one = zero = 0;
two = n-1; //n is length of string

while(two>=one)
{
      switch(a[one])


On Mon, Oct 24, 2011 at 9:50 PM, praveen raj <[email protected]> wrote:

> This can be done in O(n)..
>
> first shift all the 2's to the right side in O(n)...
>
> then again shift 1to the right shift b efore 2's......... in O(n)...
>
>
> With regards,
>
> Praveen Raj
> DCE-IT 3rd yr
> 9999735993
> [email protected]
>
>
>
>
> On Mon, Sep 26, 2011 at 6:23 PM, Naren s <[email protected]> wrote:
>
>> dutch national flag problem..search in wiki...classical.
>>
>> On Sat, Sep 24, 2011 at 9:39 AM, VIHARRI <[email protected]> wrote:
>>
>>> You are given a string (consisting of 0's, 1's or 2's) where 0
>>> represents a blue ball, 1 a
>>> red ball, and 2 a black ball. Using only swap operations (counting
>>> sort not allowed)
>>> rearrange the string such that all blue balls are together on one
>>> side, followed by all red
>>> balls, and then all black balls. You can iterate through the string
>>> only once.
>>> Eg 102112011 should produce 001111122
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>
>>
>> --
>> *Narayanan S,*
>> B.E., C.S.E., (final year),
>> College Of Engineering Guindy,
>> Anna University,
>> Chennai-25.
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
*UTKARSH SRIVASTAV
CSE-3
B-Tech 3rd Year
@MNNIT ALLAHABAD*

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to