Download presentation
Presentation is loading. Please wait.
Published byRylee Ailey Modified over 10 years ago
1
Linked Lists Mohammed Almashat CS 561 26/03/2006
2
Outline Introduction Insertion Description Deletion Description Basic Node Implementation Conclusion
3
Outline Introduction Insertion Description Deletion Description Basic Node Implementation Conclusion
4
Introduction Definitions –Lists and arrays –Nodes and pointers –Single Linked Lists –Double Linked Lists –Circular Lists Advantages
5
Introduction Definitions –Lists and arrays –Nodes and pointers –Single Linked Lists –Double Linked Lists –Circular Lists Advantages
6
Lists and arrays Lists:
7
Lists and arrays Arrays: {Size of the following array is = 4} Index0123 Value445963
8
Introduction Definitions –Lists and arrays –Nodes and pointers –Single Linked Lists –Double Linked Lists –Circular Lists Advantages
9
Nodes and pointers
10
Introduction Definitions –Lists and arrays –Nodes and pointers –Single Linked Lists –Double Linked Lists –Circular Lists Advantages
11
Single linked lists
12
Introduction Definitions –Lists and arrays –Nodes and pointers –Single Linked Lists –Double Linked Lists –Circular Lists Advantages
13
Double Linked Lists
14
Introduction Definitions –Lists and arrays –Nodes and pointers –Single Linked Lists –Double Linked Lists –Circular Lists Advantages
15
Circular Lists
16
Introduction Definitions –Lists and arrays –Nodes and pointers –Single Linked Lists –Double Linked Lists –Circular Lists Advantages
17
The Linked List advantages are collected because of the array disadvantages, array disadvantages are: 1.Array Size 2.Memory allocation 3.Insertion and Deletion
18
Outline Introduction Insertion Description Deletion Description Basic Node Implementation Conclusion
19
Insertion Description Insertion at the top of the list Insertion at the end of the list Insertion in the middle of the list
20
Insertion Description Insertion at the top of the list Insertion at the end of the list Insertion in the middle of the list
21
Insertion at the top Steps: Create a Node Set the node data Values Connect the pointers
22
Insertion Description Follow the previous steps and we get 4817142 head // head 93 Step 1 Step 2 Step 3
23
Insertion Description Insertion at the top of the list Insertion at the end of the list Insertion in the middle of the list
24
Insertion at the end Steps: Create a Node Set the node data Values Connect the pointers
25
Insertion Description Follow the previous steps and we get 4817142 head // Step 1 Step 2 Step 3
26
Insertion Description Insertion at the top of the list Insertion at the end of the list Insertion in the middle of the list
27
Insertion in the middle Steps: Create a Node Set the node data Values Break pointer connection Re-connect the pointers
28
Insertion Description Step 1 Step 2 Step 3 Step 4
29
Outline Introduction Insertion Description Deletion Description Basic Node Implementation Conclusion
30
Deletion Description Deleting from the top of the list Deleting from the end of the list Deleting from the middle of the list
31
Deletion Description Deleting from the top of the list Deleting from the end of the list Deleting from the middle of the list
32
Deleting from the top Steps Break the pointer connection Re-connect the nodes Delete the node
33
Deletion Description 417 head 42 6 417 head 42 6 417 head 42
34
Deletion Description Deleting from the top of the list Deleting from the end of the list Deleting from the middle of the list
35
Deleting from the end Steps Break the pointer connection Set previous node pointer to NULL Delete the node
36
Deletion Description 417 head 42 6 417 head 42 6 417 6 head
37
Deletion Description Deleting from the top of the list Deleting from the end of the list Deleting from the middle of the list
38
Deleting from the Middle Steps Set previous Node pointer to next node Break Node pointer connection Delete the node
39
Deletion Description 417 42 head 417 head 42 4 head 42
40
Outline Introduction Insertion Description Deletion Description Basic Node Implementation Conclusion
41
Basic Node Implementation The following code is written in C++: Struct Node { int data; //any type of data could be another struct Node *next; //this is an important piece of code pointer };
42
Outline Introduction Insertion Description Deletion Description Basic Node Implementation Conclusion
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.