Write an algorithm to “Delete At specific Location”.

Algorithm:

Delete (node head, loc)
1. [Start]
2. [Check conditions]
If head=null
Show”Operation cannot performed”
Else
Node ptr=head
2.1[Repeat loop]
While (ptr!=null)
Count++
Ptr=ptr->next
[End of loop step (2.1)]
Ptr=head
Node old
2.2[Repeat loop]
While loc>0
Old=ptr
Ptr=ptr->next
Loc–
[End of loop step (2.2)]
Old->next=ptr->next
Delete ptr
[End of if else step (2)]
3. [Return]

Leave a Reply

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