I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone. Bjarne Stroustrup

Pairwise swap elements

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


Data structure Description

Write a program to pairwise swap the elements in the singly linked list. The singly linked list contain the data and link to next node in each node. Iterate each node from linked list and swap the nodes pairwise. Example 1->2->3-4>5 and result should be 2->1->3-4>5.


Output

   					 

Print the list of items: 21->52->33->21->67->NULL
Print the list of items after pairwise Swap: 52->21->21->33->67->NULL

				    

Comments


No comments available!

Please login to add comments.