Docsity

CS2402 Lab 1: Computing Fibonacci Numbers and Optimization - Prof. Olac Fuentes, Lab Reports of Data Structures and Algorithms

Toggle sidebar
bg1
CS2402
Spring 2009
Lab 1
Due Friday, January 30, 2009
1. Fibonacci numbers and complexity
Fibonacci numbers are defined recursively as follows:
F(n) = n, for n<=1
F(n) = F(n-1) + F(n-2) for n>1
Your assignment consists of writing the following methods to compute F(n):
a) A O(2n) method based on the recursive definition
b) A O(n) method that uses a loop
c) A O(1) method that uses the closed form solution
Conduct experiments to compare the running times of your methods and verify that they
behave as expected.
2. Implement a O(1) solution to problem E3.15 from the textbook. You are allowed to
use at most O(n) preprocessing time prior to start processing queries (each of which
has to be answered in O(1) time).

Partial preview of the text

Download CS2402 Lab 1: Computing Fibonacci Numbers and Optimization - Prof. Olac Fuentes and more Lab Reports Data Structures and Algorithms in PDF only on Docsity!

CS

Spring 2009

Lab 1

Due Friday, January 30, 2009

  1. Fibonacci numbers and complexity

Fibonacci numbers are defined recursively as follows: F(n) = n, for n<= F(n) = F(n-1) + F(n-2) for n>

Your assignment consists of writing the following methods to compute F(n): a) A O(2n) method based on the recursive definition b) A O(n) method that uses a loop c) A O(1) method that uses the closed form solution

Conduct experiments to compare the running times of your methods and verify that they behave as expected.

  1. Implement a O(1) solution to problem E3.15 from the textbook. You are allowed to use at most O(n) preprocessing time prior to start processing queries (each of which has to be answered in O(1) time).