cs211 lab5
http://www.maths.nuigalway.ie/~gettrick/teach/cs211/labs/l5.html
-
For this lab you must submit all source code (python
files), and, if applicable, the result(s) of running the program on (a few)
test cases. This should be sent in as a file upload/attachment via BLACKBOARD (not directly by email).
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). Any questions asked should be answered by
typing the answers into the relevant box on the BLACKBOARD upload form, or
by including the answer in comments in the PYTHON source code..
-
This material should be uploaded
before
the deadline of 10pm
Thursday November 16th., 2017. 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.
You risk getting zero for your lab if it is found to be
plagiarized.
Have a look at (and run) the PYTHON programs mem4.py, memoize1.py, memoize2.py
in the "progs" directory.
Consider the functions (a) f: N -> N, f(n)=2**n, and (b) g: N -> N,
g(0)=0, g(1)=1,
g(n+1) = g(n)*(g(n)+2g(n-1))
-
TASK 1
Write PYTHON functions that calculate f and g for any input n
-
TASK 2
Write MEMOIZED versions of both of your functions. Determine (and comment
in your code in comments, or when submitting the lab in the text box) whether
the memoization makes a substantial different in run time for your function for a number of different (large) values of n.
©
NUI, Galway