PREDICT · IMPLEMENT · EXPLAIN
Short implementation exercises
Turn a rule you have traced into a short JavaScript function, run the tests, and explain a new input.
Predict cache eviction
- Implement one LRU cache access · 12 min
Return the hit status, updated order, and evicted key after one access.
- Trace hits and evictions across references · 20 min
Start empty and process a reference sequence, returning the final order and eviction history.
Translate an address with a page table
- Split a byte address into page and offset · 12 min
Use quotient and remainder to return the two components of an address.
- Translate an address with a page table · 20 min
Look up the frame and return a physical address or a page fault.
Trace stacks and queues
- Implement stack and queue removal · 12 min
Switching the removal end changes the result even with the same entries.
- Trace removals and remaining entries · 20 min
Apply additions and removals in order, recording removal results separately from current state.
Count operations as inputs change
- Count body executions in a doubling loop · 12 min
Start i at one, double it each time, and count iterations where i < n.
- Compare two loops in the same units · 20 min
Return the specified body counts for linear and triangular loops, along with their difference.
Predict box widths and positions
- Compute a child box’s width and horizontal position · 12 min
Compute horizontal dimensions in the simplified layout model from the parent width and child margin.
- Place a column of boxes and detect overflow · 20 min
Place the boxes in input order and return their dimensions and horizontal overflow.
Predict asynchronous execution order
- Order synchronous work and initial microtasks · 12 min
Build the execution order through the first checkpoint from the two lists of labels.
- Drain each task’s microtasks before the next task · 20 min
Order tasks and their registered microtasks according to the specified checkpoints.