What is the advantages and disadvantages of linked list over an array?

Advantages and Disadvantages of 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 liked 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 :
Articles
Data Structures
Linked List
Linked Lists
Practice Tags :
Data Structures
Linked List
Read Full Article

Advantages and Disadvantages of Linked List

Advantages of Linked List

Dynamic Data Structure

Linked list is a dynamic data structure so it can grow and shrink at runtime by allocating and deallocating memeory. So there is no need to give initial size of linked list.

Insertion and Deletion

Insertion and deletion of nodes are really easier. Unlike array here we don’t have to shift elements after insertion or deletion of an element. In linked list we just have to update the address present in next pointer of a node.

No Memory Wastage

As size of linked list can increase or decrease at run time so there is no memory wastage. In case of array there is lot of memory wastage, like if we declare an array of size 10 and store only 6 elements in it then space of 4 elements are wasted. There is no such problem in linked list as memory is allocated only when required.

Implementation

Data structures such as stack and queues can be easily implemented using linked list.

Disadvantages of Linked List

Memory Usage

More memory is required to store elements in linked list as compared to array. Because in linked list each node contains a pointer and it requires extra memory for itself.

Traversal

Elements or nodes traversal is difficult in linked list. We can not randomly access any element as we do in array by index. For example if we want to access a node at position n then we have to traverse all the nodes before it. So, time required to access a node is large.

Reverse Traversing

In linked list reverse traversing is really difficult. In case of doubly linked list its easier but extra memory is required for back pointer hence wastage of memory.

Video Tutorial


If you know some other advantages and disadvantages of linked list then please mention by commenting below.

You May Also Like:

  • C program that accepts marks in 5 subjects and outputs average marks
  • Difference Between equals[] and == in Java
  • C++ STL Forward List Container – std::forward_list
  • Polish Notation in Data Structure
  • 8 Best NoSQL Databases in 2022

Advantages and Disadvantages of Linked List

Advantages of Linked List

  1. The linked list is a dynamic data structure.
  2. You can also decrease and increase the linked list at run-time. That is, you can allocate and deallocate memory at run-time itself.
  3. In this, you can easily do insertion and deletion functions. That is, you can easily insert and delete the node.
  4. Memory is well utilized in the linked list. Because in it, we do not have to allocate memory in advance.
  5. Its access time is very fast, and it can be accessed at a certain time without memory overhead.
  6. You can easily implement linear data structures using the linked list like a stack, queue.

Disadvantages of Linked List

  1. The linked list requires more memory to store the elements than an array, because each node of the linked list points a pointer, due to which it requires more memory.
  2. It is very difficult to traverse the nodes in a linked list. In this, we cannot access randomly to any one node. [As we do in the array by index.] For example: - If we want to traverse a node in an n position, then we have to traverse all the nodes that come before n, which will spoil a lot of our time.
  3. Reverse traversing in a linked list is very difficult, because it requires more memory for the pointer.

Application of Linked List

The linked list is a primitive data structure, which is used in various types of applications.

  1. It is used to maintain directory names.
  2. The linked list can perform arithmetic operations in the long integer.
  3. Polynomials can be manipulated by storing constant in the node of the linked list.
  4. We can also use it to next and previous images in the image viewer.
  5. With the help of the linked list, we can move songs back and forth in the music player.
  6. The linked list is also used for undo in word and Photoshop applications.
  7. All the running applications in the computer are stored in the circular linked list, and the operating system provides them with a fixed time slot.
  8. It can also be used to implement hash tables.

Difference between linked list and array

Both array and linked list are used to store the same type of linear data, but array is allocated contiguous memory location in the compile-time while the linked list is allocated memory in run-time.

ArrayLinked List
It is a collection of the same type of data type. It is a collection of similar elements that are connected to each other by the pointers.
It supports random access, which means that we can access it directly using its index, like arr[0] for 1st element, arr[7] for the 8th element, etc.It supports sequential-access, meaning that in order to use any node in it, the user must traverse the whole list sequentially.
In the array, elements are stored in the contiguous-memory location.The elements in the linked list can be stored anywhere in memory.
The time complexity of the array is O [1].The time complexity of the linked list is O [n].
It is allocated the memory at compile-time.It is allocated the memory at run-time.
Arrays take longer to perform insertion and deletion functions than linked lists.In the linked list, both insertion and deletion operations take less time than the array.
It can be a 1-d array, 2-d array, or 3-d array.It can be a linear linked list, doubly linked list, or circular linked list.
? Previous Next ?

What are the advantages and disadvantages of linked list over array?

May 8, 2021

Table of Contents

  • What are the advantages and disadvantages of linked list over array?
  • What are the advantages of using linked lists over arrays?
  • What are the disadvantages of linked list over array?
  • What are the advantages and disadvantages of linked list in data structure?
  • What is the advantage and disadvantage of doubly linked list?
  • Why we use doubly linked list?
  • What is linked list used for?
  • Which is better array or linked list?
  • Which is true in a linked list?
  • Why do we need circular linked list?
  • What are the basic operation of linked list?
  • How data is added in linked list?
  • What is a linked list in C?
  • How does a linked list work in C?
  • What is a linked list and what are its types?
  • Can we sort a linked list?
  • Which sort is best for array?
  • Which elementary sort is the best when you are sorting a linked list?
  • When should we use merge sort?
  • How do you sort a linked list in ascending order?
  • How will you reverse a linked list in O 1 time?
  • Why is quicksort preferred for arrays?

What Are The Advantages And Disadvantages Of Lists?

Feb 09 2022

▲ 6 ▼
Answer The Question

Similar Questions

  1. What are the disadvantages of queu
  2. What is difference between Array and Lis
  3. What are the basic components of a linked lis
  4. Which is better Arraylist or linked lis
  5. What are the disadvantages of doubly linked lis
  6. What is difference between array and linked lis
  7. What are disadvantage
  8. What are the advantages and disadvantages of writin
  9. What are the disadvantages of linked list
  10. What is the biggest advantage of linked lis
  11. What are the advantages of using list compared to array in
  12. Why are linked lists better than array
  13. What are the advantages and disadvantages of linked lis
  14. What are the disadvantages of array
  15. What are the advantages and disadvantages of being ric
  16. Why insertion is faster in linked lis
  17. Why do we need linked list
  18. Are Linked lists faster than array
  19. When would you use a linked list vs Arraylis
  20. What operation is least efficient in a linked lis
  21. What are the advantages of disadvantage
Asked By: Philip Green Date: created: Feb 14 2021

Video liên quan

Bài Viết Liên Quan

Bài mới nhất

Chủ Đề