How to use the visualizer

1. Pick an example — or write your own

The preset picker loads a classic recursive function into the editor with a ready-made initial call; its trace appears instantly. You can edit anything: the code (nested helper functions are fine) and the initial call, e.g. is_palindrome('racecar'). The initial call must be a single expression that calls one of your functions.

2. Run & trace

Press Run & trace (or Ctrl+Enter / Cmd+Enter in the editor). The first run downloads the Python runtime into your browser, which can take a little while — the button shows progress. Obvious mistakes (indentation, brackets, disabled features like imports) are reported with line numbers before anything runs. Big runs stop at a safety limit and the app asks before raising it.

3. Replay the recursion

A successful run replays automatically. Use the controls to step forward and back, play/pause, change speed, or jump to either end. The call stack shows the frames alive at the current step, the executing one on top. The call tree grows one call at a time; completed calls turn muted and show their return value, and dashed boxes mark repeated calls with the same arguments (recomputed work). Click any node for its details; a text version of the tree sits below it.

4. Time & space analysis

Open the Time & space analysispanel under the controls. Time follows the course's recurrence-relation method as a 5-step derivation, with a cross-check against the calls your run actually made. Space starts from the deepest the stack really got and generalizes via the recurrence. The analysis states its assumptions and its confidence — when it says a pattern needs instructor review, take that literally.

Limits worth knowing

  • Traces are capped (500 events / 100 frames by default; you confirm each raise, up to 2000 / 500). Keep inputs small — fibonacci(12) is already 465 calls.
  • The recurrence method recognizes the course patterns (one call with n − k or n/2; two calls with n − k or n/2). Anything else is reported honestly as unrecognized.
  • Your code never leaves the browser — see About & privacy.