Understanding LinkedList Data Structure and Real-life Use Cases
Tags: dsa, java, linkedlist, webdev
Published: 2023-11-03 13:24:38

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fw07p42wv3gvtb7qchlc.jpg)

## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pwzptd6gbeksks48pwu2.jpg)

_**Node Creation-**_

```
struct node {
    int data;           // Data 
    struct node * next; // Address 
};
```

**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pvbgzlckd2y35gtzsvmj.jpg)

_**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; 
        }
    }
}
```

**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/42xofzkfu9u7vfew8sgo.jpg)


## 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**]
(https://dev.to/believer15/implementation-of-linkedlist-1eka)