Given an array consisting of even and odd numbers. Sort the array with even first and then odds. The order of numbers can't be changed?

You can do this in O(n) with a two-pass approach, so long as you're allowed to allocate a separate output buffer. On the first pass, detect and copy all even numbers. On the second pass, detect and copy all odd numbers.

You can certainly do it in O(n) time using O(n) extra memory. You need a stable sort, and in effect you need to do the first step of an MSD radix sort (normally the sign bit is the "most significant" bit, whereas you're interested in even/oddness, but it's same basic deal). A radix sort can be made stable by using a separate buffer to contain either the 1 or 0 values, then combine them.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions