Data Structures and Algorithms - Old Questions

6. Differentiate between Singly linked list, DLL, CLL and DCLL.

5 marks | Asked in 2067

Singly Linked List

Singly linked list is a sequence of elements in which every element has link to its next element in the sequence. In any single linked list, the individual element is called as "Node". Every "Node" contains two fields, data and next. The data field is used to store actual value of that node and next field is used to store the address of the next node in the sequence.

In this type of linked list, only one link in each node, where the link points to the next node in the list. The link of last node has a NULL pointer.

The graphical representation of a node in a single linked list is as follows...


The following example is a singly linked list that contains three elements 12, 99, & 37.


Doubly Linked List (DLL)

Doubly linked list is a sequence of elements in which every element has links to its previous element and next element in the sequence.

In double linked list, every node has link to its previous node and next node. So, we can traverse forward by using next field and can traverse backward by using previous field. Every node in a double linked list contains three fields and they are shown in the following figure...

Here, 'link1' field is used to store the address of the previous node in the sequence, 'link2' field is used to store the address of the next node in the sequence and 'data' field is used to store the actual value of that node.

Example:


Circular Linked List (CLL)

Circular linked list is a sequence of elements in which every element has link to its next element in the sequence and the last element has a link to the first element in the sequence.

Example:


Circular list has no end.

In a circular linked list there are two methods to know if a node is the first node or not.

  • Either a external pointer, list, points the first node or
  • header node is placed as the first node of the circular list.

Doubly Circular Linked List (DCLL)

circular doubly linked list is one which has the successor and predecessor pointer in circular manner. It is a doubly linked list where the next link of last node points to the first node and previous link of first node points to last node of the list. E.g.