The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 2 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Referring to the slides from text book, Chapter 5, there are two versions of Fibonacci numberÂ
calculators: BinaryFib(n) and LinearFibonacci(n). The first algorithm has exponential timeÂ
complexity, while the second one is linear.Â
a) In this programming assignment, you will implement in Java both the versions of FibonacciÂ
calculators and experimentally compare their runtime performances. For that, with eachÂ
implemented version you will calculate Fibonnaci (5), Fibonacci (10), etc. in increments of 5 up toÂ
Fibonacci (100) (or higher value if required for your timing measurement) and measure theÂ
corresponding run times. You need to use Java’s built-in time function for this purpose. You shouldÂ
redirect the output of each program to an out.txt file. You should write about your observations onÂ
timing measurements in a separate text or pdf file. You are required to submit the two fullyÂ
commented Java source files, the compiled executables, and the text/pdf files.Â
b) 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.Â
c) Do any of the previous two algorithms use tail recursion? Why or why not? Explain your answer.Â
If your answer is ``No’’ thenÂ
i. design the pseudo code for a tail recursive version of Fibonacci calculator;Â
ii. implement the corresponding Java program and repeat the same experiments as in part (a)Â
above. You will need to submit both the pseudo code and the Java program, together withÂ
your experimental results.
-----------