Problem regarding the fibonacci numbers

Assignment Help Basic Computer Science
Reference no: EM131106073

Fibonacci Numbers:

The Fibonacci sequence is given by : 0, 1, 1, 2, 3, 5, 8, 13, 21, ..... By definition the Fibonacci sequence starts at 0 and 1 and each subsequent number is the sum of the previous two. In mathematical terms, the sequence Fn of Fibonacci number is defined by the recurrence relation

Fn = Fn-1 + Fn-2 with F0=0 and F1=1

An algorithm for calculating the nth Fibonacci number can be implemented either recursively or iteratively.

Example Recursive:

fib (n) { if (n = 0) { return 0; } else if (n = 1) { return 1; } else { return fib(n-1) + fib(n-2); } }

Example Iterative:

fib (n) { fib = 0; a = 1; t = 0; for(k = 1 to n) { t = fib + a; a = fib; fib = t; } return fib; }

a) Implement both recursive and iterative algorithms to calculate Fibonacci Numbers in the programming language of your choice. Provide a copy of your code with your HW pdf. We will not be executing the code for this assignment. You are not required to use the flip server for this assignment.

b) Use the system clock to record the running times of each algorithm for n = 5, 10, 15, 20, 30, 50, 100, 1000, 2000, 5000, 10,000, .... You may need to modify the values of n if an algorithm runs too fast or too slow to collect the running time data. If you program in C your algorithm will run faster than if you use python. The goal of this exercise is to collect run time data. You will have to adjust the values of n so that you get times greater than 0.

c) Plot the running time data you collected on graphs with n on the x-axis and time on the y-axis. You may use Excel, Matlab, R or any other software.

d) What type of function (curve) best fits each data set? Again you can use Excel, Matlab, any software or a graphing calculator to calculate the regression curve. Give the equation of the function that best "fits" the data and draw that curve on the data plot. Why is there a difference in running times?

Reference no: EM131106073

Questions Cloud

Waveguide for mono-mode transmission : Design a rectangular air-filled waveguide for mono-mode transmission of the frequency band 3.6GHz~4.6GHz.
System with arrival rate and service rate : Consider the following two queueing systems. System 1: An MM1 system with arrival rate and service rate 3µ
What sources of law would have created : Based on your own experiences, the video, or a news story, relate a time when you believe that the law affected a business. Describe the events, the law, and how the court did or should resolve your example. What sources of law would have created ..
Customers arrive per hour at gotham city bank : On average, 100 customers arrive per hour at Gotham City Bank. It takes a teller an average of two minutes to serve a customer. Interarrival and service times are exponentially distributed.
Problem regarding the fibonacci numbers : The Fibonacci sequence is given by : 0, 1, 1, 2, 3, 5, 8, 13, 21, ..... By definition the Fibonacci sequence starts at 0 and 1 and each subsequent number is the sum of the previous two. In mathematical terms, the sequence Fn of Fibonacci number is..
Hyasaki corporation has the following account balances : 1. At December 31, 2011, Hyasaki Corporation has the following account balances:
Use an m/m/s queueing model : The manager of a bank wants to use an M/M/s queueing model to weigh the costs of extra tellers against the cost of having customers wait in line. The arrival rate is 60 customers per hour, and the average service time is four minutes.
What would the potential consequences be for your decision : Write a minimum of 2 paragraphs explaining whether or not you would return the gun to the defendant. Justify your answer based on sound moral judgment, values, and consequences of actions, using an ethical decision-making process. What would the p..
Benefits associated with microsoft : Cite at least two benefits associated with Microsoft's .NET and Passport services.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd