4. Consider the two functions below which both compute the value of f(n). The function fi...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
4. Consider the two functions below which both compute the value of f(n). The function fi was replaced with f2 because integer multiplications (*) were found to take 4 times longer than integer additions (+). int fi(n: integer) if (n == 1) then return(1) else return(2 fi(n-1)); int f2(n: integer) if (n == 1) then return(1) else return(f2(n-1) + f2(n-1)); i. Give a recurrence relation for f₁ which satisfies the number of multiplications (*) executed as a function of n. ii. Solve the recurrence relation from Part i. iii. Give a recurrence relation for f2 which satisfies the number of additions (+) executed as a function of n. iv. Solve the recurrence relation from Part iii. v. Both functions compute the same function f. Was it a good idea to replace fi with f2? 4. Consider the two functions below which both compute the value of f(n). The function fi was replaced with f2 because integer multiplications (*) were found to take 4 times longer than integer additions (+). int fi(n: integer) if (n == 1) then return(1) else return(2 fi(n-1)); int f2(n: integer) if (n == 1) then return(1) else return(f2(n-1) + f2(n-1)); i. Give a recurrence relation for f₁ which satisfies the number of multiplications (*) executed as a function of n. ii. Solve the recurrence relation from Part i. iii. Give a recurrence relation for f2 which satisfies the number of additions (+) executed as a function of n. iv. Solve the recurrence relation from Part iii. v. Both functions compute the same function f. Was it a good idea to replace fi with f2?
Expert Answer:
Answer rating: 100% (QA)
i Recurrence Relation for f which satisfies the number of multiplications T Tn 1 1 ... View the full answer
Related Book For
Managing Business Ethics Making Ethical Decisions
ISBN: 9781506388595
1st Edition
Authors: Alfred A. Marcus, Timothy J. Hargrave
Posted Date:
Students also viewed these programming questions
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
1- What signal is produced if the sampling frequency is equal to Fm? 2- Find the range of the cutoff frequency funt for LPF required to reconstruct the original signal from the sampled one. 3- If the...
-
1. Ernie and Bert agree to form a partnership. Because the two are great friends, no written partnership agreement is made. Ernie agrees to contribute $100,000 in assets and to devote half of his...
-
How is the process of financial planning used to estimate asset investment requirements?
-
The probability that a turbine will have a defective coil is 0.10, the probability that it will have defective blades is 0.15, and the probability that it will have both defects is 0.04. (a) What is...
-
Walden Green provides custom farming services to owners of 5-acre wheat fields. In July, he earned $2,400 by cutting, turning, and balling 3,000 bales. In the same month, the incurred the following...
-
Image transcription text Problem 1: Consider the figure below. A block of weight "W? slides on a horizontal surface with a coefficient of Coulomb friction =f". It is attached on its left face to a...
-
Fill in the missing reagents below. Me OEt ?| Br Me SH OEt OMe OEt CN
-
Each response should be between 500 and 1000 words in length. These responses will be graded on clarity of argumentation (yes, these responses should be argumentative!) as well as your usage of the...
-
A tractor with a front-end loader and a backhoe costs \($20,000\) and is rented by the hour, day, or week. It is expected to depreciate to \($2,000\) when it has been rented out until the total...
-
Consider this model in which national income Y depends on the previous periods income and the current and previous periods money supply M: where the parameters , 1 , 2 , and 3 are positive. a. If...
-
Should NASA expand the space shuttle program from four launches per year to five?
-
In a new highly automated factory, labor costs are expected to decrease at an annual rate of 5 percent; material costs will increase at an annual rate of 4 percent; overhead costs will increase at 8...
-
In 500 words or less, use cost-benefit analysis to explain some pattern of events or behavior you have observed in your own environment.
-
If the real exchange rates between the USD and CAD, AUD, and BRL respectively are 1.20, 0.90, and 1.40 respectively with the percentage of trade between the US and Canada, US and Australia, and US...
-
Suppose the spot and six-month forward rates on the Norwegian krone are Kr 5.78 and Kr 5.86, respectively. The annual risk-free rate in the United States is 3.8 percent, and the annual risk-free rate...
-
1. What are the benefits and costs of using a common currency for Greece, Germany, and the EU? 2. How do the austerity programs imposed by the bailouts help a Greek firm that exports olive oil? 3....
-
You run a die casting facility that produces metal tools used in industry. (Dies are essentially molds that are filled with superhot molten metal to make metal products.) Competition is fierce in...
-
The High Value (HV) chain of discount appliance stores, started in 1988 with the merger of three smaller chains, achieved sales in excess of $28 billion under the respected leadership of its CEO,...
-
A large building has a roof with dimensions $50 \mathrm{ft} \times 200 \mathrm{ft}$, which drains into a gutter system. The gutter contains three drawn aluminum downspouts that have a square cross...
-
A drainage canal is to be dug to keep a low-lying area from flooding during heavy rains. The canal would carry the water to a river that is 1 mile away and $6 \mathrm{ft}$ lower in elevation. The...
-
Oil with a viscosity of $25 \mathrm{cP}$ and $\mathrm{SG}$ of 0.78 is stored in a large open tank. A vertical tube made of stainless steel with an ID of $1 \mathrm{in}$. and a length of $6...
Study smarter with the SolutionInn App