Comprehensive Guide to Algorithms in Python


In the following sections, we touch different categories of algorithms, and implement or realize them using Python language.

Sorting Algorithms

Searching Algorithms

  • Python - Linear Search
  • Python - Binary Search
  • Python - Depth-First Search (DFS)
  • Python - Breadth-First Search (BFS)
  • Python - Dijkstra's Algorithm
  • Python - KMP Algorithm (for pattern matching)
  • Python - Rabin-Karp Algorithm (for pattern matching)

Graph Algorithms

  • Python - Depth-First Search (DFS)
  • Python - Breadth-First Search (BFS)
  • Python - Dijkstra's Algorithm
  • Python - Bellman-Ford Algorithm
  • Python - Floyd-Warshall Algorithm
  • Python - Prim's Algorithm
  • Python - Kruskal's Algorithm
  • Python - Topological Sorting

Dynamic Programming

  • Fibonacci Series
  • Longest Common Subsequence (LCS)
  • Knapsack Problem
  • Coin Change Problem
  • Matrix Chain Multiplication
  • Longest Increasing Subsequence (LIS)
  • Edit Distance
  • Subset Sum
  • 0/1 Knapsack Problem
  • Rod Cutting Problem

Divide and Conquer

  • Merge Sort
  • Quick Sort
  • Binary Search
  • Strassen's Matrix Multiplication
  • Closest Pair of Points
  • Karatsuba Algorithm (for fast multiplication)

Greedy Algorithms

  • Activity Selection
  • Huffman Coding
  • Dijkstra's Algorithm
  • Kruskal's Algorithm
  • Fractional Knapsack Problem

Backtracking

  • N-Queens Problem
  • Sudoku Solver
  • Hamiltonian Cycle
  • Subset Sum
  • Graph Coloring

String Matching Algorithms

  • Brute Force
  • Rabin-Karp Algorithm
  • Knuth-Morris-Pratt (KMP) Algorithm
  • Boyer-Moore Algorithm
  • Trie Data Structure

Number Theory

  • Euclidean Algorithm (for GCD)
  • Sieve of Eratosthenes (for Prime Numbers)
  • Extended Euclidean Algorithm
  • Modular Exponentiation
  • Chinese Remainder Theorem (CRT)

Computational Geometry

  • Convex Hull
  • Line Sweep Algorithm
  • Graham's Scan
  • Closest Pair of Points
  • Polygon Triangulation