Q3 for int i0 ii j cout
Q3.
 for (int i=0; i<n; i++)
 for (int j=n; j>=i; j--)
 cout << i << “,” << j <<endl;
Please use the table provided.
Solution
 for (int i=0; i<n; i++)
 for (int j=n; j>=i; j--)
 cout << i << “,” << j <<endl;
Let the cost of each execution of line is 1
LineNo.   Time Taken To Run this Line of Code Once   Total number of times needed to run this code.
 1                                                       1                                   n
 2                                                       1                                   n+(n-1)+(n-2)+……1 = n*(n+1)/2
 3                                                       1                                    n+(n-1)+(n-2)+……1 = n*(n+1)/2
Total Time needed To finish
n*(n+1)/2 = O(n^2) because in asymptotic analysis higher order terms overpower lower order terms for very large value of n

