linked list
Upcoming SlideShare
Loading in...5
×
 

linked list

on

  • 5,002 views

leniar linklist ppt with facebook theme

leniar linklist ppt with facebook theme

Statistics

Views

Total Views
5,002
Views on SlideShare
5,001
Embed Views
1

Actions

Likes
1
Downloads
118
Comments
0

1 Embed 1

http://192.168.33.10 1

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

linked list linked list Presentation Transcript

  • Dgroup@mca.com ************Presentation ON BY D Group
  • Member of D group Privanka Dabhai Insert at first in single linked list Praful Aparnathi Insert at Last in single linked list Arpan Shah Insert at Order in single linked list Narendra Chauhan Delete in single linked list Ram Sanjay Copy in single linked list Rushabh Bhavsar MCQ Bhavisha Purohit
  • Index Of Linear Linked List INDEX 1.Introduction 2.Algorithms 3.MCQ
  • Introduction Of Linked List Introduction Of Linked ListThis subsection describes in detail therepresentation of linear lists using linkedallocation. Algorithms such as the insertion ofnodes and the deletion of nodes from a linkedlinear list are given.The programming aspects of linked allocationare discussed both from the simulation point ofview, using arrays, and from the programmerdefined data type facility available in pascal.
  • Introduction Of Linked List Introduction Of Linked ListThe first approach is the one which is usually taken inprogramming linked represented structures in languagesthat do not have pointer or link facilities, such asFORTRAN,ALGOL 60 and BASIC, while the secondapproach is used in languages that do have pointerfacilities, such as Pascal, PL/ISNOBOL,ALGOL 68 andALGOL W.
  • Introduction Of Linked ListIntroduction Of Linked List info Link
  • Introduction Of Linked List Introduction Of Linked ListThe pointer variable AVAIL contains the address of the topnode in the stack. The address of the next available nodeis to be stored in the variable NEW.If a node is available then the new top most element of thestack is denoted by LINK(AVAIL). The fields of the nodecorresponding to the pointer value of NEW can now befilled in and the field LINK(NEW) is set to a value whichdesignates the successor node of this new node.
  • Introduction Of Linked ListA similar procedure can be formulated for thereturn of a discarded node to the availabilitystack. If the address of this discarded node isgiven by the variable FREE, then the link fieldof this node is set to the present value ofAVAIL and the value of FREE becomes thenew value of AVAIL.We can now formulate an algorithm whichinserts a node into a linked linear list in astack like manner.
  • Algorithms of Linked List Algorithms → Insert at first in single linked list → Insert at Last in single linked list → Insert at Order in single linked list → Delete in single linked list → Copy in single linked list
  • Insert at first in single linked Insert at first in single linked listINSERT(X,FIRST) Where X is a new element and FIRST, a pointer to the first elementof a linked linear list whose typical node contains INFO and LINK fieldsas previously described, this function insert X. AVAIL is a pointer to thetop element of the availability stack; NEW is a temporary pointervariable. It is required that X precede the node whose address is givento the FIRST.
  • INSERT(X,FIRST) linked list Insert at first in single linked listStep 1: [Underflow?] if AVAIL= NULL Then write (“Availability stack underflow”) return (FIRST) Step 2: [Obtain address of next free node] NEW ←AVAILStep 3: [Remove free node from availabilitynode] AVAIL ← Step 4: [Initialize fields node from availability LINK(AVAIL) stack] INFO(NEW) ← X LINK(NEW) ← FIRSTStep 5: [Return address of new node] Return(NEW)
  • INSERT_LAST(X,FIRST) Insert at Last in single linked listINSERT_LAST(X,FIRST) Where X is a new element and FIRST, a pointer to the firstelement of a linked linear list whose typical node contains INFO andLINK fields as previously described, this function insert X. AVAIL is apointer to the top element of the availability stack; NEW & SAVE aretemporary pointer variable. It is required that X be inserted at the end ofthe list.
  • INSERT_LAST(X,FIRST) Insert at Last in single linked listStep 1: [Underflow?] if AVAIL= NULL then write (“Availability stack underflow”) return (FIRST)Step 2: [Obtain address of next free node] NEW ← AVAILStep 3: [Remove free node from availability node] AVAIL ← LINK(AVAIL)Step 4: [Initialize fields node from availability stack] INFO(NEW) ← X LINK(NEW) ← NULL
  • INSERT_LAST(X,FIRST) Insert at Last in single linked listStep 5: [Is the list EMPTY?] if FIRST= NULL then Return(NEW)Step 6: [Initiate search for the last node] SAVE ← FIRSTStep 7 : [Search for end of list] Repeat while LINK(SAVE) ≠ NULL SAVE ← LINK(SAVE)Step 8 : [Set LINK Field of last node to NEW] LINK(SAVE) ← NEWStep 9: [Return first node] Return(FIRST)
  • INSERT_ORD(X,FIRST) Insert at Order in single linked listINSERT_ORD(X,FIRST) Where X is a new element and FIRST, a pointer to the firstelement of a linked linear list whose typical node contains INFO andLINK fields as previously described, AVAIL is a pointer to the topelement of the availability stack; NEW & SAVE are temporary pointervariable. It is required that X be inserted so that it preserves the orderingof the terms in increasing order of their INFO fields.
  • INSERT_ORD(X,FIRST) Insert at Order in single linked listStep 1: [Underflow?] if AVAIL= NULL then write (“Availability stack underflow”) return (FIRST)Step 2: [Obtain address of next free node] NEW ← AVAILStep 3: [Remove free node from availability node] AVAIL ← LINK(AVAIL)Step 4: [Copy information contents into new node] INFO(NEW) ← XStep 5: [Is the list EMPTY?] if FIRST= NULL then Return(NEW)
  • INSERT_ORD(X,FIRST) Insert at Order in single linked listStep 6: [Does the new node precede all others in the list?] if INFO(NEW) ≤ INFO(FIRST) then LINK(NEW) ← FIRST Return(NEW)Step 7 : [Initialize temporary pointer] SAVE ← FIRSTStep 8 : [Search for predecessor of new node] Repeat while LINK(SAVE) ≠ NULL and INFO(LINK(SAVE)) ≤ INFO (NEW) SAVE ← LINK(SAVE)Step 9 : [Set LINK Field of new node and its predecessor] LINK(NEW) ← LINK(SAVE) LINK(SAVE) ← NEWStep 10: [Return first node] Return(FIRST)
  • DELETE(X,FIRST)Delete in single linked list Where X and FIRST, pointer Variablewhose values denote the address of a nodein linked list and the address of the firstnode in the linked list, respectively, thisprocedure deletes the node whose addressis given by X. TEMP is used to find thedesired node, and PRED keeps track of thepredecessor of TEMP. note that FIRST ischanged only when X is the first elementsof the list.
  • DELETE(X,FIRST)Delete in single linked listStep 1: [EMPTY LIST?] if FIRST= NULL then write (“Underflow”) returnStep 2: [Initialize search for X] TEMP ← FIRSTStep 3: [Find X] Repeat thru Step 5 while TEMP ≠ x and LINK(TEMP) ≠ NULLStep 4: [Update Predecessor Marker ] PRED ← TEMPStep 5: [Move to next node] TEMP ← LINK(TEMP)
  • DELETE(X,FIRST)Delete in single linked listStep 6: [End of the list?] if TEMP ≠ X then write(„NODE NOT FOUND”) returnStep 7: [Delete X] if X = FIRST (is X the First NODE?) then FIRST ← LINK(FIRST) else LINK(PRED) ← LINK(X)Step 8 : [Return node to availability area] LINK(X) ← AVAIL AVAIL ← X return
  • COPY(FIRST) Copy in single linked list Given FIRST, a pointer to the firstnode in the linked list, this function makes acopy of this list. A typical node in the givenlist consists of INFO and LINK fields. The newlist is to contain nodes whose informationand pointer fields are denoted by FIELD andPTR, respectively. The address of the firstnode in the newly created list is to be placedin BEGIN. NEW,SAVE and PRED are pointervariable.
  • COPY(FIRST) Copy in single linked listStep 1: [EMPTY LIST?] if FIRST= NULL then write (“Underflow”) returnStep 2: [Copy first node] if AVAIL = NULL then write(„Availability Stack UNDERFLOW‟) return(0) else NEW ← AVAIL AVAIL ← LINK(AVAIL) FIELD(NEW) ← INFO(FIRST) BEGIN ← NEWStep 3: [Initialize traversal]SAVE ← FIRST
  • COPY(FIRST)Copy in single linked listStep 4: [Move to next node if not at the end of list] Repeat through step 6 while LINK(SAVE) ≠ NULLStep 5: [Update Predecessor and save pointers ] PRED ← NEW SAVE ← LINK(SAVE)Step 6: [Copy Node] if AVAIL = NULL then write(„Availability Stack UNDERFLOW‟) return(0) else NEW ← AVAIL AVAIL ← LINK(AVAIL) FIELD(NEW) ← INFO(SAVE) PTR(PRED) ← NEW
  • COPY(FIRST)Copy in single linked listStep 7 : [Set Link of last node and return] PTR(NEW) ← NULL Return NULL return
  • Linear Linked List MCQ PPT
  • Linear Linked List MCQ PPT1)A linear Structure in which the individual elements are joined together byreferences to other elements in the structure is known as a_________•Tree (b) Vector (c) Linked list (d) Table2)A list that restricts insertions and removals to the front ( or top ) is known as a(b) Linked list (b) stack (c) queue (d) frontal List3)To Access an item in a singly linked list you must usa a _______ algorithm.(b) Traversal (b) access (c) removal (d) insertion4)Linked lists are collections of data items “lined up in row”-insertions and deletion can be made only at the front and the back of a linked list.(b) TRUE (b) FALSE5)Self-referential objects can be linked together to from useful data structures such as lists,queues,stacks and tree(a) TRUE (b) FALSE
  • Linear Linked List MCQ PPT6)The situation when in a linked list START=NULL is(a) Underflow (b) overflow (c) housefull (d) saturated7)The link field in the last node of the linked list contains(a) NULL (b) link to the first node (c) pointer to the next element (d) Zero value8)To delete a node at the beginning of the list, the location of the list is modified as the address of the.(a) Second element in the list (b)First element in the list (c) Last element in the list.9) In the linked list representation of the stacks, the top of the stack is represented by(a)The last node (b) Any of the nodes (c) First node10) A linked list in which the last node points to the first is called a(a) Doubly linked list (b) Circular list (c) Generalized list
  • THANK YOU