What is the disadvantage of singly linked list?

Linked List – Linked List consists of nodes attached to each other where every node holds the address of the other node.

We can create two types of linear linked List 

  1. Singly Linked List
  2. Doubly Linked List

What is a Singly Linked List?

A Singly Linked List consists of Nodes attached to each other where each node has two members – ‘data’ and ‘next’ .’data’ is the data of the nodes and ‘next’ stores the address of the next node.

Here is the diagrammatic representation of singly Linked List

What is the disadvantage of singly linked list?

Advantages of Singly Linked List

  • Less memory is required for storing the members (2 members – data and next)
  • During execution, we can deallocate or allocate memory very easily.
  • Insertion and Deletion don’t require the shifting of all elements as required in the array.

Disadvantages of Singly Linked List

  • Insertion and Deletion of element require O(N) time.
  • Accessing the previous node is not possible since we do not have prev pointer.

What is a Doubly Linked List?

Doubly Linked List consists of Nodes attached to each other where each node has three members – ‘data’, ‘prev’ and  ‘next’ .’data’ is the data of the nodes,’ prev’ stores the address of the previous node, and ‘next’ stores the address of the next node.

Here is the diagrammatic representation of Doubly Linked List

What is the disadvantage of singly linked list?

Advantages of Doubly Linked List

  • Traversal can be done in both directions (either forward or backward since we are now available with two pointers – next and prev)
  • Accessing the previous node easy since we have prev pointer.
  • Insertion and Deletion of element require O(1) time.
  • Insertion and Deletion don’t require the shifting of all elements as required in the array.
  • During execution, we can deallocate or allocate memory very easily.

Disadvantages of Doubly Linked List

  • More memory is required for storing the members (3 members – data , prev and next)
  • Random Access is not available since elements are stored randomly where every node points to other nodes which is present randomly.

Now let us analyze the difference between Singly Linked List and Doubly Linked List.

S.No.ParametersSingly Linked List (SLL)Doubly Linked List (DLL)
1.MembersIt has two members – data and next (‘data’ for holding the data of the current node and ‘next’ for holding the address of the next node)It has three members – data, prev, and next (‘data’ for holding the data of the current node, ‘prev’ for storing the address of the previous node, and ‘next’ for storing the address of the next node)
2.DirectionalIt is unidirectional since traversing can be done using the next pointer only.It is bidirectional since traversing can be done using the next and prev pointer.
3.Insertion and Deletion operationInsertion and deletion can be done in O(n)Insertion and deletion can be done in O(1)
4.MemoryIt requires less memory since we need 2 members.It requires more memory since we need 3 members.

Some Important Questions on LinkedList:

Special thanks to Gurmeet Singh for contributing to this article on takeUforward. If you also wish to share your knowledge with the takeUforward fam, please check out this article

Que-    Advantage and Disadvantage of singly Linked list and Doubly Linked list


SINGLY LINKED LIST


*ADVANTAGE :-
1) Insertions and Deletions can be done easily.
2) It does not need movement of elements for insertion and deletion.
3) It space is not wasted as we can get space according to our requirements.
4) Its size is not fixed.
5) It can be extended or reduced according to requirements.
6) Elements may or may not be stored in consecutive memory available,even then we can store the data in computer.
7) It is less expensive.


*DISADVANTAGE :-
1) It requires more space as pointers  are also stored  with information.
2) Different amount of time is required to access each element.
3) If we have to go to a particular element then we have to go through all those elements that come before that element.
4) we can not traverse it from last & only from the beginning.
5) It is not easy to sort the elements stored in the linear linked list.



-----------------------------------------------------------------------------------------------------------

DOUBLY LINKED LIST

*ADVANTAGE :-

1) We can traverse in both direction i.e from starting to end & as well as from end to starting.
2) It is easy to reverse the linked list.
3) If we are at a node,the we can go at any node.But in linked list,it is not possible to reach the previous node.



*DISADVANTAGE :-

1) It requires more space per space per node because extra field is required for pointer to previous node.
20 Insertion and Deletion take more time than linear linked list because more pointer operations are required than linear linked list. 

There are many data structures like arrays, linked lists, etc. Each sort of arrangement has its strengths and weaknesses. For these reasons, it’s important to know the benefits and drawbacks of different data structures when it comes to designing, optimizing, and scaling programs. In this article, we will discuss the advantages and disadvantages of the linked list.

Linked List:

A Linked list is a dynamic arrangement that contains a “link” to the structure containing the subsequent items. It’s a set of structures ordered not by their physical placement in memory (like an array) but by logical links that are stored as a part of the info within the structure itself.

A linked list is another way to collect similar data. However, unlike an array, elements during a linked list aren’t in consecutive memory locations. A linked list consists of nodes that are connected with one another using pointers. The figure illustrates a linked list.



Types Of Linked List:

  • Singly Linked List: It is the simplest type of linked list in which every node contains some data and a pointer to the next node of the same data type. The node contains a pointer to the next node means that the node stores the address of the next node in the sequence. A single linked list allows the traversal of data only in one way.
  • Doubly or Two Way Linked List: A doubly linked list or a two-way linked list is a more complex type of linked list that contains a pointer to the next as well as the previous node in sequence, Therefore, it contains three parts are data, a pointer to the next node, and a pointer to the previous node. This would enable us to traverse the list in the backward direction as well.
  • Circular Linked List: A circular linked list is that in which the last node contains the pointer to the first node of the list. While traversing a circular linked list, one can begin at any node and traverse the list in any direction forward and backward until reaching the same node where started. Thus, a circular linked list has no beginning and no end.
  • Circular Doubly Linked List: A Doubly Circular linked list or a circular two-way linked list is a more complex type of linked-list that contains a pointer to the next as well as the previous node in the sequence. The difference between the doubly linked and circular doubly list is the same as that between a singly linked list and a circular linked list. The circular doubly linked list does not contain null in the previous field of the first node.

Advantages Of Linked List:

  • Dynamic data structure: A linked list is a dynamic arrangement so it can grow and shrink at runtime by allocating and deallocating memory. So there is no need to give the initial size of the linked list.
  • No memory wastage: In the Linked list, efficient memory utilization can be achieved since the size of the linked list increase or decrease at run time so there is no memory wastage and there is no need to pre-allocate the memory.
  • Implementation: Linear data structures like stack and queues are often easily implemented using a linked list.
  • Insertion and Deletion Operations: Insertion and deletion operations are quite easier in the linked list. There is no need to shift elements after the insertion or deletion of an element only the address present in the next pointer needs to be updated.

Disadvantages Of Linked List:

  • Memory usage: More memory is required in the linked list as compared to an array. Because in a linked list, a pointer is also required to store the address of the next element and it requires extra memory for itself.
  • Traversal: In a Linked list traversal is more time-consuming as compared to an array. Direct access to an element is not possible in a linked list as in an array by index. For example, for accessing a node at position n, one has to traverse all the nodes before it.
  • Reverse Traversing: In a singly linked list reverse traversing is not possible, but in the case of a doubly-linked list, it can be possible as it contains a pointer to the previously connected nodes with each node. For performing this extra memory is required for the back pointer hence, there is a wastage of memory.
  • Random Access: Random access is not possible in a linked list due to its dynamic memory allocation.

Article Tags :

Practice Tags :