The Algorithms - Python Tours
52 tours available
Getting Started with Your First Contribution to TheAlgorithms/Python
beginnerWalk the README disclaimer, the CONTRIBUTING.md algorithm requirements, the canonical insertion_sort file shape, the auto-generated DIRECTORY.md, the pytest --doctest-modules gate, and the path to deeper algorithm tours.
Navigating TheAlgorithms/Python: A Tour of the 43 Categories
beginnerSample one canonical algorithm from each major category (a sort, a search, a graph traversal, a DP class, a cipher) and end on the autoapi_dirs list that names every category.
How Bubble Sort Works
intermediateCompare adjacent elements, swap if out of order, repeat. The algorithm that appears in every first-year course because the swapping motion is easy to picture.
How Insertion Sort Works
intermediatePick the next element, shift everything larger one position right, drop the element into the gap. The algorithm that outperforms quicksort on small runs.
How Selection Sort Works
intermediateFind the minimum of the unsorted region, swap it to the front, repeat. O(n squared) always, but only O(n) swaps total.
How Mergesort Works
intermediateSplit the list in half, sort each half recursively, merge the two sorted halves. The first algorithm written for a stored-program computer.
How Quicksort Works
intermediateA random pivot, a partition into lesser and greater, two recursive calls. The 1959 algorithm that still drives most stdlib sorts.
How Heapsort Works
intermediateBuild a max-heap over the array, then repeatedly swap the root to the back and restore the heap. O(n log n) worst case with no extra memory.
How Radix Sort Works
intermediateSort by least significant digit, then next digit, repeat. Non-comparison sort that runs in O(d times n) rather than O(n log n).
How Counting Sort Works
intermediateNo comparisons, no pivots. Count key frequencies, prefix-sum them, then place each element at its exact output index in one backward pass.
How Linear Search Works
intermediateScan every element in order, return the index on match, return -1 on miss. The lower bound for searching unsorted data.
How Binary Search Works
intermediateHalve the search space on every step. The 1946 algorithm that still trips up professionals on overflow and off-by-one errors.
How Jump Search Works
intermediateJump through sorted data in square-root-sized blocks, then linear-search the candidate block. O(sqrt(n)) with no recursion, no pivots.
How BFS Works
intermediateVisit every neighbor before going deeper. The FIFO queue invariant that guarantees shortest-path distances on unweighted graphs.
How DFS Works
intermediateFollow a path as deep as it goes before backtracking. The iterative stack-based implementation that mirrors the recursive structure without blowing the call stack.
How Dijkstra's Algorithm Works
intermediateA min-heap of (cost, node) tuples, a visited set, and a single relaxation loop. The 1956 algorithm at the core of OSPF and IS-IS routing.
How A* Search Works
intermediateCombine actual path cost with a heuristic estimate of remaining distance. The 1968 algorithm built for a robot, now in every map and game engine.
How Bellman-Ford Works
intermediateRelax every edge V-1 times, then run one more pass to detect negative cycles. The algorithm Dijkstra cannot replace.
How Kruskal's Algorithm Works
intermediateSort edges by weight, then add each one unless it creates a cycle. Union-find with path compression in 46 lines.
How Fibonacci DP Works
intermediateCache the sequence on a class instance, extend it on demand, return a slice. The canonical example of memoization replacing exponential recursion.
How the 0/1 Knapsack DP Works
intermediateFill a capacity-by-item table bottom-up, then trace back through it to recover which items go in the bag.
How Longest Common Subsequence Works
intermediateA 2-D DP table, one recurrence, and a traceback walk. The algorithm at the core of diff, git-merge, and DNA sequence alignment.
How Edit Distance Works
intermediateCount the minimum insertions, deletions, and substitutions to transform one string into another. The 1965 algorithm behind spell-check, fuzzy search, and DNA alignment.
How the Sieve of Eratosthenes Works
intermediateMark every multiple of each found prime starting at its square. What remains is a list of primes, produced in O(n log log n).
How the Caesar Cipher Works
intermediateA modular shift over an alphabet, mirrored to decrypt, exhausted to brute-force. The oldest attested cipher in the Western record.
How RSA Encryption Works
intermediateSplit the message into fixed-size integer blocks, raise each block to a modular power, and undo it with the private exponent.
How SHA-1 Works
intermediatePad the message, split into 512-bit blocks, expand each block to 80 words, run 80 rounds of bit operations, accumulate five 32-bit words into a 160-bit digest.
How MD5 Works
intermediateFour 32-bit state words, 64 rounds, a sin-derived constant table. The 1991 algorithm that still shows up in checksums everywhere.
How the Knuth-Morris-Pratt Algorithm Works
intermediatePreprocess the pattern into a failure array, then scan the text without backtracking. The 1977 algorithm that makes grep and DNA search O(n+m).
How Rabin-Karp String Matching Works
intermediateHash the pattern, slide a rolling hash across the text, confirm on match. The 1987 algorithm that makes multi-pattern search practical.
How a Bloom Filter Works
intermediateA bitarray, two hash functions, and a membership check that never gives false-negatives. Burton Bloom's 1970 data structure still in production databases.
How an LRU Cache Works
intermediateA doubly-linked list plus a hashmap gives O(1) get and put. The eviction policy at the core of CPU caches, browser caches, and functools.lru_cache.
Sorting Algorithms in TheAlgorithms/Python
beginnerSeven sorting strategies side by side: from the classroom bubble loop to radix buckets.
Search Algorithms in TheAlgorithms/Python
beginnerSeven search strategies from a simple scan to partition-based selection, each with a different trade-off.
Cipher Algorithms in TheAlgorithms/Python
intermediateSeven ciphers from ancient Rome to Diffie-Hellman: each a different answer to the question of what makes a message unreadable.
Hash Functions in TheAlgorithms/Python
beginnerSix hash algorithms from a 13-byte checksum to 256-bit cryptographic digests: each trading reliability for speed differently.
Data Structures in TheAlgorithms/Python
beginnerSeven fundamental data structures side by side: the pointer chain, the key-ordered tree, the self-balancing tree, the heap, the hash table, the union-find, and the prefix tree.
Conversion Algorithms in TheAlgorithms/Python
beginnerSeven base, numeral, and unit conversions showing how repeated division, recursion, lookup tables, and pivot factors each solve the same family of problems.
Bit Manipulation in TheAlgorithms/Python
beginnerSeven techniques that use bitwise operations to count, test, flip, reverse, and encode integers without arithmetic.
String Algorithms in TheAlgorithms/Python
intermediateSeven string search and comparison algorithms from KMP failure arrays to Aho-Corasick automata.
Maths Algorithms in TheAlgorithms/Python
intermediateSeven mathematical algorithms from prime sieves to the Chinese Remainder Theorem.
Geometry Algorithms in TheAlgorithms/Python
intermediateFour stops from primitive shapes to convex hull algorithms, with cross-product orientation as the shared computational primitive.
Matrix Algorithms in TheAlgorithms/Python
intermediateSix matrix operations from elementwise addition to Pascal's triangle generation.
Graph Algorithms in TheAlgorithms/Python
intermediateSeven graph traversal and shortest-path strategies from BFS queues to Prim's greedy expansion.
Backtracking Algorithms in TheAlgorithms/Python
intermediateSeven constraint-satisfaction problems solved by the same pattern: try a placement, recurse, and undo it when the branch fails.
Greedy Algorithms in TheAlgorithms/Python
intermediateFive problems where the locally optimal choice at each step produces the globally optimal result.
Divide and Conquer Algorithms in TheAlgorithms/Python
intermediateSix algorithms that split a problem in half, solve each half independently, and combine the results: from sorting to matrix multiplication to geometry.
Dynamic Programming in TheAlgorithms/Python
intermediateSeven DP patterns from memoized sequences to all-pairs shortest paths.
Linear Algebra Algorithms in TheAlgorithms/Python
intermediateSeven direct solvers and iterative methods, from Gaussian elimination to conjugate gradient, each exposing a different trade-off in numerical linear algebra.
Machine Learning Algorithms in TheAlgorithms/Python
intermediateSeven classical ML algorithms from linear models to kernel machines, each implemented from scratch in plain NumPy.
Neural Networks in TheAlgorithms/Python
intermediateFive files tracing how a network learns: from a single-neuron forward pass to backpropagation, multi-layer weight matrices, and the activation functions that make it possible.
Project Euler Solutions in TheAlgorithms/Python
intermediateThe first seven Project Euler problems, each solved in a single Python function with doctests, showing how mathematical insight reduces brute force to a handful of lines.
Create code tours for your project
Intraview lets AI create interactive walkthroughs of any codebase. Install the free VS Code extension and generate your first tour in minutes.
Install Intraview Free