Question: For the following algorithm express the following: (a) Express the running time of Incognito( A ) as an explicit sum of the worst-case running times
For the following algorithm express the following:
(a) Express the running time of Incognito( A ) as an explicit sum of the worst-case running times of each of the 11 steps.
(b) Find an explicit formula for the expression in part (a).
Let A be a two-dimensional array with n rows and n columns of numbers and
Incognito be an algorithm that outputs a certain number y defined as follows.
Incognito( A )
//input: a two-dimensional array A with n rows and n columns
// Output: a number
// Index of the array starts in [0][0]
1. n = A.rows()
2. y = 1
3. i = 0
4. while i < n do
5. x = A[i][0]
6. for j = 1 to n - 1 do
7. if A[i][j] > x
8. x = A[i][j]
9. y = y * x
10. i = i +1
11. return y
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
