Question: Consider the following algorithm, which takes as input a sequence of n integers 1111,02,...an and produces as output a matrix M = {mg} where mij

Consider the following algorithm, which takes as input a sequence of n integers 1111,02,...an and produces as output a matrix M = {mg} where mij is the minimum term in the sequence of integers (11', (rt-+1, ..._._a3- for j 2 2'. and mij : 0 otherwise. initialize M so that \"mi-j : e:- if j Z 2'. and mij : 0 otherwise for 2'. :: 1 to n forj:=i.+1ton fork12+1toj mij :: min(mij , ck) return M: {may} {mi-j is the minimum term of (13-, a1- + 1_._ ..., aj} (a) Show that this algorithm uses 0(n3) comparisons to compute the matrix M. (b) Show that this algorithm uses (2013) comparisons to compute the matrix M. Using this fact and part (a): conclude that the algorithms uses @(nS) comparisons. [Hint: Only consider the cases where 1' 3 31/4 and j 2 331/4 in the two outer loops in the algorithm.]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
