Write an algorithm to Delete At Last Point

Algorithm:

Delete (node head)
1. [Start]
2. [Check for empty]
If head=null then
Show “List is empty”
Else if head->next=null then
Node temp=head
Delete temp
Head=null
Else
Node temp=head

[Repeat loop]
While temp->next<>null
Temp=temp->next
[End of loop]
Node ptr=temp
Ptr=ptr->next
Delete ptr
Temp->next=null
[End of if else step (2)]
3. [Return]

Leave a Reply

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