A maintenance system accepts bay IDs, repair windows, part codes, and queued jobs. Its read path asks whether a bay exists, whether a requested time overlaps a repair window, and whether a part code is an exact match. Its write path must ingest jobs without an unbounded in-memory backlog. Assign a data structure to each operation and write down which process owns the authoritative state. A fast in-memory search tree cannot replace durable storage or a completed-job record.
Project: own a maintenance index and work queue
Choose structures and invariants
Use a B-tree page model to reason about ordered bay insertion and median promotion; choose an actual storage engine for on-disk indexes. Use a balanced interval tree with subtree maximums when frequent overlap queries and updates justify it. A plain unbalanced tree has O(n) worst-case height. Use a compressed trie for exact and prefix-oriented part-code routing when shared runs of symbols make node reduction useful. A red-black invariant audit can detect color or black-height damage after mutation, but it is not an insertion algorithm. A bounded synchronized queue protects worker memory while leaving retry and durability to separate services.
Acceptance trace
Insert bay IDs 47, 52, 61, 19, 26, 58, and 83; an in-order read must produce 19, 26, 47, 52, 58, 61, 83. For half-open windows [19, 26), [31, 42), [47, 61), [52, 58), and [83, 91), query [25, 32) and require some overlap, then query [62, 80) and require none. Store dock47, dock52, and doll61 as part codes; dock is a traversable prefix, not an exact key. Fill a two-slot queue with J-47 and J-52; a nonblocking J-61 attempt must report full instead of disappearing silently.
Bay order: 19, 26, 47, 52, 58, 61, 83
Window [25, 32): overlap
Window [62, 80): no overlap
Part dock47: exact; dock: prefix only
Third queued job: backpressureCost and ownership review
State the B-tree degree and distinguish CPU comparisons from page I/O. Pair interval metadata with balancing if a strict logarithmic bound matters; count O(k) output for k reported overlaps. Budget compressed edge labels and test insertion at a key that is itself another key's prefix. Specify a queue shutdown signal, failed-job record, bounded retry policy, and the point where a worker declares completion. Acknowledging a local queue item after an exception must not masquerade as a successful repair.
Common Mistakes
- Do not treat an invariant checker as a mutation method.
- Do not present a Python B-tree model as crash-safe storage.
- Do not claim a plain interval BST has balanced worst-case height.
- Do not equate queue removal with successful processing.
Connected lessons
- Red-black trees: audit color and black-height invariants
- B-trees: split full pages during ordered insertion
- Interval trees: prune overlap search with subtree maximums
- Compressed tries: split shared edge labels at the divergence
- Bounded thread queues: separate FIFO removal from task completion
- B+ leaf pages: split full pages and keep range order
- Data Structures
