sorting list containing only 0's,1's,2's in order of 'n'help

A forum for general discussion of the Python programming language.

sorting list containing only 0's,1's,2's in order of 'n'help

Postby VenugopalaRao » Sat May 25, 2013 5:30 am

i have tried much to sort the list containing only 0's ,1's,2's
i sorted them using bubble sort,selection sort,insertion sort they all are of order 'n^2'
i sorted it with counting sort too, which produces the result in order of 'n' but counting sort is not allowed
i need to sort it in order of 'n' without using counting sort .
unable to do it can anyone help?
VenugopalaRao
 
Posts: 16
Joined: Wed May 15, 2013 5:05 pm

Re: sorting list containing only 0's,1's,2's in order of 'n'

Postby setrofim » Sat May 25, 2013 6:51 am

Go through the list swapping values to accumulate 0's at the beginning of the list and 2's at the end of the list.
setrofim
 
Posts: 288
Joined: Mon Mar 04, 2013 7:52 pm


Return to General Discussions

Who is online

Users browsing this forum: Bing [Bot], Google Feedfetcher, snippsat and 4 guests