Deletion at beginning

Deletion in doubly linked list at the beginning is the simplest operation. We just need to copy the head pointer to pointer ptr and shift the head pointer to its next.

now make the prev of this new head node point to NULL. This will be done by using the following statements.

Now free the pointer ptr by using the free function.

Algorithm

  • STEP 1: IF HEAD = NULL
  • WRITE UNDERFLOW
    GOTO STEP 6

  • STEP 2: SET PTR = HEAD
  • STEP 3: SET HEAD = HEAD → NEXT
  • STEP 4: SET HEAD → PREV = NULL
  • STEP 5: FREE PTR
  • STEP 6: EXIT

Deletion at beginning

C Function

Output

1.Append List
2.Delete node from beginning
3.Exit
4.Enter your choice?1

Enter the item
12

Node Inserted
1.Append List
2.Delete node from beginning
3.Exit
4.Enter your choice?2

Node Deleted
1.Append List
2.Delete node from beginning
3.Exit
4.Enter your choice?





Latest Courses