Reverse alternate K nodes in a Singly Linked List Given a linked list, write a function to reverse every alternate k nodes (where k is an input to the function) in an efficient way. Give the complexity of your algorithm. Example: Inputs: 1->2->3->4->5->6->7->8->9->NULL and k = 3 Output: 3->2->1->4->5->6->9->8->7->NULL. Method 1 (Process 2k nodes and recursively call for rest of the list) This method is basically an extension of the method discussed in this post. kAltReverse(struct node *head, int k) 1) Reverse first k nodes. 2) In the modified list head points to the kth node.
Read full article from Reverse alternate K nodes in a Singly Linked List | GeeksforGeeks