Complete the code to identify variables that are live at a program point.
live_vars = [1]Live variables are best tracked using a set to avoid duplicates and allow fast membership checks.
Complete the code to update live variables after processing a statement.
live_vars = (live_vars - [1]) | [2]
Variables defined (defs) in a statement are removed from live variables because they get new values, then union with used variables (uses).
Fix the error in the live variable update formula.
live_in = (live_out - [1]) | [2]
The correct operator to combine sets is union (|), not addition (+), and remove defs before adding uses.
Fill both blanks to compute live variables at a program point.
live_in = (live_out - [1]) | [2]
Live variables coming into a statement are those live after it, minus variables defined there, plus variables used there.
Fill all three blanks to create a dictionary of live variables for each program point.
live_vars_map = {point: ([3] - [1]) | [2] for point, ([3]) in program_points.items()}For each program point, remove defined variables (defs), add used variables (uses), and unpack live_info from the items.