Jump to a problem, path or page
Jump to a problem, path or page
Updates as you edit. Run the review to record it; passing every check completes the problem.
Not yet passed: WeightedSampler responsibility
Add WeightedSampler and define its responsibility.
Not yet passed: WeightValidator responsibility
Add WeightValidator and define its responsibility.
Not yet passed: PrefixSums responsibility
Add PrefixSums and define its responsibility.
Not yet passed: BoundedRandomSource responsibility
Add BoundedRandomSource and define its responsibility.
Not yet passed: BinarySearch responsibility
Add BinarySearch and define its responsibility.
Not yet passed: WeightedSampler → WeightValidator
A directed path must connect WeightedSampler to WeightValidator. Arrows represent requests, dependencies, or event flow.
Not yet passed: WeightedSampler → PrefixSums
A directed path must connect WeightedSampler to PrefixSums. Arrows represent requests, dependencies, or event flow.
Not yet passed: WeightedSampler → BoundedRandomSource
A directed path must connect WeightedSampler to BoundedRandomSource. Arrows represent requests, dependencies, or event flow.
Not yet passed: WeightedSampler → BinarySearch
A directed path must connect WeightedSampler to BinarySearch. Arrows represent requests, dependencies, or event flow.
Not yet passed: For a draw r in [0, total), which prefix is selected?
Not yet passed: How should zero-weight entries behave?
Not yet passed: Can modulo reduction always create a uniform bounded draw?
Not yet passed: Interfaces and invariants
Write at least 80 characters describing concrete operations, inputs, outputs, state and errors. This check measures completeness, not semantic correctness.
Not yet passed: Trade-offs and failure cases
Write at least 80 characters about alternatives, failure handling and edge cases. Review the reasoning yourself using the reference discussion.
Rule-based educational feedback. Notes are checked by length only; topology checks confirm directed reachability. These checks do not validate semantics, latency, reliability or every valid design.
Snapshot validated items and checked integer prefix sums once. Each sample obtains a uniform integer below total weight and binary-searches the first prefix strictly greater than that draw. Validate unique item IDs and nonnegative safe-integer weights. Accumulate with checked addition and reject an empty or zero-total distribution. Store immutable item and cumulative-weight arrays. Zero-weight entries retain repeated prefixes and therefore empty draw intervals. Call the injected bounded generator with total weight and validate its returned integer range. Use upper-bound search to find the selected index in logarithmic time. Document O(n) construction and O(log n) sampling with O(n) storage. Updating weights creates a new sampler; security-sensitive randomness and mutable weighted trees are outside this exercise.
There is no single correct diagram. Explain where yours differs and which requirement justifies it.