an ineffcient O(nlgn) solution is possible with sorting where the comparision function is
a[i] < a[j] where i < j
b[i] < b[j] where i < j
and  a[n] < b[1]

im sure theres a O(n) solution, but cudnt think of it right-away
continously swaping(i.e start with b1 , put in the desired place X, put element on X(before replacing with b1) at desired place and so on) doesnt seem too work though, does it?

On 11/13/06, nike <[EMAIL PROTECTED]> wrote:

Given an array a1b1a2b2a3b3.... , arrange it such that it becomes
a1a2a3...b1b2b3...

Its size can be odd or even. [ array can be a1b1a2 , a1b1a2b2. ]

If we use an additional array to store the result, the problem becomes
trivial.

But, with out using an additional array, how will you re-arrange the
given array in place?

Any help, welcome.

Thanks in advance,
Arun.



--~--~---------~--~----~------------~-------~--~----~
 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 [EMAIL PROTECTED]
For more options, visit this group at http://groups-beta.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to