Recursion and Dictionaries Lab
Algorithms, Programming, and Data Representation · Module 92313 · Chapter 8
Commit to a prediction, then watch a call trace or dictionary update unfold one step at a time. The experiments model the lecture’s positive-integer multiplication, 0-based Fibonacci sequence, normalized palindrome test, word counts, and nested-list flattening.
How the lab works
- Predict. Choose an answer before the trace runs.
- Rate your confidence. A sure but wrong prediction marks an idea to revisit.
- Reveal. Follow the call descent, returned values, or changing key–value table.
- Explore. Open the sandbox at any time and change its input; generated challenges practise new values.
8.1 Recursive multiplication: calls down, answers up
Each call reduces the positive multiplier by one until the base case returns. Then the waiting calls add one more copy of a.
The call trace appears here.
8.4 Fibonacci: repeated calls and a cache
Compare the recursive call count with a memoized version. The cache starts with fib(0) = fib(1) = 1.
The call comparison appears here.
8.5 Palindromes: compare the ends
Normalize to lowercase letters, compare the outside pair, and move inward only when the pair matches.
The character comparisons appear here.
8.6 Dictionary lookup and update
A key selects one value. Follow a lookup, membership check, update, or deletion through the current table.
The dictionary state appears here.
8.7 Word frequency: count, then compare
Read the words in order, update one count per word, then find every key tied at the maximum.
The frequency table appears here.
8.8 Nested lists: flatten as calls return
Follow each nested list into a smaller call; each sublist returns its flattened values before the outer call continues.
The nested-list call trace appears here.
Your results
Personal study lab based on the Chapter 8 guide and supplied “08_recursion_and_dictionaries.pdf”, written in my own words; its traces follow Python 3 dictionary semantics. Not an official FAU publication; check course details against the current notes. Made by Thanate Amornjiraporn (Focus).