Question: Algorithm 1 evaluate(A,i,j) 1: total0 2: for k - i,...,j do 3: total+ total +A[k] 4: return total Algorithm 2 subsequence WithMax Sum_ICA) 1: n
Algorithm 1 evaluate(A,i,j) 1: total0 2: for k - i,...,j do 3: total+ total +A[k] 4: return total Algorithm 2 subsequence WithMax Sum_ICA) 1: n Size of A 2: answer (0,0) 3: for i=0, . . . ,n-1 do 4: for j-i,...,n 1 do if evaluate(A.ij)> evaluate(A answer(0].answer[I) then 6: answer (i, j) 7: return answer [1 mark] Using big-O notation, what is the time complexity of the function evaluate in terms of the length of A? Justify your answer from the pseudocode. (a) (b) [1 mark] Using big-O notation, what is the time complexity of the function subsequence WithMaxSum_I in terms of the length of A? Justify your angwer from the pseudocode
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
