@Navin: Try this with {1,-1,2}. current points to the 1 and end points to
the 2. Since 1 is positive, the algorithm swaps the 1 and the 2, giving
{2,-1,1}. Then it decrements current to point outside the array and end to
point to the -1. How can this be right?
Dave
On Thursday, June 28, 2012 9:59:26 AM UTC-5, Navin Gupta wrote:
> Keep two pointers - one at start of the array and other at end of the
> array
> Now current points to start of the array
> If current is negative , increment current
> If current is positive , swap it with the element at end and decrement
> current and end both
> If current >= end , then break.
>
> Navin Kumar Gupta
> Final Year, B.Tech (Hons.)
> Computer Science & Engg.
> National Institute of Technology,Jamshedpur
> Mobile - 8285303045
>
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/JW4NPf7xBTkJ.
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.