2. [10 points] Analyze the running time of the following two pieces of code. Give the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
2. [10 points] Analyze the running time of the following two pieces of code. Give the best upper bounds for these. FA(A[1...n]) { // array of size n res = 0; i = 1; while (i < n) (1 if (A[i] < 0) return 0; for(j 0; j<n; j+-2); res += A[j]; i= i. 2; } return res; FB (A[1...n] { // array of size n res = 0; for (i = 0; i < n/2; i++) { res += A[i] * 2; } for (j-n; j > 0; j--) { res += FA (j); return res; 2. [10 points] Analyze the running time of the following two pieces of code. Give the best upper bounds for these. FA(A[1...n]) { // array of size n res = 0; i = 1; while (i < n) (1 if (A[i] < 0) return 0; for(j 0; j<n; j+-2); res += A[j]; i= i. 2; } return res; FB (A[1...n] { // array of size n res = 0; for (i = 0; i < n/2; i++) { res += A[i] * 2; } for (j-n; j > 0; j--) { res += FA (j); return res;
Expert Answer:
Related Book For
Computer Architecture A Quantitative Approach
ISBN: 978-0123704900
4th edition
Authors: John L. Hennessy, David A. Patterson
Posted Date:
Students also viewed these programming questions
-
1 . ) What energy neutron has an associated wavelength of order the radius of a nucleus? 2 . ) Describe the position and momentum uncertainties for a harmonic matter - wave.
-
Walker is 20 years old and single, lives in a rental house, and has no children. Last year, he earned 53,000 in his internship for KPMB. His wages withheld for federal income where $6,700. In...
-
7) A blob of clay of mass M is propelled upward from a spring that is initially compressed by an amount d. The spring constant is k. What is the ultimate height h above the unstretched spring's end...
-
Repeat Prob. 37 using singularity functions exclusively (including reactions). Repeat Prob. 37, For the beam shown, find the reactions at the supports and plot the shear-force and bending-moment...
-
For the steel rod of Prob. 5.57, at what airstreams velocity U will the rod begin to vibrate laterally in resonance in its first mode (a half sine wave)? (Hint: Consult a vibration text under lateral...
-
The accompanying table shows annual stock prices on the Sulaco Stock Exchange in the republic of Costaguana for 2008-2013. Construct two stock market indexes, one using weights as in the Dow Jones...
-
A spindle is used on (a) machine tools (b) I.C. engines (c) cranes (d) automobiles
-
Ware Co. produces and sells motorcycle parts. On the first day of its fiscal year, Ware Co. issued $35,000,000 of five-year, 12% bonds at a market (effective) interest rate of 10%, with interest...
-
Discuss the cultural differences between China and the United States. What would be the biggest adjustments I might need to make if working there as an expatriate? What are the most...
-
Tony and Suzie see the need for a rugged all-terrain vehicle to transport participants and supplies. They decide to purchase a used Suburban on July 1, 2022, for $12,000. They expect to use the...
-
What long range (5 yrs) potential impacts of the trade war (between China and US) have on the real estate industry? Explain Briefly?
-
Tammy charged 30,000 on her credit card. If she pays 600 each month and credit card charges 23 percent apr. how long will it to take to pay it off? How much interest will it she pay if making 600...
-
What work needs to be done on an automobile of mass 1 2 0 0 kg to increase its speed from rest to 2 5 m / s ? Express your answer in J.
-
Daniel and Ashlee are long-term clients of yours, and are getting a divorce. Because of the divorce, their interests will no longer be the same and they are not amicable. Ashlee has said that's he...
-
Compute and show the rate of return on common equity (ROCE) and Be sure to show your computations. If needed, you can assume a marginal income tax rate of 35%.
-
Complete the table by: i. Defining each type of taxable transaction data provided below. ii. Listing one unique source of information for each type of taxable transaction data listed below. iii....
-
James returned two weeks after surgery, as planned, for a change in his drug delivery system. Today Dr. Harvey opened the previous incision site. The previously placed reservoir was removed and a new...
-
Name some of the various types of financial intermediaries described in the chapter and indicate the primary reason(s) each was created.
-
In a server farm such as that used by Amazon or the Gap, a single failure does not cause the whole system to crash. Instead, it will reduce the number of requests that can be satisfied at any one...
-
The switched snooping protocol of Figure 4.40 assumes that memory "knows" whether a processor node is in state Modified and thus will respond with data. Real systems implement this in one of two...
-
Reorder the instructions to improve performance of the code in Figure 2.35. Assume the two-pipe machine in Exercise 2.3, and that the out-of-order completion issues of Exercise 2.4 have been dealt...
-
What is the value of Queens Park PLCs preferred stock when the dividend rate is 10 percent on a $100 par value? The appropriate discount rate for a stock of this risk level is 16 percent.
-
Midwest Energy Group has issued preferred stocks ($10 par value) that pay 8 percent dividend annually. If the required rate of return is 15 percent, what is the value of the stock?
-
Calculate the value of Swatchs preferred stock that pays a dividend of $8 per share if your required rate of return is 14 percent.
Study smarter with the SolutionInn App