SlideShare ist ein Scribd-Unternehmen logo
1 von 18
List Data Structure
What is List? ,[object Object],[object Object]
List operations ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Illustration/example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Illustration/example ,[object Object],List’s contents Return value 1. Initialiaze(L) <empty> - 2. Add(0,A,L) A - 3. Add(0,B,L) B  A  - 4. Add(1,C,L) B  C  A - 5. Set(1,N,L) B  N  A - 6. Add(1,D,L) B  D  N  A - 7. Remove(A,L) B  D  N A 8. Set(3,I,L) B  D  N  I - 9. Remove(D,L) B N  I D 10. Remove(N,L) B I N
Exercise: List Operation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Storing a list in a static data structure (Array List) ,[object Object],[object Object],[object Object],[object Object],[object Object]
Storing a list in a dynamic data structure (Linked List) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Adding a node   The new node is to be added at a specified index in the list ,[object Object],Another special case is that the  specified index is 0  (the node is to be added at the  front of the list ).
Adding a node (2) ,[object Object],[object Object],If the new node is to be added at the end of the list, then the NextNode of the last element is set to refer to the new node.
Adding a node (3)  A possible algorithm (pseudocode) for the Add operation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Additional operations can also be implemented to add to the beginning and end of the list. AddFirst (Data, LinkedList) calls Add(0, Data, LinkedList) AddLast (Data, LinkedList) calls Add(Size, LinkedList), where Size is itself a call to the Size operation of the list.
Removing a node ,[object Object],[object Object],In the general case, an object reference Probe moves through the list until the required node is reached – at each node the current node (Probe) is compared with TargetNode. A Previous object reference is also required to keep track of the predecessor of the node to be removed. A special case is when both references point to the same node – this happens when the first node is to be deleted. To delete the current node we can set Previous.NextNode to be equal to Probe.NextNode.
Removing a node (2)
Accessing nodes (Get, Set, IndexOf, View) ,[object Object],[object Object],[object Object]
Variations on Linked Lists ,[object Object],[object Object],Doubly linked lists These permit scanning or searching of the list in both directions. (To go backwards in a simple list, it is necessary to go back to the start and scan forwards.) In this case, the node structure is altered to have two links: Sorted lists Lists can be designed to be maintained in a given order. In this case, the Add method will search for the correct place in the list to insert a new data item.
List Implementation
List Implementation in Java ,[object Object],[object Object],[object Object],[object Object],[object Object]
List Implementation in Java ,[object Object]

Weitere ähnliche Inhalte

Was ist angesagt?

Data structure lecture 5
Data structure lecture 5Data structure lecture 5
Data structure lecture 5
Kumar
 
Linked list
Linked listLinked list
Linked list
VONI
 

Was ist angesagt? (20)

Linked list
Linked listLinked list
Linked list
 
Circular link list.ppt
Circular link list.pptCircular link list.ppt
Circular link list.ppt
 
Python lists
Python listsPython lists
Python lists
 
Linked List
Linked ListLinked List
Linked List
 
Data Structures with C Linked List
Data Structures with C Linked ListData Structures with C Linked List
Data Structures with C Linked List
 
