Presentation is loading. Please wait.

Presentation is loading. Please wait.

LINKED LISTS.

Similar presentations


Presentation on theme: "LINKED LISTS."— Presentation transcript:

1 LINKED LISTS

2 DEFINITION A LINKED LIST IS A SEQUENCE OF NODES CONNECTED TO EACH OTHER USING POINTERS.

3 TYPES SINGLY LINKED LIST DOUBLY LINKED LIST CIRCULARLY LINKED LIST

4 WHAT IS A NODE FIELD1 FIELD2
A NODE IS A STRUCTURE THAT CONTAINS ONE OR MORE FIELDS ALONG WITH A FIELD TO HOLD THE REFERENCE TO THE NEXT NODE FIELD1 FIELD2 FIELD3 FIELD4 LINK

5 CREATING A LIST CREATE A NODE. CALL IT HEAD NODE
EVERY TIME YOU WANT TO ADD NODES DO THE FOLLOWING: CREATE A NODE ADD A LINK TO THE NEW NODE FROM THE LAST NODE CREATED

6 LIST CREATION DATA DATA LINK HEAD NODE LINK DATA DATA LINK LINK DATA

7 DELETING A NODE IN THE MIDDLE DATA DATA LINK HEAD NODE LINK DATA DATA

8 DELETING A NODE AT THE END DATA DATA LINK HEAD NODE LINK DATA DATA

9 DELETING A NODE DELETE HEAD DATA DATA LINK HEAD NODE LINK DATA DATA

10 INSERTING A NODE HEAD NODE DATA LINK DATA LINK DATA LINK DATA LINK

11 DOUBLY LINKED LIST CONTAINS NODES WITH TWO LINK FIELDS – ONE TO PREVIOUS NODE AND ANOTHER TO NEXT NODE LINK TO PREV FIELD1 FIELD2 FIELD3 LINK TO NEXT

12 DOUBLY LINKED LIST CREATION
HEAD NODE PREV DATA NEXT PREV DATA NEXT PREV DATA NEXT TAIL NODE PREV DATA NEXT PREV DATA NEXT

13 DELETING A NODE IN A DDL DELETE THIS NODE PREV DATA PREV HEAD NODE
NEXT PREV DATA NEXT PREV DATA NEXT TAIL NODE PREV DATA NEXT PREV DATA NEXT

14 INSERT A NODE IN DLL INSERT HERE PREV DATA PREV PREV HEAD NODE NEXT
TAIL NODE PREV DATA NEXT PREV DATA NEXT

15 CIRCULARLY LINKED LIST
A SINGLY OR DOUBLY LINKED LIST WHERE THE TAIL NODE IS CONNECTED TO THE HEAD NODE IS CALLED A CIRCULARLY LINKED LIST

16 CIRCULARLY LINKED LIST CREATION
HEAD NODE PREV DATA NEXT PREV DATA NEXT PREV DATA NEXT TAIL NODE PREV DATA NEXT PREV DATA NEXT

17 INSERTION / DELETION IN CLL
SIMILAR TO THE PREVIOUS TWO TYPES. CARE MUST BE TAKEN WHEN HEAD OR TAIL GETS DELETED. SOMETIMES THERE IS NO DISTINCTION AS TO HEAD OR TAIL NODE

18 THANK YOU


Download ppt "LINKED LISTS."

Similar presentations


Ads by Google