Splitting array ranges precisely

A merge-sort implementation sorts portions of a sensor-reading array without copying subarrays. Each portion uses a half-open range: it includes the start index and excludes the stop index. A range starting at index ss and stopping at index tt therefore contains t−st-s readings.


For each recursive split, calculate the middle index using


m=⌊s+t2⌋,m=\left\lfloor\frac{s+t}{2}\right\rfloor,


where the brackets mean round downward to an integer. The left child starts at ss and stops at mm; the right child starts at mm and stops at tt.


Complete the table with exact integers. Left length and right length mean the numbers of readings in the two child ranges.

Start indexStop indexMiddle indexLeft lengthRight length
011
1118
1823
2325

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Merge Sort Questions: