Question: (a) if n = 10 and input stream is 0 6 9 8 1 3 2 5 4 7 what is the output? (b) the
(a) if n = 10 and input stream is 0 6 9 8 1 3 2 5 4 7 what is the output?
(b) the inner and outer loops are both linearly bounded, and thus the time complexity of the code is O(n^2). But it is not theta(n^2). Use amortization to prove that the time compexity is theta(n)

Coaster the following program, where is a divent a int A[n]: in (n): void get Tercint 1-0 4) cin >> ); R in ; s - whileli [1] /ime loop : >!!eo of outer loop for(int 1-0 1 cout > A[1]: int baino getA ; int 3 - 0 int i = 0; whileli O and B[-1] > A[1]) BC) - A(A): -- // inner loop > // end of outer loop for(int j = 0; j > ); R in ; s - whileli [1] /ime loop : >!!eo of outer loop for(int 1-0 1 cout > A[1]: int baino getA ; int 3 - 0 int i = 0; whileli O and B[-1] > A[1]) BC) - A(A): -- // inner loop > // end of outer loop for(int j = 0; j
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
