Algorithm for Delete node
Video for Delete Node
- Step1: First check the head status, if head status is NULL then it is EMPTY LIST, so no need to perform any task.
- Step2: If head status is other then NULL then,
- Get node count value.
- Get node position value to perform delete operation.
- validate node position value, if valid position, then go for further process.
- Step3: If node count value is 1.Then process following steps
- de-allocate memory for head.
- assign NULL value to head
- Step4:If node position is 1,Then processing following steps
- Create a temporary head i.e. th1 and assign current head value to th1.
- Shift the current head to next node i.e. head=head->next;
- Remove next node relation with temporary head i.e. th1->next=NULL.
- de-allocate memory of temporary head. i.e. th1.
- Step5: If node position value is other then 1, Then process following steps
- Take a temporary head i.e. th1 and assign current head value to th1.
- Create a loop and travel up to link position -1.
- Step6:Create another temporary head i.e. th2 and assign previous node next address to th2. i.e. th2=th1->next.
- Assign previous node next value to current node next value i.e. th1->next=th2->next.
- Remove next node relation with temporary head i.e. th2->next=NULL.
- de-allocate memory for temporary head. i.e.th2.
Video for Delete Node
No comments:
Post a Comment