Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests - Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests -

Difference between Singly Linked List and Doubly Linked List

Both Singly linked list and Doubly linked list are the executions of a Linked list. The singly-linked list holds data and a link to the next component. While in a doubly-linked list, every node includes a link to the previous node. Let’s discuss some major differences between the Singly linked list and the Doubly linked list.

What is a Singly Linked List?

A singly linked list is a collection of nodes, where each node has two segments. The first segment belongs to data, and the second segment belongs to the address or link.

The work of the data segment is to hold an actual piece of information, and the work of the link or address field stores the address of the next node. Insertion, deletion, and traversing are some operations that we can perform on a singly linked list.

What is a Doubly Linked List?

It is another popular type of linked list. A doubly linked list holds two addresses, and that is why it is known as a doubly-linked list. The doubly linked list contains three segments: The first segment is data. The second and third segments are pointers.

Here, the previous pointer contains the address of the previous node, and similarly, the other pointer contains the address of the next node.

Difference between Singly Linked List and Doubly Linked List

S. No. Singly linked list Doubly linked list
1 In case of singly linked lists, the complexity of insertion and deletion is O(n) In case of doubly linked lists, the complexity of insertion and deletion is O(1)
2 The Singly linked list has two segments: data and link. The doubly linked list has three segments. First is data and second, third are the pointers.
3 It permits traversal components only in one way. It permits two way traversal.
4 We mostly prefer a singly linked list for the execution of stacks. We can use a doubly linked list to execute binary trees, heaps and stacks.
5 When we want to save memory and do not need to perform searching, we prefer a singly linked list. In case of better implementation, while searching, we prefer a doubly linked list.
6 A singly linked list consumes less memory as compared to the doubly linked list. The doubly linked list consumes more memory as compared to the singly linked list.

Keep learning and stay tuned to BYJU’S to get the latest updates on GATE Exam along with GATE Eligibility Criteria, GATE 2024, GATE Admit Card, GATE Application Form, GATE Syllabus, GATE Cutoff, GATE Previous Year Question Paper, and more.

Comments

Leave a Comment

Your Mobile number and Email id will not be published.

*

*