Write an algorithm to “Insert At Starting Point” in Doubly link list

 

Algorithm:

Insert (node head, value)
1. [Start]
2. Node temp
Temp->data=value
3. [Check condition]
If head=null then
Head=temp
Else
Node ptr=head
Temp->next=ptr
Ptr->pre=temp
Head=temp
[End of if else step (3)]
4. [Return]

Leave a Reply

Your email address will not be published. Required fields are marked *