Linked list advantages



In the previous chapter we have studied what is linked list ? In this chapter we will be learning some of the advantages of linked list.

Advantages of linked list

Firstly understand the basic concept of linked list and take a look at below diagram of linked list –

Addres and Linked List Node Strucutre in Programming
List of advantages :

  1. Linked List is Dynamic data Structure .
  2. Linked List can grow and shrink during run time.
  3. Insertion and Deletion Operations are Easier
  4. Efficient Memory Utilization ,i.e no need to pre-allocate memory
  5. Faster Access time,can be expanded in constant time without memory overhead
  6. Linear Data Structures such as Stack,Queue can be easily implemeted using Linked list

Need of linked list

Suppose you are writing a program which will store marks of 100 students in maths. Then our logic would be like this during compile time –

int marks[100];

Now at run time i.e after executing program if number of students are 101 then how you will store the address of 101th student ?

Or if you need to store only 40 students then again you are wasting memory unnecessarily.

Using linked list you can create memory at run time or free memory at run time so that you will able to fulfil your need in efficient manner

Explanation

Now we will be learning linked list advantages in more details –

1. Linked List is Dynamic in Nature

  1. Linked List Data Structure is Dynamic in nature.
  2. We can have to just create Linked List structure and memory will be allocated at run time i.e while running program.
  3. At run time we can allocate as much memory as we can.
  4. Though you can allocate any number of nodes, still there is limit for allocation of memory . (We can allocate memory considering that heap size will not be exceeded)

Re-commanded article : Dynamic memory allocation

2. Insertion and Deletion Operations are easy

  1. Insertion and Deletion operations in Linked List is very flexible.
  2. We can insert any node at any place easily and similarly we can remove it easily.
  3. We don’t have to shift nodes like array insertion. In Insertion operation in linked list , we have to just update next link of node.

3. Memory Utilization

  1. As explained earlier we don’t have to allocate memory at compile time.
  2. Memory is allocated at run time as per requirement, so that Linked list data structure provides us strong command on memory utilization.

Singly-linked-list in c programming