0
Linked Lists
Outline
 Introduction
 Insertion

Description
 Deletion Description
 Basic Node Implementation
 Conclusion
Outline
 Introduction
 Insertion

Description
 Deletion Description
 Basic Node Implementation
 Conclusion
Introduction
 Definitions






Lists and arrays
Nodes and pointers
Single Linked Lists
Double Linked Lists
Circular...
Defination:
A linked list is a series of connected nodes (or links)
where each node is a data structure.
Dynamically alloc...
Introduction
 Definitions






Lists and arrays
Nodes and pointers
Single Linked Lists
Double Linked Lists
Circular...
Lists and arrays
 Lists:
Lists and arrays
 Arrays:
{Size of the following array is = 4}

Index
Value

0
44

1
5

2
96

3
3
Introduction
 Definitions






Lists and arrays
Nodes and pointers
Single Linked Lists
Double Linked Lists
Circular...
Nodes and pointers
Introduction
 Definitions






Lists and arrays
Nodes and pointers
Single Linked Lists
Double Linked Lists
Circular...
Single linked lists
Introduction
 Definitions






Lists and arrays
Nodes and pointers
Single Linked Lists
Double Linked Lists
Circular...
Double Linked Lists
Introduction
 Definitions






Lists and arrays
Nodes and pointers
Single Linked Lists
Double Linked Lists
Circular...
Circular Lists
Introduction
 Definitions






Lists and arrays
Nodes and pointers
Single Linked Lists
Double Linked Lists
Circular...
Advantages
 Linked

lists are more complex to code and manage
than arrays, but they have some distinct advantages.

a) A
...
Outline
 Introduction
 Insertion

Description
 Deletion Description
 Basic Node Implementation
 Conclusion
Insertion Description
 Insertion

at the top of the list
 Insertion at the end of the list
 Insertion in the middle of ...
Insertion Description
 Insertion

at the top of the list
 Insertion at the end of the list
 Insertion in the middle of ...
Insertion at the top
Steps:
 Create a Node
 Set the node data Values
 Connect the pointers
Insertion Description
head
 Follow

48

17

142

the previous steps and we get

Step 1

Step 2

Step 3

head

93

//
Insertion Description
 Insertion

at the top of the list
 Insertion at the end of the list
 Insertion in the middle of ...
Insertion at the end
Steps:
 Create a Node
 Set the node data Values
 Connect the pointers
Insertion Description
head
 Follow
Step 1

48

17

142

the previous steps and we get
Step 2

Step 3

//
Insertion Description
 Insertion

at the top of the list
 Insertion at the end of the list
 Insertion in the middle of ...
Insertion in the middle
Steps:
 Create a Node
 Set the node data Values
 Break pointer connection
 Re-connect the poin...
Insertion Description
Step 1

Step 3

Step 4

Step 2
Outline
 Introduction
 Insertion

Description
 Deletion Description
 Basic Node Implementation
 Conclusion
Deletion Description
 Deleting

from the top of the list
 Deleting from the end of the list
 Deleting from the middle o...
Deletion Description
 Deleting

from the top of the list
 Deleting from the end of the list
 Deleting from the middle o...
Deleting from the top
Steps
 Break the pointer connection
 Re-connect the nodes
 Delete the node
Deletion Description
head
6

4

17

42

6

4

17

42

4

17

42

head

head
Deletion Description
 Deleting

from the top of the list
 Deleting from the end of the list
 Deleting from the middle o...
Deleting from the end
Steps
 Break the pointer connection
 Set previous node pointer to NULL
 Delete the node
Deletion Description
head
6

head

4

17

6

4

17

6

4

17

head

42

42
Deletion Description
 Deleting

from the top of the list
 Deleting from the end of the list
 Deleting from the middle o...
Deleting from the Middle
Steps
 Set previous Node pointer to next node
 Break Node pointer connection
 Delete the node
Deletion Description
head
4

17

42

head
4

17

head
4

42

42
Outline
 Introduction
 Insertion

Description
 Deletion Description
 Basic Node Implementation
 Conclusion
