A summary of your results; this should include the average number of critical section runs for
each of the different size N arrays you tested, and your analysis as to the algorithm’s performance –
did it work as advertised? Was it better or worse?
The total runtime for the merge procedure, a component of the sort, will be
Tm(n, m, p) = sum[q, i, 0, m/2] + sum[q, i, 0, m/2] + sum[q, i, 0, m/2] (q is the variable of comparison)
Tm(n, m, p) = 3*sum[q, i, 0, m/2]
Tm(n, m, p) = 3*(m/2)*q
Tm(n, m, p) = q = "n"
therefore merge(n, m) ? O(n)
The total runtime of the merge sort will be
Ts(n, m) = Ts(n, m/2) + Ts(n + (m/2), (n - (m/2)) + Tm(n, m, p)
with a base case of
Tsb(n, m) = q where m <= 1.
The base case results in one comparison (quantity of time).
Ts(n, m) = Ts(n, m/4) + Ts(n + (m / 4), (n - (m/4)) + q + Ts(n + (m/2), (n - (m/2))/2) + Ts(
the first part looks like
sum[Ts(n, m*(1/2)^i) + Ts(n + m*(1/2)^i, n - m*(1/2)^i) + q, i, 0, ???]
sum[Ts(n, m) + Ts(n, m) + q, i, 0, ???]
sum[q + q + q, i, 0, ???]
3*???*q
q = "n"
the second like
sum[Ts(
…. Nevermind I fucked up, here's a powerpoint.
http://www.cs.princeton.edu/courses/archive/spr07/cos226/lectures/04MergeQuick.pdfPage 3.
And this
https://en.wikipedia.org/wiki/Master_theorem