Course offer · HLD · LLD · System Design at ₹799 until 30 Nov (not interview packs)

ProgramsC++

Sorting & Searching Programs

Sorting and searching in C++: bubble, insertion, selection, merge, quick, heap, radix, and counting sort, plus linear, binary, jump, and interpolation search, all traced.

13 programs · open one, then the next

Start with Bubble Sort
  1. 01Bubble SortBeginnerSort an array with bubble sort in C++, swapping neighbours until the largest values reach the end. Includes the swapped flag that stops early when sorted.Open example →
  2. 02Insertion SortBeginnerSort an array with insertion sort in C++: take each element as a key and shift larger values right until it fits. Fast on nearly sorted data, O(n²) worst.Open example →
  3. 03Selection SortBeginnerSort an array with selection sort in C++ by finding the minimum of the unsorted part and swapping it forward. At most n − 1 swaps, always O(n²) compares.Open example →
  4. 04Merge SortIntermediateSort an array with merge sort in C++: split it in half recursively, sort each half, and merge. Explains the recursion tree, the merge step, and O(n log n).Open example →
  5. 05Quick SortIntermediateSort an array with quick sort in C++ using the Lomuto partition with the last element as pivot. Traces one partition and the O(n²) worst case on sorted input.Open example →
  6. 06Heap SortIntermediateSort an array with heap sort in C++ by building a max heap and repeatedly moving the root to the end. Explains child index formulas 2i + 1 and 2i + 2 and heapify.Open example →
  7. 07Radix SortAdvancedSort non-negative integers with radix sort in C++, running a stable counting sort on each digit from ones to hundreds. Traces 170 45 75 90 802 24 2 66.Open example →
  8. 08Counting SortIntermediateSort small-range integers with counting sort in C++: count each value, turn counts into positions, and place items stably. Handles negatives by shifting.Open example →
  9. 09Linear SearchBeginnerSearch an unsorted array with linear search in C++, checking each element until the key is found. Returns the index or -1, and works on any order of data.Open example →
  10. 10Binary Search (Iterative)BeginnerFind a value in a sorted array with iterative binary search in C++, halving the range each step with left, right, and mid. Explains why the input must be sorted.Open example →
  11. 11Binary Search (Recursive)BeginnerWrite binary search recursively in C++, where each call checks mid and recurses on one half. Explains the base case, the call stack, and the loop version.Open example →
  12. 12Jump SearchIntermediateSearch a sorted array with jump search in C++, skipping ahead in blocks of √n and then scanning one block. Traces finding 55 in a 16-element Fibonacci array.Open example →
  13. 13Interpolation SearchIntermediateSearch a sorted, evenly spread array with interpolation search in C++ by estimating the position from the key. Shows the formula and when it slows down.Open example →