Give the following program void main0 int i j k n z double x

Give the following program: void main0 {int i, j, k, n, z; double x=0, y=0; cin >> n;//get value from user for(i=1;i

Solution

Option c;

Outer for loop with iterates n times. so O(n);

Inside we have 2 for loops,

1 will ityerates 1 to i times and second from i to n times.

We will add time complexities of 2 adjacent for loops. so O(i)+O(n-i)=> O(n+1). Removing constant it will be O(n);

So by time complexity rules we will multiply time comeplexities of nested for loop. so, O(n)*O(n)=>O(n2).

 Give the following program: void main0 {int i, j, k, n, z; double x=0, y=0; cin >> n;//get value from user for(i=1;iSolutionOption c; Outer for loop with

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site