# kevin-wayne/algs4

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/kevin-wayne-algs4).**

7,519 stars · 2,667 forks · Java · GPL-3.0

## Links

- GitHub: https://github.com/kevin-wayne/algs4
- Homepage: http://algs4.cs.princeton.edu/code/
- awesome-repositories: https://awesome-repositories.com/repository/kevin-wayne-algs4.md

## Description

algs4 is a Java data structures library and algorithm reference collection designed as the source code for a standard computer science textbook curriculum. It provides a comprehensive suite of fundamental implementations for sorting, searching, and core data organization.

The project serves as a graph theory framework, offering tools for representing directed and undirected graphs and performing complex traversals and pathfinding. It also includes a broad sorting algorithm suite and a specialized library of Java data structures, including stacks, queues, priority queues, and symbol tables.

Its capabilities extend to computational geometry for spatial analysis, text processing for indexing and filtering, and statistical tools for data analysis. The library also provides utilities for vector arithmetic, media processing, and algorithmic performance benchmarking to measure execution time and scaling.

## Tags

### Data & Databases

- [Data Structure Implementations](https://awesome-repositories.com/f/data-databases/data-structure-implementations.md) — Provides a comprehensive reference collection of fundamental data structure implementations including stacks, queues, and graphs. ([source](http://algs4.cs.princeton.edu/code/))
- [Indexed](https://awesome-repositories.com/f/data-databases/data-structure-implementations/optimized-data-structures/priority-queues/indexed.md) — Provides an indexed priority queue to efficiently retrieve and update elements associated with integer indices. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/IndexMaxPQ.java.html))
- [Graph Theory](https://awesome-repositories.com/f/data-databases/graph-computing-systems/graph-theory.md) — Offers a mathematical framework for representing graphs and performing traversals and pathfinding.
- [Graph Cycle Detection](https://awesome-repositories.com/f/data-databases/graph-computing-systems/graph-theory/graph-libraries/graph-cycle-detection.md) — Includes algorithms to determine if a directed graph contains cycles. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/DirectedCycle.java.html))
- [Graph Topology Analysis](https://awesome-repositories.com/f/data-databases/graph-topology-analysis.md) — Traverses networks to analyze structural properties such as cycles, strong components, and planarity. ([source](http://algs4.cs.princeton.edu/code/wishlist.txt))
- [Hash Tables](https://awesome-repositories.com/f/data-databases/hash-tables.md) — Implements a hash table symbol table using separate chaining for constant-time key-value lookups. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/SeparateChainingHashST.java.html))
- [Linear Probing Implementations](https://awesome-repositories.com/f/data-databases/hash-tables/linear-probing-implementations.md) — Implements a symbol table using linear probing to resolve hash collisions in an array. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/BinarySearchST.java.html))
- [Adjacency Lists](https://awesome-repositories.com/f/data-databases/list-data-structures/adjacency-lists.md) — Provides an adjacency list implementation for representing graphs and optimizing network traversal.
- [Sorted Sets](https://awesome-repositories.com/f/data-databases/sorted-sets.md) — Implements a sorted integer set using a sorted array for fast membership queries and rank lookups. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/StaticSETofInts.java.html))
- [Negative Cycle Detection](https://awesome-repositories.com/f/data-databases/graph-computing-systems/graph-theory/graph-libraries/graph-cycle-detection/negative-cycle-detection.md) — Identifies negative cycles in directed graphs, useful for finding currency arbitrage opportunities. ([source](http://algs4.cs.princeton.edu/code/javadoc))
- [Full-Text Inverted Indexes](https://awesome-repositories.com/f/data-databases/index-construction/full-text-inverted-indexes.md) — Implements an inverted index that maps individual words to the files containing them for fast document retrieval. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/FileIndex.java.html))
- [User Rank Retrievals](https://awesome-repositories.com/f/data-databases/inventory-tracking/ranked-leaderboards/user-rank-retrievals.md) — Implements rank-based retrieval to locate keys based on their relative order or specific numerical position. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/BST.java.html))
- [Node Reachability Analyses](https://awesome-repositories.com/f/data-databases/node-reachability-analyses.md) — Provides algorithms to determine reachability between nodes in a directed graph using depth-first search. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/DirectedDFS.java.html))
- [Order-Based Lookups](https://awesome-repositories.com/f/data-databases/read-replicas/lock-free-map-structures/symbol-table-managers/order-based-lookups.md) — Provides capabilities to find minimum, maximum, floor, and ceiling keys within sorted symbol tables. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/ST.java.html))
- [Search and Indexing](https://awesome-repositories.com/f/data-databases/search-indexing-technologies/search-indexing/search-and-indexing.md) — Builds inverted indexes and filters text streams to enable fast word retrieval and document search.

### Education & Learning Resources

- [Algorithmic Reference Implementations](https://awesome-repositories.com/f/education-learning-resources/educational-resources/algorithms-theory-academics/cs-theory-foundations/algorithms/general-collections-and-study/algorithmic-reference-implementations.md) — Provides standardized reference implementations of fundamental sorting, searching, and graph algorithms for educational use.
- [Algorithm Reference Libraries](https://awesome-repositories.com/f/education-learning-resources/technical-domain-education/computer-science-education/algorithm-reference-libraries.md) — Serves as a comprehensive collection of standard algorithm implementations and data structures for educational reference.
- [Divide And Conquer Algorithms](https://awesome-repositories.com/f/education-learning-resources/educational-resources/algorithms-theory-academics/cs-theory-foundations/algorithms/algorithmic-paradigms/divide-and-conquer-algorithms.md) — Implements recursive divide-and-conquer algorithms for efficient sorting and searching of data.
- [Graph Traversal Algorithms](https://awesome-repositories.com/f/education-learning-resources/educational-resources/algorithms-theory-academics/cs-theory-foundations/algorithms/data-ordering-and-retrieval/graph-traversal-algorithms.md) — Provides implementations for visiting vertices in graphs using depth-first and breadth-first searches. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/DepthFirstOrder.java.html))
- [Resizable Array Collections](https://awesome-repositories.com/f/education-learning-resources/educational-resources/algorithms-theory-academics/cs-theory-foundations/algorithms/data-ordering-and-retrieval/resizable-array-collections.md) — Provides resizable array collections that maintain amortized constant time for data storage.
- [Balanced Search Trees](https://awesome-repositories.com/f/education-learning-resources/educational-resources/algorithms-theory-academics/cs-theory-foundations/data-structure-implementations/data-structures/balanced-search-trees.md) — Implements self-balancing binary search trees to maintain logarithmic time complexity for membership lookups. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/SET.java.html))
- [AVL Tree Operations](https://awesome-repositories.com/f/education-learning-resources/educational-resources/algorithms-theory-academics/cs-theory-foundations/data-structure-implementations/data-structures/balanced-search-trees/avl-tree-operations.md) — Provides a symbol table implementation using self-balancing AVL trees for efficient key-value retrieval. ([source](http://algs4.cs.princeton.edu/code/javadoc))
- [Graph Algorithm Utilities](https://awesome-repositories.com/f/education-learning-resources/graph-algorithms/graph-algorithm-utilities.md) — Offers auxiliary graph operations including vertex degree calculation and edge management. ([source](http://algs4.cs.princeton.edu/code/javadoc/edu/princeton/cs/algs4/Digraph.html))
- [Connected Component Analysis](https://awesome-repositories.com/f/education-learning-resources/graph-algorithms/graph-connectivity-analysis/connected-component-analysis.md) — Implements algorithms for grouping nodes in undirected graphs into connected components. ([source](http://algs4.cs.princeton.edu/code/javadoc/edu/princeton/cs/algs4/CC.html))
- [Sorting Algorithms](https://awesome-repositories.com/f/education-learning-resources/sorting-algorithms.md) — Includes a wide suite of educational sorting implementations including quicksort, mergesort, and heapsort.
- [Curriculum Implementation Sources](https://awesome-repositories.com/f/education-learning-resources/technical-domain-education/computer-science-education/computer-science-concepts/curriculum-implementation-sources.md) — Provides the full set of source code and libraries used as the implementation reference for a standard algorithms textbook.
- [Algorithmic Performance Comparison](https://awesome-repositories.com/f/education-learning-resources/algorithmic-performance-comparison.md) — Measures execution time and CPU usage to analyze the growth rate and scaling of different algorithms.
- [Network Flow Algorithms](https://awesome-repositories.com/f/education-learning-resources/educational-resources/algorithms-theory-academics/cs-theory-foundations/algorithms/data-ordering-and-retrieval/network-flow-algorithms.md) — Computes maximum flow and minimum-cost flow using network simplex and bipartite matching. ([source](http://algs4.cs.princeton.edu/code/wishlist.txt))
- [Eulerian Tour Algorithms](https://awesome-repositories.com/f/education-learning-resources/eulerian-tour-algorithms.md) — Implements algorithms to identify Eulerian cycles that visit every edge in a directed graph exactly once. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/DirectedEulerianCycle.java.html))

### Programming Languages & Runtimes

- [FIFO Queues](https://awesome-repositories.com/f/programming-languages-runtimes/fifo-queues.md) — Implements a first-in-first-out queue using a resizing array for amortized constant time operations. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/ResizingArrayQueue.java.html))
- [Java Utility Libraries](https://awesome-repositories.com/f/programming-languages-runtimes/java-utility-libraries.md) — Provides a comprehensive library of reference data structures, such as stacks and symbol tables, implemented in Java.
- [LIFO Stacks](https://awesome-repositories.com/f/programming-languages-runtimes/lifo-stacks.md) — Implements a last-in-first-out stack for managing a collection of generic items with constant-time operations. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/Stack.java.html))
- [Heaps](https://awesome-repositories.com/f/programming-languages-runtimes/programming-utilities/data-structure-type-helpers/data-structures/hierarchical-tree-structures/heaps.md) — Implements binary heaps to provide a min-priority queue for efficient removal of the minimum element. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/MinPQ.java.html))
- [Wall-Clock Time Measurement](https://awesome-repositories.com/f/programming-languages-runtimes/wall-clock-time-measurement.md) — Measures total elapsed wall-clock time between timer initialization and request. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/Stopwatch.java.html))

### Scientific & Mathematical Computing

- [Sorted Array Symbol Tables](https://awesome-repositories.com/f/scientific-mathematical-computing/array-sorting-and-partitioning/sorted-array-symbol-tables.md) — Implements a symbol table using sorted arrays to support fast retrieval and range queries. ([source](http://algs4.cs.princeton.edu/code/javadoc/edu/princeton/cs/algs4/BinarySearchST.html))
- [Data Structure Implementations](https://awesome-repositories.com/f/scientific-mathematical-computing/data-structure-implementations.md) — Implements fundamental containers like priority queues, symbol tables, and stacks to manage data efficiently.
- [Graph Pathfinding Algorithms](https://awesome-repositories.com/f/scientific-mathematical-computing/graph-pathfinding-algorithms.md) — Algorithms and Data Structures finds the longest paths from a single source to all other vertices in directed acyclic graphs. ([source](http://algs4.cs.princeton.edu/code/javadoc))
- [Network Graph Analysis](https://awesome-repositories.com/f/scientific-mathematical-computing/network-graph-analysis.md) — Analyzes network topology and computes shortest paths or connectivity in directed and undirected graphs.
- [Shortest Path Algorithms](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/algorithms-and-complexity/algorithms/graph-processing/shortest-path-algorithms.md) — Implements algorithms to calculate paths from a source vertex to all reachable vertices. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/DepthFirstDirectedPaths.java.html))
- [Topological Sorting](https://awesome-repositories.com/f/scientific-mathematical-computing/topological-sorting.md) — Produces a linear ordering of vertices for acyclic directed graphs. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/Topological.java.html))
- [Bipartite Analysis](https://awesome-repositories.com/f/scientific-mathematical-computing/graph-analysis-algorithms/bipartite-analysis.md) — Detects whether an undirected graph is bipartite or contains an odd-length cycle. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/Bipartite.java.html))
- [Inversion Counting Algorithms](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/arithmetic-number-types/multiplication-algorithms/number-theory-algorithms/inversion-counting-algorithms.md) — Implements an inversion counting algorithm using a modified mergesort to identify out-of-order pairs in a sequence. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/Inversions.java.html))
- [Computational Geometry](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/computational-geometry.md) — Provides tools for representing points and intervals to calculate intersections and spatial orientations.
- [Statistical Metric Calculators](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/statistics-probability/statistical-analysis-libraries/statistical-metric-calculators.md) — Calculates mathematical metrics from datasets to analyze trends and patterns in numerical information. ([source](http://algs4.cs.princeton.edu/code/))
- [Online Running Statistics](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/statistics-probability/statistical-analysis-libraries/statistical-metric-calculators/online-running-statistics.md) — Implements one-pass algorithms for tracking mean, sample standard deviation, and variance of a real number stream. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/Accumulator.java.html))
- [Sparse Vector Storage](https://awesome-repositories.com/f/scientific-mathematical-computing/vector-mathematics/n-dimensional-vector-representations/sparse-vector-storage.md) — Implements d-dimensional mathematical vectors using symbol tables of nonzero coordinates to optimize memory. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/SparseVector.java.html))
- [Vector Operations](https://awesome-repositories.com/f/scientific-mathematical-computing/vector-operations.md) — Provides mathematical primitives for vector arithmetic including dot products, addition, and scalar products. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/SparseVector.java.html))

### Software Engineering & Architecture

- [Multiset Implementations](https://awesome-repositories.com/f/software-engineering-architecture/abstract-data-types/generic-data-abstractions/generic-data-structures/multiset-implementations.md) — Implements a generic bag collection as a multiset using a singly linked list. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/Bag.java.html))
- [Disjoint Set Union](https://awesome-repositories.com/f/software-engineering-architecture/disjoint-set-union.md) — Provides a disjoint-set union data structure for tracking and merging non-overlapping sets. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/QuickFindUF.java.html))
- [Hash Tables](https://awesome-repositories.com/f/software-engineering-architecture/hash-tables.md) — Implements hash tables using separate chaining with linked lists to resolve collisions.
- [Heaps](https://awesome-repositories.com/f/software-engineering-architecture/heaps.md) — Implements binary heaps to provide a max-priority queue for extracting the largest element. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/MaxPQ.java.html))
- [Singly](https://awesome-repositories.com/f/software-engineering-architecture/linked-lists/singly.md) — Provides a singly-linked list implementation for constant-time insertion and iteration of generic items.
- [Priority Heaps](https://awesome-repositories.com/f/software-engineering-architecture/priority-heaps.md) — Implements a binary heap to provide efficient extraction of minimum or maximum elements in a priority queue.
- [Sorting Algorithms](https://awesome-repositories.com/f/software-engineering-architecture/sorting-algorithms.md) — Provides high-performance sorting implementations including three-pivot quicksort and Timsort. ([source](http://algs4.cs.princeton.edu/code/wishlist.txt))
- [Quicksorts](https://awesome-repositories.com/f/software-engineering-architecture/sorting-algorithms/quicksorts.md) — Implements an optimized quicksort featuring 3-way partitioning and adaptive pivot selection. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/QuickBentleyMcIlroy.java.html))
- [Sorted Array Merging](https://awesome-repositories.com/f/software-engineering-architecture/sorting-algorithms/sorted-array-merging.md) — Provides a mechanism to merge multiple sorted input streams into a single sorted output using a priority queue. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/Multiway.java.html))
- [Trie Data Structures](https://awesome-repositories.com/f/software-engineering-architecture/trie-data-structures.md) — Uses tries and radix sorts for efficient string storage, sorting, and prefix-based lookups. ([source](http://algs4.cs.princeton.edu/code/wishlist.txt))

### Artificial Intelligence & ML

- [Linear Regression](https://awesome-repositories.com/f/artificial-intelligence-ml/linear-regression.md) — Provides linear regression capabilities to estimate response variables based on predictor values. ([source](http://algs4.cs.princeton.edu/code/javadoc/edu/princeton/cs/algs4/LinearRegression.html))

### Testing & Quality Assurance

- [CPU Time Profiling](https://awesome-repositories.com/f/testing-quality-assurance/cpu-time-profiling.md) — Tracks actual processor time consumed by specific threads to evaluate computational efficiency. ([source](http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/StopwatchCPU.java.html))
