Presentation is loading. Please wait.

Presentation is loading. Please wait.

LINKED LIST Presented By Engr. Reema Tariq Mughal.

Similar presentations


Presentation on theme: "LINKED LIST Presented By Engr. Reema Tariq Mughal."— Presentation transcript:

1 LINKED LIST Presented By Engr. Reema Tariq Mughal

2 What is Link List ? Various cells of memory are not allocated consecutively in memory. With arrays, the second element was right next to the first element. Now the first element must explicitly tell us where to look for the second element. Do this by holding the memory address of the second element

3 Linked List Create a structure called a Node. objectnext The object field will hold the actual list element. The next field in the structure will hold the starting location of the next node. Chain the nodes together to form a linked list.

4 Linked List Picture of our list (2, 6, 7, 8, 1) stored as a linked list: 26871 head current size=5

5 Linked List Note some features of the list: Need a head to point to the first node of the list. Otherwise we wont know where the start of the list is. The current here is a pointer, not an index. The next field in the last node points to nothing. We will place the memory address NULL which is guaranteed to be inaccessible

6 Linked List Actual picture in memory: 1051 1052 1055 1059 1060 1061 1062 1063 1064 1056 1057 1058 1053 10542 6 8 7 1 1051 1063 1057 1060 0 head 1054 1063 current 26871 head current 1065

7 Linked List Operations Link list operations can be better understood with the help of C Programming.


Download ppt "LINKED LIST Presented By Engr. Reema Tariq Mughal."

Similar presentations


Ads by Google