views:

25

answers:

0

A[] -> 1 3 5 7 2 4 6 8 //

lb=0,mid-1=3,mid+1=4,ub=7;

a=3,b=7,ab=7;

1st iteration

a=3,b=6,ab=6;


2nd iteration

swap(A[ab],A[a]) // int t; t i'll using for temporary storage

1 3 5 6 2 4 7 8

b=5,ab=5; sort(A,lb,mid-1); // using bubble sort


3rd iteration

swap(A[ab],A[a])

1 3 5 4 2 6 7 8

b=5,ab=4

sort(A,lb,mid-1) // using bubble sort


Is this correct approach for Merge sort using inplace merging. This is my first attempt about inplace merging.If it is not correct approach someone can suggest me.