TheAlgorithms Python

repository·master·Indexed 11 days ago

https://github.com/thealgorithms/python

A collection of various algorithm implementations in Python, including data structures (binary tree traversals), linear algebra (Vector and Matrix classes), hashing algorithms (MD5, SHA-256, Luhn), blockchain and DLT concepts, cellular automata, and solutions for Project Euler problems.

Tokens
13K
Snippets
14
Records
76
Agent score
99%

What's inside TheAlgorithms Python

  1. Overview of Conversion algorithms

    master

    The conversions module provides algorithms for transforming data between different formats, numerical bases, or units. Common use cases include:

    • Numerical Base Conversion: Converting numbers between bases (e.g., binary to decimal).
    • Data Type Conversion: Converting between data types (e.g., integer to string).
    • Unit Conversion: Converting between physical units (e.g., feet to meters).
  2. Overview of Cellular Automata

    master
    Cellular automata are mathematical models used to simulate the behavior of complex systems (like biological cells or robotic behaviors) using simple, local rules. These rules, when applied iteratively to a grid of cells, can lead to the emergence of complex, organized forms. A primary example of this phenomenon is Conway's Game of Life.
  3. Explore Dynamic Programming algorithms

    master

    The dynamic_programming directory contains implementations of various optimization and combinatorial problems. Key algorithms available include:

    • String/Sequence Matching: edit_distance.py, longest_common_subsequence.py, longest_common_substring.py, regex_match.py, wildcard_matching.py, word_break.py.
    • Optimization/Resource Allocation: knapsack.py, rod_cutting.py, minimum_coin_change.py, matrix_chain_multiplication.py.
    • Pathfinding/Grid: min_distance_up_bottom.py, minimum_cost_path.py, trapped_water.py.
    • Mathematical/Sequence: fibonacci.py, catalan_numbers.py, factorial.py, tribonacci.py.
    • Subsequence/Subset: longest_increasing_subsequence.py, subset_generation.py, sum_of_subset.py.
  4. Explore Matrix algorithms

    master

    The matrix/ directory provides implementations for various matrix-based operations and problems, such as:

    • Core Operations: Matrix Multiplication (Recursive), Matrix Inversion, Matrix Class, and Matrix Operations.
    • Search & Traversal: Binary Search in Matrix, Searching in Sorted Matrix, Spiral Print, and Counting Islands.
    • Mathematical Rules: Cramer's Rule (2x2) and Sherman-Morrison formula.
    • Problem Solving: Pascal's Triangle, Rotating a Matrix, Validating Sudoku Boards, and finding the Largest Square Area in a Matrix.
  5. Explore Graph algorithms

    master

    The graphs directory is a comprehensive collection of graph theory and traversal algorithms:

    • Traversals: breadth_first_search.py, depth_first_search.py, bidirectional_search.py.
    • Shortest Path: dijkstra.py, bellman_ford.py, a_star.py, johnson.py.
    • Spanning Trees: kruskal.py, prims.py, boruvka.py.
    • Connectivity & Cycles: check_cycle.py, connected_components.py, scc_kosaraju.py, tarjans_scc.py.
    • Topological Sort: kahns_algorithm_topo.py, g_topological_sort.py.
    • Flow & Matching: dinic.py, edmonds_karp_multiple_source_and_sink.py, gale_shapley_bigraph.py.
    • Data Structures: graph_adjacency_list.py, graph_adjacency_matrix.py.
  6. Explore Data Structures in Python

    master

    The repository contains a comprehensive collection of data structure implementations. You can find implementations for:

    • Arrays: Including Equilibrium Index In Array, Kth Largest Element, Prefix Sum, and Sparse Table.
    • Binary Trees: Including Avl Tree, Binary Search Tree, Red Black Tree, Segment Tree, and Treap.
    • Hashing: Including Bloom Filter, Hash Map, and Hash Table.
    • Heaps: Including Binomial Heap, Max Heap, Min Heap, and Skew Heap.
    • Linked Lists: Including Circular Linked List, Doubly Linked List, and Singly Linked List.
    • Queues & Stacks: Including Circular Queue, Priority Queue, Stack, and Deque.
    • Specialized Structures: Such as Kd Tree, Suffix Tree, Trie, and Radix Tree.
    • Disjoint Sets: Including Disjoint Set implementations.
  7. Get started with The Algorithms - Python

    master

    The Algorithms - Python is an educational repository containing various algorithm implementations in Python.

    Important Note: These implementations are intended for learning purposes only. They may be less efficient than the optimized implementations found in the Python standard library. Use them at your discretion for educational study rather than production environments.

    To begin using or contributing to the project:

    1. Review the Contribution Guidelines to understand the project's standards and processes.
    2. Use the Directory to navigate the various algorithm implementations available in the repository.
  8. Explore Mathematics algorithms

    master

    The maths/ directory contains a wide range of mathematical implementations, including:

    • Basic Arithmetic & Number Theory: Factorials, GCD, LCM, Prime Sieve (Eratosthenes, Segmented, Odd), and Primality Tests (Lucas Lehmer, Solovay Strassen).
    • Numerical Analysis: Root-finding (Bisection, Newton Raphson, Secant, Weierstrass) and Integration (Simpson Rule, Trapezoidal Rule, Runge Kutta).
    • Geometry & Trigonometry: Area, Volume, Arc Length, Euclidean/Manhattan/Chebyshev distances, and Trigonometric functions (Sin, Tanh, Sigmoid).
    • Special Numbers: Armstrong, Catalan, Fibonacci, Happy, and Triangular numbers.
    • Probability & Statistics: Binomial Distribution, Entropy, Geometric Mean, and Spearman Rank Correlation.
    • Series: Arithmetic, Geometric, Harmonic, and P Series.
    • Polynomials: Single Indeterminate Operations.

    Each algorithm is implemented as a standalone Python script within the maths/ directory or its subdirectories.

  9. Explore Financial algorithms

    master

    The financial directory contains algorithms for common financial calculations:

    • Interest & Value: interest.py, present_value.py.
    • Moving Averages: exponential_moving_average.py, simple_moving_average.py.
    • Payments & Depreciation: equated_monthly_installments.py, straight_line_depreciation.py, time_and_half_pay.py.
    • Taxation: price_plus_tax.py.
  10. Explore Sorting Algorithms

    master
    This section of the repository provides implementations of various sorting algorithms in Python. Sorting algorithms are used to arrange data in specific orders (typically lexical or numerical) to optimize data searching and improve data readability. You can find implementations for various scenarios within the sorts/ directory.
  11. Explore Digital Image Processing algorithms

    master

    The digital_image_processing module provides various algorithms for manipulating and analyzing images. Key capabilities include:

    • Basic Adjustments: Change Brightness, Change Contrast, Convert To Negative, and Sepia.
    • Filters: Bilateral Filter, Gaussian Filter, Median Filter, Sobel Filter, and Laplacian Filter.
    • Edge Detection: Canny edge detection.
    • Morphological Operations: Dilation Operation and Erosion Operation.
    • Histogram Operations: Histogram Stretch for equalization.
    • Geometric Transformations: Resize and Rotation.
    • Dithering: Burkes dithering algorithm.