Skip to main content

Menu

LEVEL 0
0/5 XP
HomeAboutTopicsPricingMy VaultStats

Categories

πŸ€– Artificial Intelligence
☁️ Cloud and Infrastructure
πŸ’Ύ Data and Databases
πŸ’Ό Professional Skills
🎯 Programming and Development
πŸ”’ Security and Networking
πŸ“š Specialized Topics
HomeAboutTopicsPricingMy VaultStats
LEVEL 0
0/5 XP
GitHub
Β© 2026 CheatGridβ„’. All rights reserved.
Privacy PolicyTerms of UseAboutContact

Algorithms Cheat Sheet

Algorithms Cheat Sheet

Back to Mathematics and Algorithms
Updated 2026-04-29
Next Topic: Approximation Algorithms and Heuristics Cheat Sheet

Algorithms are step-by-step computational procedures for solving problems β€” ranging from simple tasks like searching and sorting to complex optimization and graph traversal challenges. They form the foundation of computer science, enabling efficient data processing across fields like artificial intelligence, databases, networking, and systems design. Understanding algorithmic paradigms β€” such as divide-and-conquer, dynamic programming, greedy methods, and backtracking β€” equips you to select the right strategy for a problem's constraints. A key insight: the best algorithm isn't always the fastest in theory; cache locality, constant factors, and input characteristics often matter more in practice than asymptotic complexity alone.


What This Cheat Sheet Covers

This topic spans 21 focused tables and 166 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.

Table 1: Sorting AlgorithmsTable 2: Searching AlgorithmsTable 3: Dynamic ProgrammingTable 4: Greedy AlgorithmsTable 5: Divide and ConquerTable 6: BacktrackingTable 7: Graph Algorithms β€” Shortest PathTable 8: Graph Algorithms β€” Minimum Spanning TreeTable 9: Graph Algorithms β€” Traversal and TopologyTable 10: Graph Algorithms β€” Cycle DetectionTable 11: Network Flow AlgorithmsTable 12: String AlgorithmsTable 13: Tree AlgorithmsTable 14: Advanced Data StructuresTable 15: Algorithmic Paradigms and TechniquesTable 16: Computational GeometryTable 17: Complexity ClassesTable 18: Recursion PatternsTable 19: Hashing TechniquesTable 20: Approximation and Randomized AlgorithmsTable 21: Number Theory Algorithms

Table 1: Sorting Algorithms

AlgorithmExampleDescription
Quick Sort
pivot = arr[high]
partition(arr, low, high)
quicksort(arr, low, pi-1)
β€’ Divide-and-conquer sort that picks a pivot, partitions around it, and recursively sorts
β€’ average O(n \log n), worst O(n^2) but cache-friendly and widely used in practice.
Merge Sort
mid = (left + right) // 2
mergesort(arr, left, mid)
merge(arr, left, mid, right)
β€’ Stable divide-and-conquer sort that always runs in O(n \log n) time
β€’ requires O(n) extra space but guarantees consistent performance.
Tim Sort
minrun = compute_minrun(n)
insertionSort for runs < minrun
merge adjacent runs
β€’ Hybrid of merge sort and insertion sort
β€’ O(n \log n) worst case, optimized for real-world data, used in Python and Java standard libraries.
Heap Sort
buildMaxHeap(arr)
swap(arr[0], arr[i])
heapify(arr, 0, i)
β€’ In-place sort using a binary heap
β€’ O(n \log n) time, O(1) space, but not stable and slower in practice than Quick Sort due to poor cache behavior.
Counting Sort
count = [0] * (max_val + 1)
for x in arr: count[x] += 1
for i, c in enumerate(count): output.extend([i] * c)
β€’ Non-comparison integer sort that counts occurrences
β€’ O(n + k) time where k is range, efficient when k = O(n) but requires extra space.
Radix Sort
for digit in range(num_digits):
countingSortByDigit(arr, digit)
β€’ Non-comparison sort that processes digits from least to most significant
β€’ O(d(n + k)) where d is digits, works well for integers with bounded digit count.

More in Mathematics and Algorithms

  • Algebra Cheat Sheet
  • Approximation Algorithms and Heuristics Cheat Sheet
  • Abstract Algebra Essentials Cheat Sheet
  • Convex Optimization Cheat Sheet
  • Hash Tables and Hash Maps Cheat Sheet
  • Number Theory Cheat Sheet
View all 57 topics in Mathematics and Algorithms