Computer Science, asked by hrasool5555, 6 months ago

1. Describe the worst case running time(O(T(n))) of the following pseudo code
functions.
I. void MyFunction(int n) {
for (int i = 0; i<n; +1)
{
for (intj=0;j<i; Hj) {cout<<(j=”+j);}
for (int k =0; k<n* 3; Hk) {cout<<(k=”+ k);}
}
I }

Answers

Answered by vshrivastava103
0

Answer:

look dear,

the outer for loop will run in O(N)

and since u r talking about worst case

we will take maximum value of i i.e. N

so it's Time will Also be = N

same with another inner loop

so total time will be as follows = N*(N+3N)

which is similar to N^2

therefore, total time will be = O(N^2)

please give me a brainliest

Similar questions