Basic Node Implementation
The following code is written in C++:
Struct Node
{
int data;

be another struct

Node *next;

p...
Outline
 Introduction
 Insertion

Description
 Deletion Description
 Basic Node Implementation
 Conclusion
Upcoming SlideShare
Loading in...5
×

Linked lists by ammara siddiqui

1,360

Published on

Published in: Education, Technology, Spiritual
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,360
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
146
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Linked lists by ammara siddiqui"

  1. 1. Linked Lists
  2. 2. Outline  Introduction  Insertion Description  Deletion Description  Basic Node Implementation  Conclusion
  3. 3. Outline  Introduction  Insertion Description  Deletion Description  Basic Node Implementation  Conclusion
  4. 4. Introduction  Definitions      Lists and arrays Nodes and pointers Single Linked Lists Double Linked Lists Circular Lists  Advantages
  5. 5. Defination: A linked list is a series of connected nodes (or links) where each node is a data structure. Dynamically allocated data structures can be linked together to form a chain. A linked list can grow or shrink in size as the program runs.This is possible because the nodes in a linked list are dynamically allocated.
  6. 6. Introduction  Definitions      Lists and arrays Nodes and pointers Single Linked Lists Double Linked Lists Circular Lists  Advantages
  7. 7. Lists and arrays  Lists:
  8. 8. Lists and arrays  Arrays: {Size of the following array is = 4} Index Value 0 44 1 5 2 96 3 3
  9. 9. Introduction  Definitions      Lists and arrays Nodes and pointers Single Linked Lists Double Linked Lists Circular Lists  Advantages
  10. 10. Nodes and pointers
  11. 11. Introduction  Definitions      Lists and arrays Nodes and pointers Single Linked Lists Double Linked Lists Circular Lists  Advantages
  12. 12. Single linked lists
  13. 13. Introduction  Definitions      Lists and arrays Nodes and pointers Single Linked Lists Double Linked Lists Circular Lists  Advantages
  14. 14. Double Linked Lists
  15. 15. Introduction  Definitions      Lists and arrays Nodes and pointers Single Linked Lists Double Linked Lists Circular Lists  Advantages
  16. 16. Circular Lists
  17. 17. Introduction  Definitions      Lists and arrays Nodes and pointers Single Linked Lists Double Linked Lists Circular Lists  Advantages
  18. 18. Advantages  Linked lists are more complex to code and manage than arrays, but they have some distinct advantages. a) A ◦ linked list can easily grow and shrink in size The programmer doesn’t need to know how many nodes will be in the list. They are created in memory as needed. b) Speed of insertion or deletion from the list ◦ Inserting and deleting elements into and out of arrays requires moving elements of the array. When a node is inserted, or deleted from a linked list, none of the other nodes have to be moved .
  19. 19. Outline  Introduction  Insertion Description  Deletion Description  Basic Node Implementation  Conclusion
  20. 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. 21. Insertion Description  Insertion at the top of the list  Insertion at the end of the list  Insertion in the middle of the list
  22. 22. Insertion at the top Steps:  Create a Node  Set the node data Values  Connect the pointers
  23. 23. Insertion Description head  Follow 48 17 142 the previous steps and we get Step 1 Step 2 Step 3 head 93 //
  24. 24. Insertion Description  Insertion at the top of the list  Insertion at the end of the list  Insertion in the middle of the list
  25. 25. Insertion at the end Steps:  Create a Node  Set the node data Values  Connect the pointers
  26. 26. Insertion Description head  Follow Step 1 48 17 142 the previous steps and we get Step 2 Step 3 //
  27. 27. Insertion Description  Insertion at the top of the list  Insertion at the end of the list  Insertion in the middle of the list
  28. 28. Insertion in the middle Steps:  Create a Node  Set the node data Values  Break pointer connection  Re-connect the pointers
  29. 29. Insertion Description Step 1 Step 3 Step 4 Step 2
  30. 30. Outline  Introduction  Insertion Description  Deletion Description  Basic Node Implementation  Conclusion
  31. 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. 32. Deletion Description  Deleting from the top of the list  Deleting from the end of the list  Deleting from the middle of the list
  33. 33. Deleting from the top Steps  Break the pointer connection  Re-connect the nodes  Delete the node
  34. 34. Deletion Description head 6 4 17 42 6 4 17 42 4 17 42 head head
  35. 35. Deletion Description  Deleting from the top of the list  Deleting from the end of the list  Deleting from the middle of the list
  36. 36. Deleting from the end Steps  Break the pointer connection  Set previous node pointer to NULL  Delete the node
  37. 37. Deletion Description head 6 head 4 17 6 4 17 6 4 17 head 42 42
  38. 38. Deletion Description  Deleting from the top of the list  Deleting from the end of the list  Deleting from the middle of the list
  39. 39. Deleting from the Middle Steps  Set previous Node pointer to next node  Break Node pointer connection  Delete the node
  40. 40. Deletion Description head 4 17 42 head 4 17 head 4 42 42
  41. 41. Outline  Introduction  Insertion Description  Deletion Description  Basic Node Implementation  Conclusion
  42. 42. Basic Node Implementation The following code is written in C++: Struct Node { int data; be another struct Node *next; piece of code “pointer” }; //any type of data could //this is an important
  43. 43. Outline  Introduction  Insertion Description  Deletion Description  Basic Node Implementation  Conclusion
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×