DEV Community

Cover image for Understanding LinkedList Data Structure and Real-life Use Cases
Ujjwal Sinha
Ujjwal Sinha

Posted on • Edited on

Understanding LinkedList Data Structure and Real-life Use Cases

In this Article, we'll explore about LinkedList & its types and
Real-life Use Cases of LinkedList and Best Practice to use.

What is LinkedList ?

LinkedList as a linear data structure where elements are stored in nodes that are linked together by pointers, each containing the data and a reference to the next node. Unlike Arrays, Linked List elements are not stored at a contiguous location.
In a Node, there is data and address/reference of next node and last node always point to null.
As you can see in image below-

Image description

Types of linked lists

1- Singly-linked list :-In Singly-linked list, We can say that traversal of items can be done in the forward direction only due to the linking of every node to its next node.

Operation on Singly-Linked list

  • Insertion

  • Deletion

  • Search

  • Display

Below you can see representations-

Image description

Node Creation-

struct node {
    int data;           // Data 
    struct node * next; // Address 
};
Enter fullscreen mode Exit fullscreen mode

2- Doubly-linked list :- In Doubly-linked list, We can say that Traversal of items can be done in both forward and backward directions as every node contains an additional prev pointer that points to the previous node.

Operation on Doubly-Linked list

  • Insertion

  • Deletion

  • Display

Representation of Doubly linked list-

Image description

Node Creation-

// Class for Doubly Linked List
public class DLL {
    Node head; // head of list

    /* Doubly Linked list Node*/
    class Node {
        int data;
        Node prev;
        Node next;

        // Constructor to create a new node
        // next and prev is by default initialized as null
        Node(int d) { 
           data = d; 
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

3- Circular linked lists :- In Circular linked list, We can say that A circular linked list is a type of linked list in which the first and the last nodes are also connected to each other to form a circle, there is no NULL at the end.

Operation on Circular Linked list

  • Insertion

  • Deletion

  • Display

Representation of Circular linked list-

Image description

Real-life Use Cases of LinkedList

find various applications in real-life scenarios due to their dynamic memory allocation and efficient insertion and deletion operations. Here are some real-life use cases of LinkedLists:

Music and Video Playlists

In music and video streaming services, playlists are commonly implemented using LinkedLists. Each song or video is represented as a node, allowing users to easily add, remove, or rearrange the sequence of media items in their playlists.

Browser History in Web Browsers

Web browsers use LinkedLists to maintain a user's browsing history. Each visited web page is stored as a node, enabling users to navigate backward and forward through their browsing history, facilitating a seamless browsing experience.

Task Management Applications

Task management applications often utilize LinkedLists to manage to-do lists. Each task is stored as a node, enabling users to add new tasks, mark tasks as complete, or reorder tasks based on priority or due dates.

Scheduling Systems

In transportation systems, such as train or flight or Bus scheduling, LinkedLists can be used to manage the sequence of upcoming departures. Each departure schedule is stored as a node, allowing for easy rearrangement and adjustment of the schedule based on real-time changes or delays.

Check out the Implementation of Linked list

Top comments (0)