Piyush: Your solution takes O(n) extra stack space and is
inadmissible. Kunal's idea of using an insertion/bubble sort mechanism
will work in O(n^2) with O(1) extra memory.
DK
On Jun 7, 10:36 pm, Apoorve Mohan wrote:
> @piyush: at every call to merge u create 3 variables...so u consider this a
@piyush: at every call to merge u create 3 variables...so u consider this an
in-place solution???
On Tue, Jun 7, 2011 at 11:03 PM, Piyush Sinha wrote:
> void merge(int a[], int n, int i)
> {
>
>if(i == 1)
>{
>arr[1] = arr[n];
>arr[2] = arr[n << 1];
>return;
>}
void merge(int a[], int n, int i)
{
if(i == 1)
{
arr[1] = arr[n];
arr[2] = arr[n << 1];
return;
}
int a = arr[i - 1];
int b = arr[n + i - 1];
int c = arr[2*n + i - 1];
merge(arr, n, i - 1);
int x = 3 * (i - 1);
arr[x] = a;
arr[x + 1
@piyush...i think u can use anything..but give a optimal solution
On Jun 5, 9:22 pm, Piyush Sinha wrote:
> Can we use recursion/internal stack memory???
>
> On 6/5/11, hary rathor wrote:
>
> > it it is possible in order of O(n )
>
> > --
> > You received this message because you are subscribed