
Segment trees for minimum and sum queries
Use one segment-tree design for sums, minima and ordered concatenation by requiring an associative combine operation and the right neutral element.
The journal / Ideas in progress
Engineering & everyday learningSoftware, systems, and the things I’m learning along the way. From first principles to AI in production.
Find something to readA little theory. A lot of practice.

Use one segment-tree design for sums, minima and ordered concatenation by requiring an associative combine operation and the right neutral element.

Merge sorted attendance records with two pointers while preserving duplicates and stable ties, then prove linear work and distinguish a merge from set union.

Use stable merge sort to preserve registration order among equal scores, trace the tie decision, and explain what stability does and does not guarantee.

Repair AVL imbalance with rotations that preserve in-order keys, follow the transferred middle subtree, and update stored heights in the right order.

Choose algorithm tests from an argmax contract, expose negative-value and tie bugs, and combine exact examples with exhaustive checks and useful properties.

Implement lower-bound binary search with a half-open interval, prove its boundaries, and test empty arrays, duplicates, and the insertion point after the last value.

Build a small prefix trie with explicit terminal markers, return limited suggestions in alphabetic order, and include output size in the query cost.

Compare array shifts and linked-list pointer changes for a concrete editor workload, including the cost of finding the insertion point and retaining a cursor.

Sort fixed-width decimal identifiers from the least significant digit upward, trace all passes, and prove why each pass must preserve earlier digit order.

Plan sorted runs and buffered merges for a file larger than RAM, calculate merge passes and I/O volume, and distinguish a byte budget from object memory.

Model a single FIFO help desk with explicit arrival ties, start times, waiting times, and idle periods, then separate service order from event scheduling.

Trace three-way quicksort partitioning on duplicate pivots, state its four-region invariant, and compare it with a two-way scheme that degenerates on equal input.