Linked List - Kthreverse

how to do k reverse?
suppose i have three references

  1. Current
    2)next
    3)Previous
    so how to change the references bw them and I am considering the current pointer as the head of LL so please can you help with this

@Chitwan,

  • Reverse the first sub-list of size k. While reversing keep track of the next node and previous node. Let the pointer to the next node be next and pointer to the previous node be prev .
  • head->next = reverse(next, k) ( Recursively call for rest of the list and link the two sub-lists )
  • Return prev ( prev becomes the new head of the list )

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.