I hope merge sort is not an inplace sorting.. It'll take extra space (in
function merge) and since it uses recursion it'll also take stack space..
I think this sol will work.
1. partition the array by holding the even elements on first space(n/2 or
n/2-1 depends on odd sized and even sized array) of array and odd elements
in last n/2 space of array.
2. Do heapsort by using both min heap and maxheap by having 0 and (sizeof
even elements) as root of heap.
3. Heap don't use extra space and time complexity is O(nlgn).
Cheers
~ Jeeva ~
--
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.