Reversal of single linked list

Algorithm for Reversal  node
  • Step 1: First check the head status, if head status is NULL then it is EMPTY LIST, so no need to perform any task.
  • Step 2: Take 3 pointers of type node called prev,current and next and set prev pointer  to NULL,current pointer head.
  • Step 3: Design a loop body and perform following steps
        • Set next value to current to next.
        • Set current to next value to prev.
        • Change prev value to current.
        • Change current value to next.
  • Step 4: Assign head value to prev.
Video For Reversal node


0 comments:

Post a Comment