Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For each of the following functions, provide the following analysis on the code as provided : i. A recurrence T(n) describing the worst-case running time
For each of the following functions, provide the following analysis on the code as provided : i. A recurrence T(n) describing the worst-case running time of the function (as a function of n). ii. The tightest asymptotic upper and lower bounds you can for T (n). iii. A graph showing running time of the code on a real machine as a function of n , together with your hypothesized bounds. For the purposes of (i) and (ii) above, you should assume that the code is run in a Java environment that supports the RAM model: The machine has infinite memory. Both int and Integer are arbitrarily large. Basic integer arithmetic operations [+, -, *,1, %, casting) require o (1) time. 2a. [5 points] nmn static int probA(int n) { if (n 1l = new LinkedList(); NMONO 11.add(0); while (nn-- !=0) 11.addAll(11); return 11.size(); 2d. [5 points] public int probD(int n) { if (n==0) return 3; int sum=0; for (int jj=1; jj!=n; jj++) { for (int ii=n; ii!=0; ii/2) { sum+=(ii-jj); return probD(n/2) - (sum +prodD(n/2)); 12 } Extra Credit - A (+0.1 points for the tightest bound) covaWNA int probE(int nn) { for (int ii=2; ii 1l = new LinkedList(); NMONO 11.add(0); while (nn-- !=0) 11.addAll(11); return 11.size(); 2d. [5 points] public int probD(int n) { if (n==0) return 3; int sum=0; for (int jj=1; jj!=n; jj++) { for (int ii=n; ii!=0; ii/2) { sum+=(ii-jj); return probD(n/2) - (sum +prodD(n/2)); 12 } Extra Credit - A (+0.1 points for the tightest bound) covaWNA int probE(int nn) { for (int ii=2; ii
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started