BH an MF: block should be renamed in the style used throughout the rest of the course. --MF, 4/1/19
PG: Efficiency is important, even in the AP framework (though that's irrelevant at this time of year) but is a distraction until kids are so fluent with recursion that they're able to think about efficiency.
BH: End of lab 3
MF: I want to review/revise.
Pages or lab needs renaming so they aren't duplicative. --MF, 6/15/20
Here's one solution to the pascal
block:
There are two base cases, the beginning and end of a row. The recursive case calculates the sum of two values in the previous row.
=
+
You are about to figure out how many recursive calls are needed to compute a value in Pascal's Triangle.
pascal
block to keep count of how many times the block is executed.pascal
block called when calculating Many of the recursive calls are redundant. For example, will call
many times, asking for the same information.
pascal
, so that when the same inputs are given again, the function looks up the saved value instead of making more recursive calls.pascal
that is often used:
Build a version of pascal
that uses the formula. Compare the efficiency of this version to the recursive version, and determine whether each version runs in constant time, linear time, quadratic time, or exponential time.