q10 sol3 - CSCI.1100 Computer Science I Quiz 10 Monday...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CSCI.1100 Computer Science I Quiz 10 Monday November 23, 2009 Closed book, closed notes, no computers or calculators of any kind. Name: RCS login: Circle your lab section: (01 MTh 10:00) (02 MTh 12:00) (03 MTh 2:00) (04 MTh 4:00) (05 MTh 6:00) (06 MTh 10:00) (07 TF 10:00) (08 TF 12:00) (09 MTh 12:00) (10 TF 2:00) (11 MTh 4:00) 1. The Fibonacci sequence is defined as follows: If (n = 0) then fib (n) = 0 If (n = 1) then fib (n) = 1 Otherwise fib(n) = fib (n – 1) + fib (n – 2) a) Write a recursive function to compute the Fibanacci number for any positive integer. (4 points) int fib (int n) { if (n == 0) return 0; else if (n == 1) return 1; else return (fib (n – 1) + fib (n – 2); } 2 point for simple cases 2 points for simplification case
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2. Complete the following recursive function to find the largest number in a list of positive numbers or -1 if the list is empty. The code must be recursive [5 points]. int
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/04/2011 for the course CORE 101 taught by Professor Poop during the Spring '08 term at Rensselaer Polytechnic Institute.

Page1 / 3

q10 sol3 - CSCI.1100 Computer Science I Quiz 10 Monday...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online