Linear Search
Scan elements sequentially one-by-one to locate match values.
Binary Search
Logarithmically divide search bounds on sorted arrays.
Lower Bound
Find the first element index greater than or equal to the target.
Upper Bound
Find the first element index strictly greater than the target.
Ternary Search
Find target in sorted range or peaks of unimodal continuous functions.
Binary Search on Answer
Perform binary searches to solve Book Allocation or Cows optimization limits.
Bubble Sort
Repeatedly scan and swap adjacent unsorted elements.
Selection Sort
Select the minimum element from the unsorted zone and place it at the front.
Insertion Sort
Build final sorted array by inserting each key element relative to sorted prefix.
Merge Sort
Divide array into halves, sort recursively, and merge sorted halves.
Quick Sort
Partition array elements around pivot keys recursively.
Heap Sort
Represent the array as a binary max heap, repeatedly extract max elements.
Counting Sort
Non-comparison sorting using value frequencies counts lists.
Radix Sort
Sort integers digit-by-digit from LSD to MSD stably.
Bucket Sort
Distribute elements into range buckets, sort buckets, and gather.
Sorting Benchmark Tool
Compare execution times, comparisons, and swaps across algorithms.
Custom Comparator Playground
Verify sorting stability and user-defined records comparators.
Search space bounds & decision functions
In competitive programming, searching extends beyond simple arrays. By defining a monotonic decision function `f(x)` that returns `true` or `false`, we can binary search the solution space to find boundary thresholds.
- Lower Bound: First index where `f(x)` is satisfied (element >= target).
- Binary Search on Answer: Finding maximum/minimum feasible limits.
Sorting Stability Invariants
A sorting algorithm is stable if it preserves the relative order of items with equal keys. This is critical when sorting records across multiple columns.
- Stable algorithms: Bubble Sort, Insertion Sort, Merge Sort, Counting Sort.
- Unstable algorithms: Selection Sort, Quick Sort, Heap Sort.