PPT Slide
How big can array c get? Let b[h..k] have n values, and let b be already sorted. At each step, b[f..j-1] would be empty and b[j+1..k]would have all but one of the elements. After 3 loop iterations, we would have
c[0] represents a segment of 0 elements
c[1] represents a segment of 0 elements
c[2] represents a segment of 0 elements
c[3] represents a segment of n-3 elements
In worst case array c needs almost n array elements!
Put largest of the two segments b[f..j-1], b[j+1..k] on c first, then the smaller. Then, we can show that that if c[0] represents a segment of m elements, c looks like
c[0] represents m elements
c[1] represents < m/2 elements
c[2] represents < m/4 elements
c[3] represents < m/8 elements
c[i-1] represents m/ 2 i-1 elements
c has at most 1+ log m elements
So c has at most 1 + log n elements. Much better!