COMP152 - Lab 6
-
On pencil and paper, do R-4.2 through R-4.5. Each of these problems asks you to trace (see fig 4.10 for an example) recursive functions. This should help prep your brain for designing and writing recursive functions.
-
In repl.it, do C-4.16 to C-4.18. For each function use the following process: create a stub for the function, write at least three unit tests (base case, an input of length one or two, and a longer input of your choosing, any other tests needed to cover different cases of the problem), run the tests to check for syntax errors (tests are expected to fail), then tackle the code and use the tests to check progress and correctness. This is a software development process known as test-driven design.
-
In repl.it, do C-4.20. Use test-driven design.
-
(Optional) Write a function to solve the same problem as 4.20 but use loops and iteration rather than recursion. Write a third function for this problem that uses python list comprehensions: no loops and no recursion.