Identify the steps to be taken when a first node is deleted from linked list.
(i) set link of start pointer to be second node in the list
(ii) free the space associated with first node
(iii) obtain the address of the second node in the list.
The steps to be taken when a first node
is deleted from linked list:-
1) Set link of start pointer to be second node in the list.
2) Free the space associated with first node.
Linked list:-
A linked list is a linear data structure where each element is a separate object. Each element of a list is comprising of two items - the data and a reference to the next node. The last node has a reference to null. The entry point into a linked list is called the head of the list.
We explicitly handle the case when node to be deleted is first node, we copy the data of next node to head and delete the next node. The cases when deleted node is not the head node can be handled normally by finding the previous node and changing next of previous node.