PratikDey0316
consider Merging these two arrays …
A[] =1,2,7,11,88,100
B[] =8,9,90,91,98,107
here when you are merging A and B in C. array.
c=1,2,7,8,9,11,88,90,91,98 ,100,107….You have to go till end of both array and compare 100,107 ...and put 100 in C first….
Why this happend?
because last element of Array A i.e. 100 is bigger than second last element of array B(i.e. 98) (worst case)
Nowe consider A=1,2,3 B=4,5,6,7,8,9,10
c=1,2,3,4,5,6,7,8,9,10
here how many comparison required? 3 because array A has 3 elements all less than B(best case)
so to merge array of size m and size n
min(m,n)<= no of comparison<=m+n-1