Consider the following algorithm, which takes as input a sequence of n integers a1, a2, …, an and produces as output a matrix M = {mij} where mij is the minimum term in the sequence of integers ai, ai+1, …, ai for j ≥ i and mij = 0 otherwise.

initialize M so that mij = a, if j ≥ i and mij = 0 otherwise

for i := 1 to n

for j := i + 1 to n

for k := i + 1 to j

mij := min(mij, ak)

return M = {mij}{mij is the minimum term of ai, ai+1, …, aj}

a) Show that this algorithm uses O(n3) comparisons to compute the matrix M.

b) Show that this algorithm uses Ω(n3) comparisons to compute the matrix M. Using this fact and part (a), conclude that the algorithms uses ⊝(n3) comparisons. [Hint: Only consider the cases where i ≤ n/4 and j ≥ 3n/4 in the two outer loops in the algorithm.]

Step 1</p>

In this problem we need to show that the given algorithm uses comparisons to compute the matrix M.