Find median of two sorted arrays, with complexity of min(log(m),log(n))
Consistent whitespace


    cout &lt;&lt; "\nthe median of the merged array is : " &lt;&lt; findMedian(a, b,  m,  n)&lt;&lt; '\n';



isn't even consistent within the same line about whether &lt;&lt; should have spaces on both sides or not. I'm surprised your editor didn't auto-format it.

There is also a wide variety of whitespace in the strings which are used to prompt for input.

Also in this category,


                return min(max_of_left,min_of_right);



appears to be indented too far. Well, either that or there are some missing {} to include it with the previous statement in a single block.



Memory management


void main()
{
    ...
    a = new int[m];
    ...
    b = new int[n];
    ...
    free(b);
    free(a);
}



Are you sure? This looks fishy to me. There's no call to malloc or friends, so why is there a call to free?.



Warning

Let's simplify the code a bit...


int findMedian(int a[], int b[], int m, int n)
{
    int imin = 0, imax = m, half_len = (m + n + 1) / 2;
    int i, j, max_of_left, min_of_right;

    while (imin &lt;= imax)
    {
        ...
    }
}



Now can you see why "not all control paths return a value"?

Hint: what's the loop invariant?



Performance claims

The title of this question is "Find median of two sorted arrays, with complexity of min(log(m),log(n))". That's impossible: if I guarantee that the second array is of length at most 1, you're promising to find the median of the other array with complexity bounded above by 0.

I think you can claim \$\log(m+n)\$, but some comments to justify correctness and performance would be nice.