linked list (c#)
 linked list (c#) linked list (c#)
linked list (c#)
 
Bca data structures linked list mrs.sowmya jyothi
Bca data structures linked list mrs.sowmya jyothiBca data structures linked list mrs.sowmya jyothi
Bca data structures linked list mrs.sowmya jyothi
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
 
linklisr
linklisrlinklisr
linklisr
 
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
 
Data Structures 3
Data Structures 3Data Structures 3
Data Structures 3
 
Linked lists
Linked listsLinked lists
Linked lists
 
single linked list
single linked listsingle linked list
single linked list
 
Linklist
LinklistLinklist
Linklist
 
Data structure lecture 5
Data structure lecture 5Data structure lecture 5
Data structure lecture 5
 
Link list
Link listLink list
Link list
 
Linked list
Linked listLinked list
Linked list
 
Ppt on Linked list,stack,queue
Ppt on Linked list,stack,queuePpt on Linked list,stack,queue
Ppt on Linked list,stack,queue
 
Singly linked list
Singly linked listSingly linked list
Singly linked list
 
poornima.coseq
poornima.coseqpoornima.coseq
poornima.coseq
 

Ähnlich wie List data structure

Objective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdfObjective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdf
advancethchnologies
 
Objective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdfObjective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdf
giriraj65
 
Linked List Objective The purpose of this exercise is to cr.pdf
Linked List Objective The purpose of this exercise is to cr.pdfLinked List Objective The purpose of this exercise is to cr.pdf
Linked List Objective The purpose of this exercise is to cr.pdf
adityacomputers001
 
Objective The purpose of this exercise is to create a Linked List d.pdf
Objective The purpose of this exercise is to create a Linked List d.pdfObjective The purpose of this exercise is to create a Linked List d.pdf
Objective The purpose of this exercise is to create a Linked List d.pdf
aliracreations
 
Please and Thank youObjective The purpose of this exercise is to .pdf
Please and Thank youObjective The purpose of this exercise is to .pdfPlease and Thank youObjective The purpose of this exercise is to .pdf
Please and Thank youObjective The purpose of this exercise is to .pdf
alicesilverblr
 

Ähnlich wie List data structure (20)

1.3 Linked List.pptx
1.3 Linked List.pptx1.3 Linked List.pptx
1.3 Linked List.pptx
 
Algo>ADT list & linked list
Algo>ADT list & linked listAlgo>ADT list & linked list
Algo>ADT list & linked list
 
Linked lists
Linked listsLinked lists
Linked lists
 
Linked list and its operations - Traversal
Linked list and its operations - TraversalLinked list and its operations - Traversal
Linked list and its operations - Traversal
 
Objective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdfObjective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdf
 
Objective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdfObjective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdf
 
Linked List Objective The purpose of this exercise is to cr.pdf
Linked List Objective The purpose of this exercise is to cr.pdfLinked List Objective The purpose of this exercise is to cr.pdf
Linked List Objective The purpose of this exercise is to cr.pdf
 
Chapter 3 Linkedlist Data Structure .pdf
Chapter 3 Linkedlist Data Structure .pdfChapter 3 Linkedlist Data Structure .pdf
Chapter 3 Linkedlist Data Structure .pdf
 
1 list datastructures
1 list datastructures1 list datastructures
1 list datastructures
 
General Data structures
General Data structuresGeneral Data structures
General Data structures
 
Linked List Presentation in data structurepptx
Linked List Presentation in data structurepptxLinked List Presentation in data structurepptx
Linked List Presentation in data structurepptx
 
3.ppt
3.ppt3.ppt
3.ppt
 
3.ppt
3.ppt3.ppt
3.ppt
 
Built-in Data Structures in python 3.pdf
Built-in Data Structures in python 3.pdfBuilt-in Data Structures in python 3.pdf
Built-in Data Structures in python 3.pdf
 
Data Structures & Algorithms Unit 1.pptx
Data Structures & Algorithms Unit 1.pptxData Structures & Algorithms Unit 1.pptx
Data Structures & Algorithms Unit 1.pptx
 
unit 5 stack & queue.ppt
unit 5 stack & queue.pptunit 5 stack & queue.ppt
unit 5 stack & queue.ppt
 
Chapter 15 Lists
Chapter 15 ListsChapter 15 Lists
Chapter 15 Lists
 
Objective The purpose of this exercise is to create a Linked List d.pdf
Objective The purpose of this exercise is to create a Linked List d.pdfObjective The purpose of this exercise is to create a Linked List d.pdf
Objective The purpose of this exercise is to create a Linked List d.pdf
 
Please and Thank youObjective The purpose of this exercise is to .pdf
Please and Thank youObjective The purpose of this exercise is to .pdfPlease and Thank youObjective The purpose of this exercise is to .pdf
Please and Thank youObjective The purpose of this exercise is to .pdf
 
unit 1.pptx
unit 1.pptxunit 1.pptx
unit 1.pptx
 

List data structure