Write an algorithm to Delete At Mid Point.

Algorithm:

Delete (node head)
1. [Start]
2. [Check condition]
If head=null OR head->next=null then
Show “cannot be inserted.”
Else
Node ptr=head
2.1 [Repeat loop]
While( ptr!=null)
Count++
Ptr=ptr->next
[End of loop step (2.1)]
Mid=count/2
Ptr=head
Node old
2.2[Repeat loop]
While mid>0
Old=ptr
Ptr=ptr->next
Mid–
[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 *