Concept of Linked List
● A linked list is a fundamental data structure in computer science. It mainly
allows efficient insertion and deletion operations compared to arrays.
● A linked list is a linear data structure which can store a collection of "nodes"
connected together via links i.e. pointers.
● A linked list is a dynamic linear data structure whose memory size can be
allocated or de-allocated at run time based on the operation insertion or
deletion, this helps in using system memory efficiently.
● A linked list starts with a head node which points to the first node. Every
node consists of data which holds the actual data (value) associated with
the node and a next pointer which holds the memory address of the next
node in the linked list. The last node is called the tail node in the list
which points to null indicating the end of the list.
Types of Linked List
Singly Linked Lists
Singly linked lists contain two "buckets" in one node; one bucket holds the data
and the other bucket holds the address of the next node of the list. Traversals
can be done in one direction only as there is only a single link between two
nodes of the same list.
Doubly Linked Lists
Doubly Linked Lists contain three "buckets" in one node; one bucket holds the
data and the other buckets hold the addresses of the previous and next nodes
in the list. The list is traversed twice as the nodes in the list are connected to
each other from both sides.
, Circular Linked Lists
Circular linked lists can exist in both singly linked list and doubly linked list.
Since the last node and the first node of the circular linked list are connected,
the traversal in this linked list will go on forever until it is broken.
Basic Operations in Linked List
The basic operations in the linked lists are insertion, deletion, searching, display,
and deleting an element at a given key.
● Insertion − Adds an element at the beginning of the list.
● Deletion − Deletes an element at the beginning of the list.
● Display − Displays the complete list.
● Search − Searches an element using the given key.
● Delete − Deletes an element using the given key.
Linked List - Insertion Operation
Adding a new node in linked list is a more than one step activity. We shall learn
this with diagrams here. First, create a node using the same structure and find
the location where it has to be inserted.
● A linked list is a fundamental data structure in computer science. It mainly
allows efficient insertion and deletion operations compared to arrays.
● A linked list is a linear data structure which can store a collection of "nodes"
connected together via links i.e. pointers.
● A linked list is a dynamic linear data structure whose memory size can be
allocated or de-allocated at run time based on the operation insertion or
deletion, this helps in using system memory efficiently.
● A linked list starts with a head node which points to the first node. Every
node consists of data which holds the actual data (value) associated with
the node and a next pointer which holds the memory address of the next
node in the linked list. The last node is called the tail node in the list
which points to null indicating the end of the list.
Types of Linked List
Singly Linked Lists
Singly linked lists contain two "buckets" in one node; one bucket holds the data
and the other bucket holds the address of the next node of the list. Traversals
can be done in one direction only as there is only a single link between two
nodes of the same list.
Doubly Linked Lists
Doubly Linked Lists contain three "buckets" in one node; one bucket holds the
data and the other buckets hold the addresses of the previous and next nodes
in the list. The list is traversed twice as the nodes in the list are connected to
each other from both sides.
, Circular Linked Lists
Circular linked lists can exist in both singly linked list and doubly linked list.
Since the last node and the first node of the circular linked list are connected,
the traversal in this linked list will go on forever until it is broken.
Basic Operations in Linked List
The basic operations in the linked lists are insertion, deletion, searching, display,
and deleting an element at a given key.
● Insertion − Adds an element at the beginning of the list.
● Deletion − Deletes an element at the beginning of the list.
● Display − Displays the complete list.
● Search − Searches an element using the given key.
● Delete − Deletes an element using the given key.
Linked List - Insertion Operation
Adding a new node in linked list is a more than one step activity. We shall learn
this with diagrams here. First, create a node using the same structure and find
the location where it has to be inserted.