CS209 lab7
http://www.maths.nuigalway.ie/~gettrick/teach/cs209/l7.html
-
For this lab you should submit all source code (C
files), and the result(s) of running the program on (a few)
test cases.
The source code must
be well presented (indenting, spaces, reasonable variable/function names,
etc.) and must include comments (as a rough guideline - aim to have nearly as
many comments as lines of code).
-
The above material should be uploaded in BLACKBOARD before
the deadline of 5pm
Wednesday 16th. March 2011. You will lose 20% for each day
(or part of day) the lab is late.
-
Plagiarism (the unattributed copying of work from other sources
(internet, fellow students,....)) will not be tolerated. Please see
http://www.nuigalway.ie/engineering/documents/plagiarism_guide_students
_v4.pdf. You risk getting zero for your lab if it is found to be
plagiarized.
-
Write two separate programs in C to calculate the nth
Fibonacci Number
(see, for example
http://en.wikipedia.org/wiki/Fibonacci_number). The first program should use
iteration and the second recursion (the recursive program must
use "top down" recursion, i.e. the recursive function f(n) will call
f(n-1) and f(n-2)).
-
Test both your programs on calculating the 10th, 20th, 30th, 40th etc.
Fibonacci number, until the recursive program slows down noticeably.
-
State the first
value of n for which your recursive program takes more than
10 seconds to complete.
©
NUI, Galway