Skip to main content

Sorted Range Reporter

Challenge on lesson: Checkpoint: Algorithms

Implement void sort_asc(int *a, int n) (any in-place algorithm) and int in_range(const int *sorted_a, int n, int lo, int hi) counting elements of the ALREADY-SORTED array within [lo, hi] inclusive. For full credit, in_range should exploit sortedness with a scan that can stop early (or binary search twice) — but a correct linear scan also passes.

Difficulty: beginner

Back to lesson: Checkpoint: Algorithms