No, Jagadish. You missed the statement "Now use any inplace sorting
algorithm" in Anurag's posting, which makes his algorithm also O(n log
n), and both Anurag and you missed the statement "should not do any
pre or post processing."

Dave

On Jun 23, 8:52 am, Jagadish M <jagadis...@gmail.com> wrote:
> >Why not just change the definition of when one number is bigger than another
> >and do normal sort ?
> >I guess that is better and simpler.
>
> Normal sort takes O(n log n), while Anurag's algo is O(n).
>
> Regards,
> Jagadishhttp://www.cse.iitb.ac.in/~jagadish
>
> On Jun 20, 2:18 pm, Rohit Saraf <rohit.kumar.sa...@gmail.com> wrote:
>
>
>
> > Why not just change the definition of when one number is bigger than another
> > and do normal sort ?
> > I guess that is better and simpler.
> > --------------------------------------------------
> > Rohit Saraf
> > Second Year Undergraduate,
> > Dept. of Computer Science and Engineering
> > IIT Bombayhttp://www.cse.iitb.ac.in/~rohitfeb14
>
> > On Sun, Jun 20, 2010 at 7:52 AM, Anurag Sharma 
> > <anuragvic...@gmail.com>wrote:
>
> > > Keep 2 pointers 'start' and 'end' and make them point to start and
> > > beginning of the array.
>
> > > Now keep decresing *end* pointer until an odd element is found
> > > Keep increasing the *start* pointer until an even element is found
> > > swap the elements at start and end
> > > Continue the above 3 steps till start<end
>
> > > Now the start/end points to a border element which divides the array in 2
> > > parts, 1st have having all odd numbers and 2nd half with all even numbers.
>
> > > Now use any inplace sorting algorithm to sort in descending order the
> > > portion containing all odd numbers and in increasing order the portion
> > > containing all  even numbers.
> > > Hope its clear.
>
> > > Anurag Sharma
>
> > > On Sun, Jun 20, 2010 at 2:15 AM, vijay <auvija...@gmail.com> wrote:
>
> > >>  There is an array of odd and even numbers. Now, sort them in such a
> > >> way that the top portion of the array contains odd numbers, bottom
> > >> portion contains even numbers. The odd numbers are to be sorted in
> > >> descending order and the even numbers in ascending order. You are not
> > >> allowed to use any extra array and it has to use a conventional
> > >> sorting mechanism and should not do any pre or post processing
>
> > >> --
> > >> 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
> > >> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups
> > >>  .com>
> > >> .
> > >> 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 algoge...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups
> > >  .com>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text -
>
> - Show quoted text -

-- 
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 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to