How does a project get to be a year late?... One day at a time. Fred Brooks

Sort a linked list of 0s, 1s and 2s

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


Data structure Description

The linked list contain only 0, 1 and 2 values. Each node link with sequence node. Write program to sort 0s, 1s and s2 item from linked list. Singly linked list contain the data (0, 1 or 2) and link to the next node and able to iterate only forward.


Output

   					 

Print the list of items: 1->0->2->2->1->0->1->2->NULL
Print the list of items after sort '0', '1' and '2' elements: 0->0->1->1->1->2->2->2->NULL

				    

Comments


No comments available!

Please login to add comments.