Case-based lecture: you attempt, we discuss, then we reveal.
cs-125, cs-126, cs-127, cs-128A robot returns books: requests (minute, shelf) pairs arrive; the robot serves shelves in increasing minute order, one per minute, and idle-waits otherwise. Compute total idle time and the busiest shelf. Full method: model, plan, solve, test, present.
requests = [(2, "A"), (3, "B"), (7, "A"), (7, "C"), (9, "B")]
requests.sort()
clock = idle = 0
tally = {}
for m, shelf in requests:
if m > clock:
idle += m - clock
clock = m
tally[shelf] = tally.get(shelf, 0) + 1
clock += 1
busiest = sorted(tally.items(), key=lambda kv: (-kv[1], kv[0]))[0][0]
print(idle, busiest)Expected: total idle 3 minutes; busiest shelf A (tie with B, alphabetical)
Cost: O(k log k) for the sort, O(k) service; the presentation, not the code, is the exam.
Six talks with (start, end, room-needed or None), rooms R1 R2. Fit every talk or report the minimal set to drop. Twenty minutes, method marks for the plan.
talks = [(9, 10), (9.5, 10.5), (10, 11), (10.5, 11.5), (11, 12), (11.5, 12.5)]
talks = sorted(talks, key=lambda t: t[1])
rooms = [0.0, 0.0]
placed, dropped = [], []
for idx, (s, e) in enumerate(talks):
r = rooms.index(min(rooms))
if rooms[r] <= s:
rooms[r] = e
placed.append((s, e))
else:
dropped.append((s, e))
print(len(placed), len(dropped))Expected: all 6 talks placed; nothing dropped (with these arrivals)
Cost: O(n log n) sort + O(n x rooms) placement; the marks are in the plan write-up.
One messy table: missing cells, a duplicated row, one impossible value, and a mixed-case category. Clean it with an audit trail, then produce ONE honest summary sentence. All semester, one page.
rows = [("Ada", "CS", 80), ("ada", "cs", 80), ("Bo", "DS", None), ("Cy", "DS", 150)]
seen, clean, log = set(), [], []
for name, cat, val in rows:
key = (name.lower(), cat.lower(), val)
if key in seen:
log.append(f"duplicate {name}")
continue
seen.add(key)
if val is None:
log.append(f"missing {name}")
continue
if not 0 <= val <= 100:
log.append(f"impossible {name}: {val}")
continue
clean.append((name.title(), cat.upper(), val))
print(clean, log)Expected: 1 clean row; audit log: 1 duplicate, 1 missing, 1 impossible
Cost: O(n); the grade lives in what the log says, not what the loop costs.
A robot returns books to shelves minimising total walking, with a battery limit. Route planning meets knapsack-ish choice; full method: model, algorithm, tests.
**Input:** shelves along a corridor at positions [1, 4, 7, 10]; returns pile [4, 10, 1]; robot starts at 2, battery 12 m**Output:** greedy nearest-shelf route 2->4->7->10->1 = 2+3+3+9 = 17 > 12 battery -> infeasible; better order 2->1->4->7->10 = 1+3+3+3 = 10 <= 12Solve for the worked instance first. Then ask what would change if onenumber, name, or condition were replaced by something stranger.Pseudocode, flowchart or Python. State one assumption. Compare with your neighbour at minute 4.
Instructor: the reveal, the reasoning section and common wrong turns are in the instructor distribution for cs-125 — not embedded in this deck.
Schedule taster talks from preferences and room limits to maximise satisfied visitors. Greedy with a tie-break rule, evaluated against a simulation of visitor happiness.
**Input:** 3 talks x 2 slots, room cap 2; preferences: ada: [T1, T2], bo: [T2, T3], cy: [T1], dee: [T3, T1]**Output:** assign visitors to (talk, slot) maximising first preferences subject to caps - enumerate: satisfied 3-4 of 4Solve for the worked instance first. Then ask what would change if onenumber, name, or condition were replaced by something stranger.Pseudocode, flowchart or Python. State one assumption. Compare with your neighbour at minute 4.
Instructor: the reveal, the reasoning section and common wrong turns are in the instructor distribution for cs-126 — not embedded in this deck.
A messy departmental dataset end-to-end: profile, clean, summarise honestly, and answer three posed questions with stated limitations.
**Input:** rows with missing hours, duplicate ids, one 25-hour day, mixed am/pm**Output:** profile -> clean (typed policies per defect) -> honest summary (median, with N after cleaning) -> 3 answers with limitationsSolve for the worked instance first. Then ask what would change if onenumber, name, or condition were replaced by something stranger.Pseudocode, flowchart or Python. State one assumption. Compare with your neighbour at minute 4.
Instructor: the reveal, the reasoning section and common wrong turns are in the instructor distribution for cs-127 — not embedded in this deck.
Two unseen capstone problems under exam conditions, then a structured debrief mapping each step to the lecture that taught it. The course, walked backwards.
**Input:** unseen problem A: balancing team sizes from skill scores; unseen problem B: minimum coins for a fee with odd denominations**Output:** A: greedy by score with size cap, verified against brute force; B: DP (greedy fails for odd systems - lecture 23)Solve for the worked instance first. Then ask what would change if onenumber, name, or condition were replaced by something stranger.Pseudocode, flowchart or Python. State one assumption. Compare with your neighbour at minute 4.
Instructor: the reveal, the reasoning section and common wrong turns are in the instructor distribution for cs-128 — not embedded in this deck.