Fall05Hw1

# Fall05Hw1 - Return fib1(n-1 fib1(n-2 Iterative algorithm...

This preview shows page 1. Sign up to view the full content.

CSE 5211/4081 Fall 2005 Homework 1 Points: 15/(Grad)20 Due: 9/8/05 .1. Prove that ( i=0 N-1 i) is Θ ( N 2 ). .2. Analyze the complexity of the algorithms MaxSubSum2 (page 39) and MaxSubSum4 (page 42) in the text. .3. Fibonacci series starts with two integers 1 and 1. All the subsequent numbers in the series is sum of the previous two numbers (1, 1, 2, 3, 5, 8, 13, 21, …). Thus, Fibbonacci number corresponding to 7 is 21. The following are two algorithms for calculating the Fibonacci number corresponding to an input positive integer n. Recursive algorithm: fib1(n) If n = = 0 or 1 Return 1 Else
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Return fib1(n-1) + fib1(n-2); Iterative algorithm: fib2(n) If n = = 0 or 1 Return 1 Else prev = temp =1; For I = 2 through n do prev2prev = prev; prev=temp; temp = prev+prev2prev; Return temp; Implement these two algorithms. Run them with increasing input n and find out what happens with the run times. Optionally you may like to measure the run time of each of the programs and plot them against increasing n. Submission: source codes and a few lines of description regarding the run times. Graduate class: 4. Prove that if f(n) = Θ (g(n)), then g(n) = Θ (f(n))....
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online