Ritesh
Ritesh
A Linked List is a linear data structure in which elements, called nodes, are
connected sequentially using pointers. Each node contains two components:
Dynamic Size: The size of a linked list can grow or shrink dynamically
during runtime.
There are mainly three types of linked list , which are given below :-
Defination :-
2.Pointer (Next): A reference to the next node in the sequence. The last node in the
list has its pointer set to null , indicating the end of the list
Characteristics of Singly Linked Lists:
•Dynamic Size: The list size can grow or shrink dynamically as nodes are added or
removed.
•Sequential Access: Traversing the list is done sequentially, starting from the head (the
first node).
•Head Node: The entry point of the list, pointing to the first node.
Operation On Singly Linked List :-
•Insertion: Add a node to the beginning, end, or specific position in the list.
Defination :-
A doubly linked list is a linear data structure consisting of a sequence of nodes, where each
node contains three parts:
2. Pointer to the Next Node: A reference to the next node in the list.
3. Pointer to the Previous Node: A reference to the previous node in the list.
In a doubly linked list, each node is linked to both its predecessor and successor, allowing
traversal in both forward and backward directions.
Characteristics of Doubly Linked Lists:
•Bidirectional Traversal: Nodes can be accessed both forward (next) and backward
(previous).
•Dynamic Size: The size of the list can grow or shrink dynamically as nodes are added
or removed.
•Head and Tail Nodes: The list has a starting node (head) and an ending node (tail).
Operation On Doubly Linked List :-
• Insertion: Nodes can be added at the beginning, end, or any specific position in the list.
• Deletion: Nodes can be removed from the beginning, end, or any specific position.
• Traversal: Nodes can be traversed in both directions (from head to tail or tail to head).
Circular Linked List :-
Defination :-
A circular linked list is a variation of a linked list in which all nodes are connected in
such a way that the last node points back to the first node, forming a circular structure. It
can be implemented as either:
1. Singly Circular Linked List: Each node has a pointer to the next node, and the
last node points back to the first node.
2. Doubly Circular Linked List: Each node has pointers to both the next and the
previous nodes, with the first and last nodes connected in a circular manner.
Characteristics of Circular Linked Lists:
• Cyclic Nature: The last node connects back to the first node, forming a loop.
• Traversal: Traversal can start at any node and continue indefinitely due to the
circular structure.
Operation On Circular Linked List :-
• Insertion: Nodes can be added anywhere in the list (beginning, end, or a specific
position).
•Deletion: Nodes can be removed from the list while maintaining the circular structure.
•Traversal: The list can be traversed continuously until the starting node is encountered
again.
Advantage of linked list:-
•Dynamic Size:
Linked lists can grow or shrink dynamically during runtime by allocating or deallocating
memory. There is no need to specify the size in advance, unlike arrays.
•Memory Utilization:
Unlike arrays, which may reserve unused memory, linked lists use memory only for the
elements currently in the list. Each node is created when needed.
•No Fixed Size:
Arrays require a fixed size declaration at compile time. Linked lists are more flexible
and adapt to the number of elements dynamically.
Linked lists are a versatile and efficient data structure that provide dynamic memory
allocation and ease of modification. Their ability to grow and shrink in size, combined
with efficient insertions and deletions, makes them ideal for applications where
flexibility is key. However, the sequential access and overhead of pointers may make
them less suitable for tasks requiring random access or when memory optimization is
crucial. Despite these trade-offs, linked lists serve as the foundation for many advanced
data structures like stacks, queues, and graphs, highlighting their importance in
computer science and programming.
In summary, linked lists are a powerful tool for managing collections of data,
particularly in scenarios requiring frequent modifications or dynamic sizing.