cs211 lab4
https://maths.nuigalway.ie/~gettrick/teach/cs211/
-
For this lab you must write code (python files), and, if applicable, the result(s) of running the program on (a few) test cases. This will be graded only in person in the lab. 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 a comments section (using the hash tag) in your PYTHON code.
-
Check the file "criteria.pdf" to see what to look for, and what you should take care of, in your PYTHON code.
-
This will be graded only in person in the lab.
-
Plagiarism (the unattributed copying of work from other sources
(internet, chatGPT, 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
(see CANVAS)
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)
whether
the memoization makes a substantial different in run time for your function for a number of different (large) values of n.
©
Universityv of Galway