Question: Consider the following algorithms, where A is an array storing n positive integer values. Algorithm foo(A,n) Input : Array A of size n for k
Consider the following algorithms, where A is an array storing n positive integer values.
Algorithm foo(A,n)
Input: Array A of size n
for k 0 to n 1 do {
if A[k] > 0 then foofoo(A,n)
else A[k] A[k] 1
}
Algorithm foofoo(A,n)
Input: Array A of size n
i 0
while i < n do {
for j 0 to n 1 do {
A[j] A[j] + 1
i i + 1
}
}
What is the worst case time complexity of algorithm foo?
(A) O(n)
(B) O(nk)
(C) O(n2)
(D) O(n2i)
(E) O(n3)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
