Write an algorithm of “Insert At Last Point” using 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 if head->next=null then
Head->next=temp
Temp->pre=head
Else
Node ptr=head
3.1[Repeat loop]
While ptr<>null
Ptr=ptr->next
[End of loop step (3.1)]
Ptr->next =temp
Temp->pre=ptr
[End of if else step (3)]
4. [Return]

Leave a Reply

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