CPKit
v1.6.1

Linear Search

Scan elements sequentially one-by-one to locate match values.

O(N)Easy

Binary Search

Logarithmically divide search bounds on sorted arrays.

O(log N)Easy

Lower Bound

Find the first element index greater than or equal to the target.

O(log N)Easy

Upper Bound

Find the first element index strictly greater than the target.

O(log N)Easy

Ternary Search

Find target in sorted range or peaks of unimodal continuous functions.

O(log3 N)Medium

Binary Search on Answer

Perform binary searches to solve Book Allocation or Cows optimization limits.

O(N log S)Hard

Bubble Sort

Repeatedly scan and swap adjacent unsorted elements.

O(N^2)Easy

Selection Sort

Select the minimum element from the unsorted zone and place it at the front.

O(N^2)Easy

Insertion Sort

Build final sorted array by inserting each key element relative to sorted prefix.

O(N^2)Easy

Merge Sort

Divide array into halves, sort recursively, and merge sorted halves.

O(N log N)Medium

Quick Sort

Partition array elements around pivot keys recursively.

O(N log N)Medium

Heap Sort

Represent the array as a binary max heap, repeatedly extract max elements.

O(N log N)Medium

Counting Sort

Non-comparison sorting using value frequencies counts lists.

O(N + K)Medium

Radix Sort

Sort integers digit-by-digit from LSD to MSD stably.

O(D * N)Medium

Bucket Sort

Distribute elements into range buckets, sort buckets, and gather.

O(N + B)Medium

Sorting Benchmark Tool

Compare execution times, comparisons, and swaps across algorithms.

O(N log N)Medium

Custom Comparator Playground

Verify sorting stability and user-defined records comparators.

O(N log N)Easy

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.