Question: Consider the following algorithm: % PRE: A is an nxn array, zero-indexed. sum = 0 for y = O to n-1 for X =
Consider the following algorithm: % PRE: A is an nxn array, zero-indexed. sum = 0 for y = O to n-1 for X = end end y to n-1 sum = sum + A [y,x] % POST: sum contains the sum of the elements on or above % the main diagonal. Assuming each sum assignment takes time C, and each loop assignment takes time D, write down a summation expression for the total time requirement of the algorithm and evaluate to an algebraic expression, then simplify to a polynomial with variable n.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
