Past exam question: 2072 Ashwin (Regular), Q5
Open in the Padhaiko appQuestion
Define different types of linked list with suitable example.
Solution
Three Main Types of Linked List:
- Singly Linked List (SLL): Each node stores
(data, next), linking strictly forward; the last node'snextisNULL.- Example:
head -> [10|*] -> [20|*] -> [30|NULL]
- Example:
- Doubly Linked List (DLL): Each node stores
(prev, data, next), enabling both forward and backward traversal;head->prev = NULLandtail->next = NULL.- Example:
NULL <- [10] <-> [20] <-> [30] -> NULL
- Example:
- Circular Linked List (CLL): The last node's
nextpoints back toheadinstead ofNULL(can be singly or doubly circular), useful for round-robin CPU scheduling.- Example:
head -> [10] -> [20] -> [30] --(back to 10)
- Example:
Answer:
The three types of linked list are Singly Linked List (one-way next links ending in NULL), Doubly Linked List (two-way prev and next links), and Circular Linked List (tail links back to head).