A very common interview question

let the array be from 0 to 2n-1

now,

every element of array has its initial position and final position.. start
from beginning
if the elemnt you r processing is the first half of array then f=i+i;
else f=2*i-(2n-1);
replace the elemnt at final position with the initial element .. now next
elemnt to process will be oroginal elemnt at final position
if the final position is empty or the same position then process next
element to the initial position.
do until you process the last element.

inplace with O(n).

On Mon, Feb 7, 2011 at 8:32 AM, may.I.answer <may.i.answ...@gmail.com>wrote:

> If  [a1,a2,a3...,an,b1,b2...bn] is given input change this to
> [a1,b1,a2,b2.....an,bn]
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@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.
>
>


-- 
With Regards,
*Jalaj Jaiswal* (+919019947895)
Final Year Undergraduate,
IIIT ALLAHABAD

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@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