Tag: Sorting
4 posts
-
Bubble, Selection and Insertion Sort: Time Complexity and Why Insertion Sort Wins on Nearly Sorted Data
Bubble, selection and insertion sort in Python with their time complexity, why insertion sort wins on nearly sorted data, and how Timsort fits in.
-
Quick Sort, Merge Sort and Heap Sort: How O(n log n) Sorting Works and When Each Wins
Quick, merge and heap sort in Python: how each reaches O(n log n), when quick sort degrades to O(n^2), which are stable or in-place, and Kth largest.
-
Sorting Problems: Multi-Key Sorts, Custom Comparators, and When Sorting First Solves the Problem
Sorting interview problems in Python: stable multi-key sorts, cmp_to_key comparators, why sort-by-end greedy works, and comparator bugs that fail submissions.
-
Binary Search: Lower/Upper Bound, Binary Search on the Answer, and Off-by-One Traps
Binary search beyond "find x in a sorted array": loop invariants that keep bounds correct, lower and upper bound, binary search on the answer, and the off-by-one and infinite-loop bugs that fail interviews.