Re: Arranging the keys problem



mihir wrote:
) There are n keys of different 3 colors say white ,red and blue only.Now
) we have to arrange keys such that red keys come before white ones and
) white ones come before blue keys eg RWWBBB where the keys are placed in
) any random order.Give me a linear time algorithm to solve this problem
) ( O(n)).

Quicksort. You may need a slight tweak to make it linear time.


SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
.



Relevant Pages

  • Re: Thin Paint
    ... Now can i ask you something mate? ... have found a good looker but i'm told i need a red and brown key for ... red keys and doesn't know what i'm on about. ... Standard issue is 2 red keys. ...
    (uk.rec.cars.misc)
  • Re: Arranging the keys problem
    ... >) There are n keys of different 3 colors say white,red and blue only.Now ... >) we have to arrange keys such that red keys come before white ones and ... Quicksort is an overkill. ... known as fat pivot partitioning. ...
    (comp.programming)
  • Re: Arranging the keys problem
    ... > There are n keys of different 3 colors say white,red and blue only.Now ... > we have to arrange keys such that red keys come before white ones and ... > any random order.Give me a linear time algorithm to solve this problem ... Since this sounds a lot like a homework problem, ...
    (comp.programming)
  • Re: Arranging the keys problem
    ... >There are n keys of different 3 colors say white,red and blue only.Now ... >we have to arrange keys such that red keys come before white ones and ... >any random order.Give me a linear time algorithm to solve this problem ... IOW provide a stable quicksort. ...
    (comp.programming)
  • Re: Arranging the keys problem
    ... >) we have to arrange keys such that red keys come before white ones and ... You may need a slight tweak to make it linear time. ... Just "sorting by counting". ... so even if given in totally random order ...
    (comp.programming)