DAY 28: Mastering Linked Lists in Java – Singly, Doubly & Circular LL Explained | My DSA Journey – Linked List


🚀 Introduction
Welcome to Day 28 of my DSA Journey!
After spending the last few weeks mastering one of the core problem-solving techniques — Recursion — I’ve now transitioned into learning a new fundamental data structure: the Linked List.
This shift from recursion to linked lists has been exciting, as both concepts are deeply connected — especially when it comes to problems involving traversal and pointer manipulation.
Over the past 3 days, I’ve explored:
What Linked Lists are, their types, and how Singly, Doubly, and Circular Linked Lists work — all of which form the building blocks for many advanced data structures and algorithms.
I’m documenting this journey publicly to stay consistent and to help others who are starting their own DSA path from scratch.
📅 Here’s What I Covered Over the Last 3 Days:
Day 25
- Introduction to Linked List
- Types of Linked List
- Singly Linked List
Day 26
- Doubly Linked List
Day 27
- Circular Linked List
Let’s break down each of these topics below 👇
1. Introduction to Linked List:
A Linked List is a linear data structure in which elements (called nodes) are connected using pointers.
Each node contains two parts:
data
— the actual value stored.next
— a pointer/reference to the next node in the sequence.
Unlike arrays, linked lists don’t require contiguous memory allocation, making them more flexible for dynamic memory operations.
Why Use Linked Lists?
While arrays are great for indexed access and compact storage, they come with limitations:
Feature | Array | Linked List |
Memory Allocation | Fixed (contiguous) | Dynamic (non-contiguous) |
Insert/Delete at Middle | Costly (O(n)) | Efficient (O(1) if pointer known) |
Access by Index | Fast (O(1)) | Slow (O(n)) |
Memory Waste | Possible (over-allocation) | None (exact needed is allocated) |
Resizing | Requires reallocation | Handled easily via pointers |
Key Characteristics of Linked List:
- Dynamic Size: Grows or shrinks during runtime.
- Efficient Insert/Delete: Especially when manipulating the head or tail.
- No Random Access: Elements must be accessed sequentially.
- Extra Memory: Each node needs to store a pointer.
Linked lists are the foundation for several advanced data structures like stacks, queues, graphs, and even hash tables.
2. Types of Linked List:
A Linked List can be classified into several types based on how the nodes are connected and how navigation is handled. Let's explore the main types:
- Singly Linked List
- Doubly Linked List
- Circular Linked List
- Singly Circular Linked List
- Doubly Circular Linked List
3. Singly Linked List:
A Singly Linked List (SLL) is a linear data structure where each element (called a node) contains two parts:
- Data — holds the actual value
- Next — a reference (or pointer) to the next node in the sequence
In SLL, each node points only to its next node, and the last node points to null
, indicating the end of the list.
Node Structure (Java):
class Node {
int data;
Node next;
Node(int data) {
this.data = data;
this.next = null;
}
}
Explanation:
int data
: This holds the actual data or value stored in the node.Node next
: This is a reference to the next node in the linked list.- The constructor sets the initial value of the node and initializes the
next
pointer tonull
, indicating it doesn't point to any other node yet.
Example:
A single node looks like this:
Value | Next |
10 | null |
- Value holds the data (e.g., 10).
- Next holds the reference to the next node (null if no next node).
The Singly linked list looks like this:10 -> 20 -> 30 -> 40 -> 50 -> null
- Each arrow (
->
) represents thenext
pointer linking nodes. null
indicates the end of the list.
Operations in Singly Linked List
- Insertion: beginning, end, at a given position
- Deletion: beginning, end, at a given position, by value
- Search: by value
- Traversal: iterate to access all nodes
- Length: count total nodes
- Reversal: reverse the list
Advantages:
- Dynamic size (no need to define size beforehand)
- Efficient insertions and deletions at the beginning
- Uses memory only as needed (no pre-allocation)
Disadvantages:
- No backward traversal (unlike doubly linked list)
- Slower access to elements (no indexing)
- More memory overhead due to the next pointer
Use Cases:
- Implementation of stacks, queues, and hash maps
- Music/Video playlists (next song/video)
- Dynamic memory management
4. Doubly Linked List:
A Doubly Linked List (DLL) is a linear data structure where each element (called a node) contains three parts:
- Data — holds the actual value
- Next — a reference (or pointer) to the next node in the sequence
- Prev — a reference to the previous node in the sequence
In DLL, each node points to both the next and previous nodes, allowing traversal in both directions. The first node’s prev
pointer and the last node’s next
pointer both point to null
.
Node Structure (Java):
class Node {
int data;
Node next;
Node prev;
Node(int data) {
this.data = data;
this.next = null;
this.prev = null;
}
}
Explanation:
int data
: This holds the actual data or value stored in the node.Node next
: Reference to the next node in the list.Node prev
: Reference to the previous node in the list.- The constructor sets the initial value of the node and initializes both
next
andprev
pointers tonull
, indicating no connections yet.
Example:
A single node looks like this:
Prev | Value | Next |
null | 10 | null |
- Prev holds the reference to the previous node (null if no previous node).
- Value holds the data (e.g., 10).
- Next holds the reference to the next node (null if no next node).
The Doubly linked list looks like this:null <- 10 <-> 20 <-> 30 <-> 40 <-> 50 -> null
- Arrows (
<->
) representprev
andnext
pointers linking nodes in both directions. null
indicates the start or end of the list.
Operations in Doubly Linked List
- Insertion: beginning, end, at a given position
- Deletion: beginning, end, at a given position, by value
- Search: by value
- Traversal: iterate forward and backward
- Length: count total nodes
- Reversal: reverse the list
Advantages:
- Can be traversed in both directions (forward and backward)
- Easier to delete a node without needing previous node reference
- More flexible than singly linked list
Disadvantages:
- Uses more memory due to additional prev pointer
- Slightly more complex implementation than singly linked list
Use Cases:
- Implementation of browsers’ forward/backward navigation
- Undo/Redo functionality in applications
- Doubly ended queues (Deque)
5. Circular Linked List:
A Circular Linked List is a variation where the last node points back to the first node instead of null
, forming a circle.
Note: This explanation is for Singly Circular Linked List (SCLL).
Doubly Circular Linked List (DCLL) works similarly but withprev
pointers linking in a circle as well.
Node Structure (Java):
class Node {
int data;
Node next;
Node(int data) {
this.data = data;
this.next = null;
}
}
Explanation:
int data
: Holds the actual data or value stored in the node.Node next
: Reference to the next node in the list.- The constructor sets the initial value and initializes
next
tonull
.- In a circular linked list,
next
will later be updated to point to the appropriate node, forming a loop.
- In a circular linked list,
Example:
A single node looks like this:
Value | Next |
10 | (points to itself) |
- Value holds the data (e.g., 10).
- Next points back to the same node, forming a circular link.
The Singly Circular Linked List looks like this:10 -> 20 -> 30 -> 40 -> 50 -> (back to 10)
- The last node’s
next
points back to the head node, forming a loop.
Operations in Circular Linked List:
- Insertion: beginning, end, at a given position
- Deletion: beginning, end, at a given position, by value
- Search: by value
- Traversal: iterate nodes until back to head
- Length: count total nodes
- Reversal: reverse the list
Advantages:
- Can be traversed from any node since it loops back to the head
- Useful for applications that require circular iteration
Disadvantages:
- Care needed to avoid infinite loops during traversal
- Slightly complex implementation compared to singly linked list
Use Cases:
- Implementing round-robin schedulers
- Multiplayer games for player turns
- Circular buffers and playlists
6. What's next:
I’m excited to keep growing and sharing along the way! Here’s what’s coming up:
- Posting new blog updates every 3 days to share what I’m learning and building.
- Alongside mastering DSA concepts, I’m also documenting my web development journey — check out my ongoing Web dev Journey Blog for ReactJS concepts, UI projects, Codes, and more.
- Sharing regular progress and insights on X (Twitter) — feel free to follow me there and join the conversation!
Thanks for being part of this journey!
7. Conclusion:
In this blog of my dsa journey, I transitioned from mastering Recursion to diving deep into one of the most important linear data structures — Linked Lists.
Over the last 3 days, I explored:
- The fundamentals of Linked Lists and how they differ from arrays
- The various types of linked lists — Singly, Doubly, and Circular
- Node structure and internal working of each type
- Common operations such as insertion, deletion, traversal, and reversal
- Real-world advantages, disadvantages, and use cases
Understanding how Linked Lists work under the hood not only sharpens my problem-solving skills but also lays a strong foundation for mastering more complex data structures like stacks, queues, trees, and graphs.
I’ll continue building on this momentum and explore these advanced structures in the coming days.
If you're on a similar learning path, feel free to follow along or reach out — let’s grow together.
Subscribe to my newsletter
Read articles from Ritik Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Ritik Kumar
Ritik Kumar
👨💻 Aspiring Software Developer | MERN Stack Developer.🚀 Documenting my journey in Full-Stack Development & DSA with Java.📘 Focused on writing clean code, building real-world projects, and continuous learning.