In class, we discussed two versions of Fibonacci number calculations: BinaryFib(n) and LinearFibonacci(n) (refer to your...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
In class, we discussed two versions of Fibonacci number calculations: BinaryFib(n) and LinearFibonacci(n) (refer to your slides and the text book). The first algorithm has exponential time complexity, while the second one is linear. In this programming assignment, you will design in pseudo code and implement in Java two recursive versions (linear and multiple) of Tetranacci calculators and experimentally compare their runtime performances. Tetranacci numbers are a more general version of Fibonacci numbers and start with four predetermined terms, each term afterwards being the sum of the preceding four terms. The first few Tetranacci numbers are: 0, 0, 0, 1, 1, 2, 4, 8, 15, 29, 56, 108, 208, 401, 773, 1490, ... For that, with each implemented version you will calculate Tetranacci(5), Tetranacci(10), etc. in increments of 5 up to Tetranacci (200) (or higher value if required for your timing measurement) and measure the corresponding run times (for instance, Tetranacci(10) returns 56). You can use Java's built-in time function for finding the execution time. You should redirect the output of each program to an TetraOut.txt file. You should write about your observations on timing measurements in a separate text file. You are required to submit the two fully commented Java source files, the compiled executables, and the text files. a) Briefly explain why the first algorithm is of exponential complexity and the second one is linear (more specifically, how the second algorithm resolves some specific bottleneck(s) of the first algorithm). You can write your answer in a separate file and submit it together with the other submissions. b) Do any of the previous two algorithms use tail recursion? Why or why not? Explain your answer. If your answer is "No" then: Can a tail-recursion version of Tetranacci calculator be designed? i. If yes; write the corresponding pseudo code for that tail-recursion algorithm and implement it in Java, and repeat the same experiments as in part (a) above. If no, explain clearly why such tail-recursive algorithm is infeasible. 11. In class, we discussed two versions of Fibonacci number calculations: BinaryFib(n) and LinearFibonacci(n) (refer to your slides and the text book). The first algorithm has exponential time complexity, while the second one is linear. In this programming assignment, you will design in pseudo code and implement in Java two recursive versions (linear and multiple) of Tetranacci calculators and experimentally compare their runtime performances. Tetranacci numbers are a more general version of Fibonacci numbers and start with four predetermined terms, each term afterwards being the sum of the preceding four terms. The first few Tetranacci numbers are: 0, 0, 0, 1, 1, 2, 4, 8, 15, 29, 56, 108, 208, 401, 773, 1490, ... For that, with each implemented version you will calculate Tetranacci(5), Tetranacci(10), etc. in increments of 5 up to Tetranacci (200) (or higher value if required for your timing measurement) and measure the corresponding run times (for instance, Tetranacci(10) returns 56). You can use Java's built-in time function for finding the execution time. You should redirect the output of each program to an TetraOut.txt file. You should write about your observations on timing measurements in a separate text file. You are required to submit the two fully commented Java source files, the compiled executables, and the text files. a) Briefly explain why the first algorithm is of exponential complexity and the second one is linear (more specifically, how the second algorithm resolves some specific bottleneck(s) of the first algorithm). You can write your answer in a separate file and submit it together with the other submissions. b) Do any of the previous two algorithms use tail recursion? Why or why not? Explain your answer. If your answer is "No" then: Can a tail-recursion version of Tetranacci calculator be designed? i. If yes; write the corresponding pseudo code for that tail-recursion algorithm and implement it in Java, and repeat the same experiments as in part (a) above. If no, explain clearly why such tail-recursive algorithm is infeasible. 11.
Expert Answer:
Related Book For
Financial Accounting and Reporting a Global Perspective
ISBN: 978-1408076866
4th edition
Authors: Michel Lebas, Herve Stolowy, Yuan Ding
Posted Date:
Students also viewed these programming questions
-
Midland Energy Resources, Inc" Assignment Questions: How are Mortensen's estimates of Midland's cost of capital used? How, if at all, should these anticipated uses affect the calculations? Calculate...
-
In this programming assignment you will practice using ArrayLists, Inheritance and Polymorphism. You are to write a game called Magical Creatures War. You will do this by implementing a class called...
-
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...
-
In Exercises 3538, evaluate C F dr. F(x, y, z) = xi + yj + zk C: r(t) = 2 cos ti + 2 sin tj + tk, 0t 2
-
A possible means for making an airplane invisible to radar is to coat the plane with an antireflective polymer. If radar waves have a wavelength of 3.00 cm and the index of refraction of the polymer...
-
Sessionville Manufacturing Company plans to introduce a new product known as Quintex. Based on experience and contacts with customers, the vice-president of marketing believes that the demand for...
-
In Exercise 41, an error was made in grading your practical. Instead of getting 90, you scored 100. What is your new weighted mean? Data from Exercises 41 The scores and their percents of the final...
-
The audit of the revenue cycle accounts of Acco, Inc. has been planned with a low preliminary assessment of control risk related to each of the relevant assertions. A sample of sales transactions was...
-
if 2 ^ a = 5 and 2 ^ b = 3 , what is the value of log 3 ( 1 0 )
-
A farm couple are sending their three children to the market to sell 90 apples with the objective of educating them about money and numbers. Karen, the oldest, carries 50 apples; Bill, the middle...
-
IBM, which is considering the development of a quantum computer. Initial costs would be $5 billion and cash flows from year one through year five would be $1.3 billion. Let r = 14%. Four years from...
-
I have to choose a relevant and interesting topic fo rmy literature review in the area of staffing and employment. I have to focus on the specific aspects of each topic and how they relate to...
-
Fergie has the choice between investing in a State of New York bond at 11.2 percent and a Surething Incorporated bond at 14.2 percent. Assuming that both bonds have the same nontax characteristics...
-
Prepare journal entries to record the following production activities. 1. Purchased $40,000 of raw materials on credit. 2. Used $17,000 of direct materials in production. 3. Used $22,000 of indirect...
-
An American firm owes A$1,500,000.00 payable in one year. The current spot it$1.7500/A$. An Australian bank is paying 4.50% on deposits or will lend at 7.50%. A U.S. bank is paying 2.50% or will lend...
-
Surveying leaders on strategic planning has shown respondents indicate- despite effective planning and good implementation the results/benefits of strategic planning it did not meet expectations....
-
What is the premium or discount between the spot rate and the three months forward rate for the Swiss Franc on February 25,2013? What does this imply about the future spot rate for Swiss Franc See...
-
1. As a general strategy, would you recommend that Carl take an aggressive approach to capacity expansion or more of a wait-and-see approach? 2. Should Carl go with the option for one facility that...
-
=> Search the Internet for job offers concerning vacancies for accounting and related personnel (auditor, financial director, management controller, treasurer, etc.). => Using the offers located,...
-
Finland-based UPM products include pulp, paper, plywood, sawn timber, labels and composites, bio energy, bio fuels for transport, bio chemicals and nano products. The company is the worlds leading...
-
(a) To be appropriated in X2 by the General Assembly: management recommends, and the General Assembly approves, that one half of the profit of X1 be distributed. (b) To be received in X2. (c) To be...
-
The hydrodynamic boundary layer equations consist of one momentum equation and the continuity equation. How does one solve for the pressure?
-
In laminar flow, why does the heat transfer coefficient decrease as the boundary layer thickness grows?
-
How does the hydrodynamic boundary layer thickness depend upon the Reynolds number?
Study smarter with the SolutionInn App