Table of contents
1.
Introduction
2.
Why Linked List Over Array?
3.
Advantages of Linked List
4.
Disadvantages of Linked List
5.
Types of Linked Lists
5.1.
Singly Linked List
5.2.
Circular Linked List
5.3.
Doubly Linked List
6.
Implementation of Linked List
7.
Frequently Asked Questions
7.1.
Name some applications of Linked List?
7.2.
What is a multiple linked list?
7.3.
How will you remove a cycle from a linked list?
8.
Conclusion
Last Updated: Mar 25, 2025
Easy

Linked List Data Structure

Author Ayush Mishra
2 upvotes
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

A Linked List is a linear Data Structure that consists of a group of nodes. Unlike an array, it has elements that are stored in random memory locations.

Each node contains two fields:

  • data stored at that particular address.
  • The pointer contains the address of the next node.

 

The last node of the Linked list contains a pointer to null to represent the termination of the linked list. Generally, we call the first node as the head node and the last node as the Tail node in the Linked List.

Linked List

Recommended Topic, Floyds Algorithm and Rabin Karp Algorithm.

Why Linked List Over Array?

The array contains the following limitations:

  • The size of an array is fixed. We must know the size of the array at the time of its creation, hence it is impossible to change its size at runtime.
  • Inserting a new element in an array of elements is expensive because we need to shift elements to create room for new elements to be inserted.
  • Deleting an element in an array is also expensive as it also takes the shifting of elements in the array.
    Also read - merge sort in linked list

Advantages of Linked List

The advantages of Linked List are:-

  • Insertion and deletion operations can be implemented very easily and these are not costly as they do not require shifting of elements.
  • They are dynamic in nature. Hence, we can change their size whenever required.
  • Stacks and queues can be implemented very easily using Linked Lists.

Disadvantages of Linked List

The disadvantages of Linked List are:-

  • Random access to an element is not possible in Linked Lists, we need to traverse Linked Lists from starting to search an element into it.
  • It is relatively slow to process in comparison to an Array.
  • Since the node of a Linked List contains both data and pointer to the next node, hence extra memory is required to store the pointer of each node.

Types of Linked Lists

Types of Linked Lists

There are three types of Linked Lists:

  • Singly Linked List
  • Circular Linked List
  • Doubly Linked List

Singly Linked List

A Singly Linked List contains a node that has both the data part and pointer to the next node. The last node of the Singly Linked List has a pointer to null to represent the end of the Linked List. Traversal to previous nodes is not possible in singly Linked List, i.e, We can not traverse in a backward direction.

Singly Linked List

Circular Linked List

A Circular Linked List is similar to a singly Linked List, but the last node of the singly Linked List has a pointer to a node that points to the first node (head node) of Linked List.

Circular Linked List

Doubly Linked List

Doubly Linked List contains a node that has three entries: (1) data part, (2) pointer to the next node, and (3) pointer to the previous node. We can traverse in both forward and backward directions in doubly Linked Lists.

Implementation of Linked List

Here we are implementing a Singly Linked List for the sake of understanding.

Implementation of Linked List
Implementation of Linked List
Implementation of Linked List

Frequently Asked Questions

Name some applications of Linked List?

Here are a few examples of Linked Lists' most common uses:

  1. We can implement queues, stacks, graphs, etc. using linked lists.
  2. We can add elements to the list's beginning and end using linked lists.

What is a multiple linked list?

Each node in a multiply linked list has two or more link fields. The same set of records are joined using each field in a different order, such as "by name, by date of birth, by the department, etc."

How will you remove a cycle from a linked list?

Floyd's cycle detect technique, also referred to as the tortoise and hare algorithm because it employs two pointers/references that move at diametrically opposed speeds, is one way to spot the cycle. If there is a cycle, the two pointers (let's say, slow and fast) will point to the same element after a finite number of steps.

Conclusion

In this article, we discussed the Linked List data structure, its types, and its advantages over arrays. We learned that linked lists provide dynamic memory allocation, efficient insertions and deletions compared to arrays. However, they also have drawbacks, such as increased memory usage and slower access times. Understanding linked lists is essential for efficient data management and forms the foundation for more complex data structures like stacks, queues, and graphs.

Live masterclass