There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code. Flon's Law

Reverse alternate K nodes

Language Java | Level Intermediate | Category Data structure | September 5, 2015 11:59 pm


Data structure Description

The singly linked list contains the sequence of nodes which each node contains data and link to the next node. Write a program to reverse the singly linked list with K nodes. The utility function takes the head node and K value (number of position to reverse the node) and return the head node of reversed list.


Output

   					 

Print the first list items: 21->52->33->67->NULL
After swap 2 items in the linked list: 52->21->67->33->NULL

				    

Comments


No comments available!

Please login to add comments.