sort an array such that one half of the array has even numbers in ascending order and the other half

Posted by nd81 on Stack Overflow See other posts from Stack Overflow or by nd81
Published on 2010-05-31T16:30:33Z Indexed on 2010/05/31 16:42 UTC
Read the original article Hit count: 150

Filed under:
|

Design an algorithm with min time and space

here is my solution -

  1. assume a array of N elements with 32 bit integers
  2. use a bit array to set the appropriate bits
  3. the array is sorted now
  4. assign even numbers to the first half of the array in ascending order
  5. assign odd numbers to the second half of the array in descending order

any better solution ?

© Stack Overflow or respective owner

Related posts about homework

Related posts about sorting