AlgoViz

The 5-step execution flow

easy 45 min

A fixed order for the 45 minutes of a low-level design round: ask, name, sketch, build, prove.

Video lesson · Chapter 1 of 6

Make a prediction

0:00 / 4:38

See it run

The plan, the calls it leads to, the trace and the extension.

Operations

The plan

Five steps, each hands something on.

Step 1 of 5

Ask

MinutesHands on
1 Ask0 to 5requirements
2 Name
3 Sketch
4 Build
5 Prove

Five to seven lines that both agree on.

Step 1: Ask

Good for
Every round
Costs
A visible clock

Write the five end times at the edge of the board before you start.

In the real world

The same the 5-step execution flow doing real jobs. Pick one and step through it.

Seven minutes behind, and still a good end.

Step 1 of 5

Too many questions

PlanReally
Ask endsminute 5minute 12
Name ends
Sketch ends
Build ends
Prove ends

Ask ends at 12. Seven minutes late.

Step 1: Too many questions

Common mistakes

The bugs interviewers watch for, with the fix beside each.

  • State in a timer thread

    major

    It races with empty and makes tests slow.

    Wrong
    Thread(target=lambda: (sleep(1800), set_done())).start()
    Right
    return RUNNING if now < wash.ends_at else DONE
  • Count outside the lock

    critical

    Two taps both see one machine in use.

    Wrong
    if held(who) < 2:    with lock: machine.start(who)
    Right
    with lock:    if held(who) >= 2: raise Refused()    machine.start(who)
  • Reading the clock twice

    minor

    Two rules of one call see two times.

    Wrong
    rule.check(clock())machine.start(who, 30, clock())
    Right
    now = clock()rule.check(now)machine.start(who, 30, now)
  • A test that cannot fail

    major

    If nothing is raised, it passes.

    Wrong
    try: room.start("lee", "m1", QUICK)except Refused: pass
    Right
    assert refused(lambda: room.start("lee", "m1", QUICK))

Interview tips

  • Show the clock

    • Write five end times
    • Say where you are
    • Late: cut aloud
  • End each step

    • A result to look at
    • One exit line
    • Wait for a nod
  • Core first

    • The method where rules meet
    • Refusals, then change
    • Time passed in
  • Leave well

    • What works
    • What is left out
    • What comes next