Course Self-Check and Mastery Review
How to use this page
Answer closed-book first, then compare against the key points. Each question is worth four points, for 100 total. A score of 80 is required, and questions 3, 8, 12, 15, and 19 (complexity, mutability, hashing, heaps, and graphs) may not score zero. Passing the tests in Dependency Task Scheduler is required evidence too.
The point is not terminology recall; it is confirming that you can choose structures from operations, maintain invariants, explain costs, and acknowledge engineering boundaries.
Closed-book questions
Abstraction and complexity
- Distinguish an ADT, a concrete data structure, and an algorithm, using a queue.
- Write three invariants and one failure postcondition for a tool registry.
- Why does not mean one machine instruction? What do average, worst-case, and amortized analysis answer?
- Why is
list.appendoften amortized ? Does that guarantee identical time for every call? - Why is
sys.getsizeof(list)not total memory for all nested elements? What would be stronger measurement evidence?
Linear structures and state
- What are common cost models for Python-list indexed read, middle insertion, and membership search?
- What premise does “linked-list insertion is ” hide? Why do ordinary Python projects rarely implement linked lists themselves?
- Draw references for
a = [[1]]; b = a.copy(); b[0].append(2)and state finala. - How do iterable, iterator, and generator relate? Why can a generator be consumed once?
- Where do
bisect_leftandbisect_rightreturn different bounds for duplicates? Why isinsortstill overall?
Stacks, queues, hashing, and priority
- Which Agent scenario suits a stack, FIFO queue, and bounded deque respectively? Which reliable-queue semantics are absent from an in-memory deque?
- What limits average dictionaries/sets? Why can a mutable list not be a key, and why cannot
hash()be a persistent ID? - Does dictionary insertion order mean key-sorted order? How do you make set output deterministic?
- How do deduplication and business idempotency differ? Why cannot a single-process set protect multi-instance writes?
- Which invariant does a heap maintain? Why is it not a fully sorted list? How do peer priorities avoid
TypeError? - Can numeric priority bypass a dependency? What is low-priority starvation?
Trees, graphs, and engineering composition
- Define a tree’s root, leaf, depth, and subtree. How do DFS and BFS auxiliary structures differ?
- Why maintain
visitedwhen enqueueing/pushing in graph traversal? How do you choose adjacency list versus matrix? - How is “A depends on B” represented in predecessor and successor maps? How does Kahn topological progress change in-degree?
- Does a graph cycle mean no node can execute? Why is a blocked node not necessarily a cycle member?
- In a
dict + indegree + adjacency + heapcomposition, which structure is source of truth and which are derived indexes? - What capacity/cleanup policies do unbounded message history, a seen set, and a ready heap need?
- How do you make scheduler output deterministic for identical input? State at least three rules.
- Why should you not rewrite code merely after seeing nested loops? Give an evidence chain.
- Why cannot this course’s list/dict/heap directly replace a vector database?
Answer key
Expand to check
- An ADT specifies operation semantics; a structure is a representation; an algorithm implements operations. A queue can use
dequeor a persistent messaging system.- Keys unique; key matches object name; auxiliary indexes stay synchronized. On failure all indexes keep their pre-call state.
- Big O describes growth with scale; average depends on distribution/assumptions; worst case takes highest cost; amortized analysis averages total cost across a series.
- A dynamic array occasionally expands. A run of operations averages out, but one call can resize.
- It counts only direct object allocation. Record version and workload; use
tracemallocor process Metrics and state their scope.- Common models are , , and .
- You already hold the insertion-position node. Finding it can still cost , while Python object/reference overhead and boundary bugs often remove the value.
- The outer lists share the inner list, so final
a == [[1, 2]].- An iterable produces an iterator;
nextconsumes an iterator; a generator is a stateful iterator that does not reset after exhaustion.- Left locates the left edge of equals and right the right edge. Lookup is but list shifting is .
- Backtracking, FIFO tasks, and recent-window storage; missing persistence, acknowledgement, leases, retry, recovery, and multi-machine consistency.
- Average is not worst-case guarantee; keys need stable hashing/equality; built-in
hashis not promised stable across processes.- It is not sorting. Use
sortedwith a stable comparable key or an independent ordered structure.- Deduplication identifies repeated identifiers; idempotency ensures repeated business execution has no extra side effect and needs a durable atomic record.
- The root is smallest and parent/child obey heap order; remaining items are not fully sorted. Use a unique sequence or stable ID to break ties.
- No: priority compares only ready tasks. Continual high-priority arrivals can starve a lower-priority task.
- DFS uses a stack and BFS a queue; both need node/depth limits.
- It prevents cycles and duplicate multi-path visits. Sparse graphs normally use adjacency lists; use a matrix only for dense graphs with frequent edge lookup.
- Predecessor map
A: {B}; successor mapB: {A}. Completing a predecessor decrements successor in-degree.- Unrelated DAG components can advance; downstream nodes may depend on a cycle without being cycle-path members.
- The task mapping is source of truth; all other structures are rebuildable. Updates need one entry point and invariants.
- State entry/byte caps and reject/evict/persist/backpressure semantics plus audit impact.
- Stable IDs, fixed edge direction, a tie key, no set-order dependence, identical input, and pinned version/rules.
- Record scale, operation frequency, and baseline; locate the hot path with profiler/timeit/tracemalloc; change the hot path and retest at the same workload.
- A dedicated index also addresses approximate retrieval, filtering, persistence, sharding, recall/latency tradeoffs, and concurrent updates.
Practical task A: bounded event window
Implement a local EventWindow:
- retain only the latest 100
(timestamp, event_id, category)values; event_idis unique inside the current window;- count by
category; - return closed-interval time events using binary search;
- order events by nondecreasing
timestamp, thenevent_idon ties; - after a failed add, deque/list, seen set, and
Counterremain unchanged; - write at least 12 tests for capacity eviction, duplicate, unordered input, time bounds, input immutability, and determinism.
Write the structure-selection card and invariants before implementation. Explain why evicting an event must also remove it from seen and the counter, and why this is still not an audit log.
Practical task B: migration design
An existing program scans a list of one million tool calls on every lookup, retains only recent results, and frequently looks up by ID. Write a migration design:
- State current primary operations and complexity.
- Select source of truth, ID index, and capacity window.
- Define consistency when a multi-structure update fails.
- State when a single-process structure is no longer enough.
- Give a method for benchmark-data generation, measurement, and regression validation.
- List problems you intentionally do not solve.
Do not invent “times faster.” Without measurement, state only a growth model and experiment plan.
Final mastery standard
- I can select structures from operation, scale, order, duplicates, capacity, and concurrency.
- I can explain time/space and average/worst/amortized cost without treating Big O as a stopwatch.
- I can handle mutability, shallow copy, iterator exhaustion, and mutation during iteration.
- I can use
deque,dict/set/Counter,bisect, andheapqcorrectly. - I can write tree DFS/BFS and DAG topological progress and accurately explain a cycle.
- I can define sources of truth, derived indexes, and invariants for composed structures.
- The Dependency Task Scheduler’s 24 tests pass and I can explain its complexity.
- I can state that in-memory examples lack production persistence, concurrency, recovery, and authorization semantics.
If you do not meet a point, return to its individual lesson and repeat its exercise. Do not hide a foundation gap by adding advanced trees or competitive-programming algorithms.
Next step
- Return to Data Structures Fundamentals.
- Data interchange continues in JSON; vectors and indexes continue in Vector Fundamentals and Vector Databases.
- Workflow execution and recovery continue in Workflow Automation.
References
This page combines mastery checks from the course. See individual lessons for exact facts and version sources. Retrieved on 2026-07-14.