Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Loop and Recursive Fibonacci Function: (Java, please show your math !) Write two functions to compute Fibonacci numbers: one using a loop, and the other

Loop and Recursive Fibonacci Function: (Java, please show your math !)

Write two functions to compute Fibonacci numbers: one using a loop, and the other recursive as described in class. The two methods are

public long fibonacci_loop(int f){} public long fibonacci_recursive(int f){}

How much time is required to compute the following Fibonacci numbers using a loop?

n = 10 time required: ___________ n = 50 time required: ___________ n = 90 time required: ___________

How much time is required to compute the following Fibonacci numbers using recursion?

n = 30 time required: ___________ n = 40 time required: ___________ n = 41 time required: ___________ n = 42 time required: ___________ n = 43 time required: ___________ n = 44 time required: ___________ n = 45 time required: ___________ n = 46 time required: ___________ n = 47 time required: ___________ n = 48 time required: ___________ n = 49 time required: ___________ n = 50 time required: ___________ Determine the largest values of n for which the corresponding Fibonacci Numbers can be computed within the given time.

n = _____ time required: less than 10 seconds

n = _____ time required: less than 30 seconds

n = _____ time required: less than 1 minute

n = _____ time required: less than 5 minutes

Estimate the value of n for the largest value of fib(n) that can be computed using recursion in one hour on your computer. Explain in detail how you estimated this value. Also describe any additional data you took to arrive at this value. Attach any additional work required.

n = ______ for time required = 1 hour (3600 seconds)

Repeat this problem for the largest value of n for which the corresponding Fibonacci number can be computed in one day (86,400 seconds).

n = ______ for time required = 1 day (86,400 seconds)

Repeat this problem for the largest value of n for which the corresponding Fibonacci number can be computed in one year.

n = ______ for time required = 1 year.

Repeat this problem for the largest value of n for which the corresponding Fibonacci number can be computed in one million years (106 years).

n = ______ for time required = 1 million years.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Semantics In Databases Second International Workshop Dagstuhl Castle Germany January 2001 Revised Papers Lncs 2582

Authors: Leopoldo Bertossi ,Gyula O.H. Katona ,Klaus-Dieter Schewe ,Bernhard Thalheim

2003rd Edition

3540009574, 978-3540009573

More Books

Students also viewed these Databases questions

Question

Describe Cattells mental testing program and its fate?

Answered: 1 week ago