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

  Instruction sequence to output the value

Write an instruction sequence to output the value $35 to Port P.

  There are four conditions that are necessary

There are four conditions that are necessary for a deadlock to occur. Give an example to show that these conditions are not sufficient for a resource deadlock to occur. When are these conditions sufficient for a resource deadlock to occur? Explain..

  Define relevant systems analysis and design

Relevant systems analysis and design. Scholarly research should exist performed within the last few years that develop timely and appropriate procedures for an information systems analysis and design.

  Hardware r us" it consulting and managing firm

A star consultant from "Hardware R US" IT consulting and managing firm. Just graduated from APUS and this is your first critical job.

  Long-term average highway mileage

Larry wonders whether the data show that his true long-term average highway mileage is less than 51 mpg. What are his null and alternative hypotheses?

  Conflict-management techniques

Conflict-management techniques allow leaders to control conflict levels (not only decrease them, but also increase them). Select a problem that disturbs you and is not solved. The problem can address any environment-your workplace, your community, ..

  File format would you choose

What file format would you choose for the following tasks: 1. A cartoon strip 2. A 3D model for use on a multimedia presentation on the web

  Write a select statement that returns four columns

Write a Select statement that returns four columns from the Invoices table, named Number, Total, Credits, and Balance

  What belief system or systems do the staff adhere to

What belief system or systems do the staff adhere to. What are some beliefs that can be improved on or changed to create a better work experience, while maintaining quality in services delivered

  Management information systems

Discuss the pros and cons of selecting (outsourcing to) three different vendors to handle three different IT/IS activities.

  Carrying out a big data readiness assessment

The theme of the assignment is the reliability (or unreliability) of Assisted GPS Location Services in smart devices (Smart Phones, Tablets, Smart Cameras, etc.). John Easton (of IBM) stated in 2012 that 80% of all Big Data and data from the Inter..

  The quality of the discussion by making frequent

Discussion responses should be on topic, original, and contribute to the quality of the Discussion by making frequent, informed references to lesson materials and Seminars. Initial Discussion responses should be around 150 words. Responses to your cl..

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