Re: [algogeeks] Re: To sort an array of 0,1,2

2010-08-23 Thread Manjunath Manohar
is it possible to do without any extra space... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] Re: To sort an array of 0,1,2

2010-08-23 Thread TurksHead Education
I think the first 3 methods of the total 4 specified at http://www.rawkam.com/?p=168 will be applicable for sorting arrays with 0,1 2 On Mon, Aug 23, 2010 at 11:07 AM, Jameel Mohamed jameel.moha...@gmail.comwrote: Use counting sort. time complexity is O(n) On Aug 22, 1:11 pm, AlgoBoy

Re: [algogeeks] Re: To sort an array of 0,1,2

2010-08-23 Thread Kumar Vishal
yes we can a possible solution what i can think is treat 12 (same entity ) and 0 as other so in first pass we will short array which will have (all zeros first , then 12 in some random order ) take index number of zero then in second pass short for 1 2 still O(n) but takes 2 pass On Mon, Aug

Re: [algogeeks] Re: To sort an array of 0,1,2

2010-08-23 Thread Raj N
Refer Dutch National Flag Algorithm On Mon, Aug 23, 2010 at 12:10 PM, Manjunath Manohar manjunath.n...@gmail.com wrote: is it possible to do without any extra space... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

Re: [algogeeks] Re: To sort an array of 0,1,2

2010-08-23 Thread Sathaiah Dontula
Yes, it is possible in one pass without extra memory, I think this is a CLRS exercise problem. It is possible in one pass without using extra memory. Keep the 0's at left and 2's at right and scan the middle portion from left to right and if you see 0 keep at left side and if you see 2 keep it

Re: [algogeeks] Re: To sort an array of 0,1,2

2010-08-23 Thread Manjunath Manohar
@sathiah..i can get u ..but dont seem to understand the part where in we must keep track of the 1's...can u pls post the code.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To

[algogeeks] Re: To sort an array of 0,1,2

2010-08-22 Thread Jameel Mohamed
Use counting sort. time complexity is O(n) On Aug 22, 1:11 pm, AlgoBoy manjunath.n...@gmail.com wrote: An algorithm to sort an array of 0's,1's,2's in a single pass... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,