Doubly linked list

A complex type of linked list in which a node contains a pointer to the previous as well as the next node in the sequence is called a doubly linked list. The node data, the pointer to the next node in sequence (next pointer), and the pointer to the previous node (previous pointer) are the … Read more

Searching in singly linked list

The process of finding the location of a particular element in a list is called searching. To search an element in a list, we need to traverse through the list. After which, we will make the comparison of every element of the list with the specified element. The location of the element is returned from … Read more

Traversing in singly linked list

The process of visiting each node of the list once to perform some operation on it is called traversing. It is performed in almost every scenario of the singly linked list and is the most common operation, for which we can use the below statements. ptr = head; while (ptr!=NULL) { ptr = ptr -> … Read more

Deletion in singly linked list at the end

If a node is deleted from the end of the linked list, there can be any of the two scenarios: Only one node is there in the list and this node is to be deleted. More than one node is there in the list and we need to delete the last node of the list. … Read more

Deletion in singly linked list after the specified node

Reach the node after which the node should be deleted, by skipping the desired number of nodes, to delete the node, which is present after the specified node. It is necessary to keep track of both the nodes, one which is to be deleted and the one which is present before that node. To serve … Read more

Deletion in singly linked list at the beginning

With a few adjustments in the node pointers, we can delete a node from the beginning of the list. It is thus the most simplistic operation of all. Here, we need to delete the first node of the list. For which, we will use the below statements to make the head point to the next … Read more

Insertion in singly linked list at the end

Two scenarios are mentioned while inserting a node at the last. These are: Inserting a node to an empty list. Inserting a node to the end of a linked list. Inserting a node to an empty list: In this case, the condition (head == NULL) gets satisfied. Thus, only the space for the node needs … Read more

Insertion in singly linked list after specific Node

At first, we need to move the pointer at the position after which the node will be inserted, by skipping the desired number of elements in the list, for inserting an element after the specified number of nodes into the linked list. For this, we can use the below statements. customer=head; for(i=0; inext; if(temp == … Read more

Insertion in the singly linked list at the beginning

We just need to make a few adjustments in the node links to insert a new element into a singly linked list at the beginning. This process involves the below steps: Use the below statements to allocate the space for the new node. It also stores the data into the data part of the node. … Read more

Linked List Data Structure

Linked List A collection of objects called nodes is defined as a Linked List. These nodes are randomly stored in memory. There are two fields present in a node. The first field is the data stored at that particular address and the second field is the pointer containing the address of the next node in … Read more