Skip to content
CAI
Software that uses CAICheck a score

trekhleb/javascript-algorithms

63.0

Adequate · 1 October 2026

10.6k

lines of production code

JavaScript

primary language

2

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This system is a comprehensive JavaScript library implementing fundamental data structures and algorithms. It provides concrete implementations for linear and tree-based structures like linked lists, heaps, and binary search trees, alongside a wide array of algorithmic solutions for graph traversal, sorting, searching, and mathematical computations. The codebase is designed for educational and practical use, featuring extensive multilingual documentation and rigorous test coverage for all components.

How it got here

2018 — comprehensive data structures and algorithms expansion

100 changes.

This period focused on significantly expanding the library's coverage by implementing a wide array of new data structures, including linked lists, stacks, queues, heaps, tries, graphs, and various tree types. It also introduced numerous algorithms for sorting, searching, graph traversal, dynamic programming, and mathematical computations, each accompanied by comprehensive unit tests and multilingual documentation.

2019–2026 — expansion of algorithm and data structure library

17 changes.

This period focused on significantly expanding the project's algorithm and data structure library by adding implementations for mathematics, cryptography, machine learning, and image processing. It also introduced core data structures such as LRU Cache and Deque, alongside establishing code quality standards through Husky pre-commit linting.

Features

Add Bellman-Ford shortest path algorithm

Added the Bellman-Ford algorithm implementation, which computes shortest paths from a single source vertex to all other vertices in a weighted digraph. This new capability handles graphs with negative edge weights, distinguishing it from algorithms like Dijkstra's. The addition includes the core implementation, a comprehensive test suite covering both undirected and directed graphs with negative weights, and documentation detailing the algorithm's complexity and references.

src/algorithms/graph/bellman-ford · high confidence

Add Breadth-First Search algorithm with customizable traversal callbacks

A new Breadth-First Search (BFS) implementation has been added to the graph algorithms library. This feature allows users to traverse graph data structures starting from a specified vertex, exploring neighbor nodes before moving to the next level. The implementation supports optional callbacks for \enterVertex\ and \leaveVertex\ events, enabling custom logic during traversal, as well as an \allowTraversal\ callback to control which edges are traversed, providing fine-grained control over the search behavior.

src/algorithms/graph/breadth-first-search · high confidence

Add Breadth-First and Depth-First Search algorithms for trees

New Breadth-First Search (BFS) and Depth-First Search (DFS) implementations have been added to the tree algorithms library. Both algorithms support customizable traversal logic through optional callbacks, allowing users to define custom behavior when entering or leaving nodes, as well as the ability to conditionally allow or forbid traversal to specific child nodes.

src/algorithms/tree · high confidence

Add Caesar Cipher implementation with encryption and decryption

This change introduces a new Caesar Cipher algorithm to the cryptography module, providing \caesarCipherEncrypt\ and \caesarCipherDecrypt\ functions. The implementation supports case-insensitive encryption, handles negative shifts for decryption, preserves non-alphabetic characters, and allows for custom alphabets. Comprehensive tests verify correct behavior for various shift values, empty strings, and full phrases, accompanied by English and Russian documentation.

src/algorithms/cryptography/caesar-cipher · high confidence

Add Cartesian Product algorithm and tests

Added a new Cartesian Product function that generates all ordered pairs from two input sets, returning null if either set is empty or invalid. The change includes the implementation, unit tests verifying correct pair generation and null handling, and documentation explaining the mathematical concept.

src/algorithms/sets/cartesian-product · high confidence

Add Combination Sum backtracking algorithm

A new backtracking algorithm has been added to find all unique combinations of candidate numbers that sum to a specific target. The implementation allows candidates to be reused unlimited times and ensures the solution set contains no duplicate combinations, accompanied by documentation and unit tests.

src/algorithms/sets/combination-sum · high confidence

Add Deque data structure with O(1) double-ended operations

A new Deque (double-ended queue) implementation is available in src/data-structures/deque, backed by a DoublyLinkedList to ensure that adding or removing elements from both the front and back runs in O(1) time. The module provides methods for addFront, addBack, removeFront, removeBack, peekFront, peekBack, isEmpty, and a size property, along with utility methods to convert the structure to an array or string. Comprehensive tests verify queue, stack, and mixed usage patterns, as well as correct size tracking and handling of object values.

src/data-structures/deque · high confidence

Add Dijkstra's shortest-path algorithm with multilingual documentation

Users can now find shortest paths in weighted graphs using the new Dijkstra algorithm implementation in \src/algorithms/graph/dijkstra/dijkstra.js\, which calculates distances from a source node to all others and reconstructs paths via predecessor tracking. The feature is supported by comprehensive, step-by-step documentation and illustrations in ten languages (English, German, Spanish, French, Hebrew, Japanese, Korean, Ukrainian, Simplified Chinese, and Traditional Chinese) to help users understand the priority-queue-based traversal and path-reconstruction logic.

src/algorithms/graph/dijkstra · high confidence

Add Disjoint Set (Union-Find) data structure implementation

Added a new Disjoint Set (also known as Union-Find) data structure to the library, available in two forms: a full-featured \DisjointSet\ class supporting custom key callbacks and union-by-rank, and a minimalistic \DisjointSetAdhoc\ class optimized for coding interviews with path compression and union-by-height. The implementation includes core operations like \makeSet\, \find\, \union\, and \inSameSet\/\connected\, along with documentation in English, Russian, Portuguese (Brazil), and Ukrainian.

src/data-structures/disjoint-set · high confidence

Add Doubly Linked List data structure

The DoublyLinkedList class is now available in src/data-structures/doubly-linked-list, providing a linked data structure where each node contains references to both the next and previous nodes. This implementation supports bidirectional traversal and includes methods for prepending, appending, deleting specific values or ends (head/tail), and finding nodes by value or callback. The change also introduces the DoublyLinkedListNode class and adds comprehensive documentation in English, Spanish, Japanese, Korean, Portuguese, Russian, Ukrainian, and Simplified Chinese.

(repo-wide) · high confidence

Add Euclidean algorithm, iterative variant, and LCM calculation

This change introduces the Euclidean algorithm for computing the greatest common divisor (GCD) in both recursive and iterative forms, along with a new least common multiple (LCM) function that leverages the GCD implementation. Users can now calculate GCDs for positive and negative integers using either approach, and compute LCMs, with comprehensive test coverage and documentation provided for all three functions.

src/algorithms/math/euclidean-algorithm · high confidence

Add Eulerian Path algorithm

Users can now find an Eulerian path or circuit in a graph using Fleury's algorithm. The new \eulerianPath\ function analyzes vertex degrees to determine if the graph is Eulerian (all even degrees) or semi-Eulerian (exactly two odd-degree vertices), throwing an error if neither condition is met. It returns an array of vertices representing the trail that visits every edge exactly once, starting from an appropriate vertex (an odd-degree vertex for paths, any vertex for circuits).

(repo-wide) · high confidence

Add Fast Powering algorithm with French documentation

Users can now compute exponentiation using a recursive fast powering algorithm that reduces time complexity from O(n) to O(log(n)) by leveraging a divide-and-conquer approach. This new capability includes the JavaScript implementation, a corresponding test suite, and documentation in both English and French.

src/algorithms/math/fast-powering · high confidence

Add Fenwick Tree (Binary Indexed Tree) implementation

A new Fenwick Tree data structure is now available in the library, providing efficient O(log n) time complexity for both element updates and prefix sum calculations. The implementation includes methods to increase values at specific positions, query sums from the start to a given index, and query sums within a specific range, along with corresponding documentation in English and Portuguese.

src/data-structures/tree/fenwick-tree · high confidence

Add Floyd-Warshall algorithm for all-pairs shortest paths

The Floyd-Warshall algorithm has been added to the graph algorithms library, enabling users to calculate the shortest paths between all pairs of vertices in a weighted graph. This implementation supports both directed and undirected graphs, as well as graphs containing negative edge weights (provided there are no negative cycles). The algorithm returns a matrix of distances and a matrix of next-hop vertices, allowing users to reconstruct the actual paths. Comprehensive tests verify its correctness on various graph structures, including those with disconnected components and negative weights.

src/algorithms/graph/floyd-warshall · high confidence

Add Fourier Transform algorithms and documentation

The Fourier transform section now includes implementations for the Discrete Fourier Transform (DFT), Fast Fourier Transform (FFT), and Inverse Discrete Fourier Transform (IDFT), along with comprehensive test suites and bilingual (English and French) documentation explaining the mathematical concepts and usage.

src/algorithms/math/fourier-transform · high confidence

Add Hill Cipher encryption support

Added a new Hill Cipher implementation in the cryptography algorithms section. Users can now encrypt messages using a key string via the \hillCipherEncrypt\ function, which validates that inputs contain only letters and that the key length is a valid square of the message length. The decryption method (\hillCipherDecrypt\) is currently a placeholder that throws an error, as it is not yet implemented. Documentation and unit tests for the encryption logic are also included.

src/algorithms/cryptography/hill-cipher · high confidence

Add Horner's Method for polynomial evaluation

Added a new Horner's Method implementation for evaluating polynomials, which reduces the number of required operations compared to the traditional power-based approach. The update includes the core algorithm, a reference classic implementation for comparison, corresponding unit tests, and documentation explaining the mathematical identity and usage.

src/algorithms/math/horner-method · high confidence

Add Jump Game algorithm solutions

Added four implementations for the Jump Game problem in \src/algorithms/uncategorized/jump-game\: a backtracking approach, top-down and bottom-up dynamic programming strategies, and a greedy algorithm, along with their corresponding unit tests and documentation.

src/algorithms/uncategorized/jump-game · high confidence

Add Jump Search algorithm for sorted arrays

A new Jump Search (Block Search) algorithm has been added to the search module, providing an O(√n) time complexity alternative to linear search for sorted arrays. The implementation supports both primitive values and custom objects via an optional comparator callback, and includes comprehensive test coverage for various search scenarios.

src/algorithms/search/jump-search · high confidence

Add Knight's Tour algorithm implementation

Added a new algorithm in the uncategorized section that solves the Knight's Tour problem using backtracking. The implementation accepts a board size and returns the sequence of moves for an open tour starting at the top-left corner, or an empty array if no solution exists (e.g., on a 3x3 board). This includes the core logic, unit tests verifying behavior on 3x3 and 5x5 boards, and documentation explaining the problem and its relation to the Hamiltonian path problem.

src/algorithms/uncategorized/knight-tour · high confidence

Add Kruskal's algorithm for minimum spanning trees

Users can now compute the minimum spanning tree (or minimum spanning forest for disconnected graphs) of a weighted, undirected graph using Kruskal's greedy algorithm. The implementation validates that the input graph is undirected, throwing an error for directed graphs, and returns a new graph containing the selected edges. This change includes the core algorithm logic, a comprehensive test suite verifying correct tree construction and error handling, and documentation in both English and Korean.

src/algorithms/graph/kruskal, src/algorithms/graph/prim · high confidence

Add Levenshtein Distance algorithm implementation

Added a new Levenshtein Distance algorithm to the string algorithms library. This feature calculates the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one string into another, using a dynamic programming approach. The addition includes the core implementation, a comprehensive test suite covering various edge cases, and detailed documentation explaining the mathematical definition, examples, and the dynamic programming logic.

(repo-wide) · high confidence

Add Liu Hui's π approximation algorithm

Introduces a new mathematical utility in src/algorithms/math/liu-hui that approximates π using Liu Hui's iterative polygon-bisection method. The implementation (liuHui.js) accepts a split count to determine polygon complexity (from 12-gon up to 201326592-gon), accompanied by a test suite verifying accuracy and a README explaining the historical and mathematical context.

src/algorithms/math/liu-hui · high confidence

Add Longest Common Substring algorithm with Unicode support

Introduces a new \longestCommonSubstring\ function that finds the longest common substring between two strings using a dynamic programming approach. The implementation correctly handles Unicode characters by converting input strings into arrays before processing, ensuring accurate length calculations for multi-byte symbols. A corresponding test suite verifies functionality with both standard ASCII and complex Unicode inputs.

src/algorithms/string/longest-common-substring · high confidence

Add N-Queens algorithm implementations

Added new N-Queens algorithm solutions to the uncategorized algorithms library. This includes a backtracking solution in \nQueens.js\ that returns all valid board configurations using a \QueenPosition\ helper class, and a performance-optimized bitwise solution in \nQueensBitwise.js\ that counts the number of valid solutions for a given board size. Documentation explaining the naive, backtracking, and bitwise approaches has also been added.

src/algorithms/sets/longest-common-subsequence, src/algorithms/sets/maximum-subarray, src/algorithms/uncategorized/n-queens · high confidence

Add Pascal's Triangle algorithm implementations

Added two new implementations for generating Pascal's Triangle coefficients: an iterative approach in \pascalTriangle.js\ that calculates entries in O(n) time using a multiplicative formula, and a recursive approach in \pascalTriangleRecursive.js\ that builds each line based on the previous one. Both functions accept a zero-based line number and return an array of integers representing that row's coefficients, accompanied by documentation and test coverage for both methods.

src/algorithms/math/pascal-triangle · high confidence

Add Polynomial Hash and Simple Polynomial Hash implementations

Added two new classes to the cryptography algorithms library: \PolynomialHash\, which implements a rolling hash with configurable base and modulus to prevent overflow, and \SimplePolynomialHash\, a simpler version without modulo operations intended for educational purposes. Both classes provide \hash()\ and \roll()\ methods for computing and updating string fingerprints efficiently, accompanied by documentation and unit tests.

src/algorithms/cryptography/polynomial-hash · high confidence

Add Priority Queue data structure with localization

Introduces a new Priority Queue implementation in src/data-structures/priority-queue/PriorityQueue.js, which extends MinHeap to support element prioritization via a custom Comparator and includes methods for adding, removing, and changing item priorities. This addition is accompanied by the initial documentation for the data structure, including the main English README and localized versions in French, Japanese, Korean, Portuguese (Brazilian), Russian, Ukrainian, and Simplified Chinese.

src/data-structures/priority-queue · high confidence

Add Queue data structure implementation and documentation

Added a new Queue data structure implemented in JavaScript (src/data-structures/queue/Queue.js) using a LinkedList as the underlying storage. The implementation supports standard FIFO operations: enqueue (add to rear), dequeue (remove from front), peek (view front element), isEmpty, and toString. Alongside the code, documentation has been added in multiple languages including English, French, Japanese, Korean, Portuguese (Brazil), Russian, Ukrainian, Vietnamese, and Simplified Chinese, providing explanations of the Queue concept, its FIFO nature, and usage examples.

src/data-structures/queue · high confidence

Add QuickSort and QuickSortInPlace implementations

Users can now sort arrays using the QuickSort algorithm, available in two variants: a standard version that returns a new sorted array without modifying the input, and an in-place version that sorts the array directly. Both implementations are provided in src/algorithms/sorting/quick-sort/ along with documentation in English, Portuguese, and Chinese.

src/algorithms/sorting/quick-sort · high confidence

Add Rabin-Karp string search algorithm

A new Rabin-Karp algorithm implementation has been added to the string algorithms library. This feature enables efficient pattern matching within text using a rolling hash function (specifically a polynomial hash) to identify occurrences of a search word, including a verification step to handle hash collisions. A corresponding README documenting the algorithm's theory, complexity, and applications is also included.

src/algorithms/string/knuth-morris-pratt, src/algorithms/string/rabin-karp · high confidence

Add Radix Sort and Bucket Sort algorithms

This change introduces two new sorting algorithms to the library: Radix Sort and Bucket Sort. Radix Sort is implemented as a non-comparative algorithm that sorts both integers and strings by processing individual digits or characters, supporting configurable passes based on the longest element. Bucket Sort is added as a new algorithm that distributes elements into a specified number of buckets (defaulting to 1) and sorts each bucket using the newly added Radix Sort implementation. Both algorithms include comprehensive test coverage and documentation explaining their complexity and usage.

src/algorithms/sorting/radix-sort · high confidence

Add Rain Terraces algorithm with brute-force and dynamic programming solutions

Users can now calculate the amount of water trapped after rain using the new Rain Terraces (Trapping Rain Water) algorithm in the uncategorized section. This addition includes two implementation approaches: a brute-force solution with O(n²) time complexity and an optimized dynamic programming solution with O(n) time complexity, both accompanied by comprehensive test suites and documentation.

src/algorithms/uncategorized/rain-terraces · high confidence

Add Recursive Staircase algorithm with four solution approaches

Added the Recursive Staircase problem to the uncategorized algorithms section, providing four distinct implementations: a Brute Force recursive solution, a Recursive solution with Memoization, a Dynamic Programming approach, and an Iterative solution. Each implementation includes corresponding unit tests to verify the calculation of the number of ways to climb a staircase of n steps.

src/algorithms/uncategorized/recursive-staircase · high confidence

Add Red-Black Tree data structure with insertion support

A new Red-Black Tree implementation has been added to the data structures library, extending the existing Binary Search Tree. This update introduces self-balancing capabilities via node coloring and rotations during insertion, ensuring O(log n) search and insert performance. The implementation currently supports insertion and balancing logic but throws an error if removal is attempted, as the delete method is not yet implemented. Documentation for the structure, its properties, and balancing cases is provided in both English and Portuguese.

src/data-structures/tree/red-black-tree · high confidence

Add Seam Carving algorithm for content-aware image resizing

A new Seam Carving implementation has been added to the image-processing module, enabling content-aware image resizing that preserves important visual elements by removing low-energy seams. The feature includes a \resizeImageWidth\ function that uses dynamic programming to efficiently find and remove these seams, along with supporting utilities for pixel energy calculation and image data manipulation. Documentation in both English and Russian explains the algorithm's approach to object removal and proportion preservation, and unit tests verify the resizing logic against reference images.

src/algorithms/image-processing · high confidence

Add Segment Tree data structure with generic range queries

Added a new Segment Tree implementation that supports configurable binary operations (such as min, max, and sum) for efficient range queries. The structure handles arrays of any length by padding to the next power of two, and includes documentation in English and Portuguese along with comprehensive test coverage.

src/data-structures/tree/segment-tree · high confidence

Add Shellsort algorithm implementation and documentation

Added a new Shellsort implementation in src/algorithms/sorting/shell-sort/ShellSort.js, including English and Brazilian Portuguese READMEs that explain the algorithm's mechanics, complexity, and references. The JavaScript class extends the base Sort class, implements the gap-based sorting logic, and supports visiting callbacks for visualization or tracing.

src/algorithms/sorting/shell-sort · high confidence

Add Stack data structure with multi-language documentation

The Stack data structure is now available in src/data-structures/stack, implemented in Stack.js using an underlying LinkedList to support push, pop, peek, isEmpty, and utility methods. This addition is accompanied by README documentation in English and translations for French (fr-FR), Japanese (ja-JP), Korean (ko-KR), Portuguese (pt-BR), Russian (ru-RU), Ukrainian (uk-UA), Vietnamese (vi-VN), and Simplified Chinese (zh-CN) to help users understand the LIFO behavior and operations in their preferred language.

src/data-structures/hash-table, src/data-structures/stack · high confidence

Add Trie data structure implementation with multilingual documentation

This change introduces the Trie (prefix tree) data structure to the library, providing core operations for managing string-based keys: adding words, deleting words, checking for existence, and suggesting next characters. The implementation uses a HashTable for efficient child-node lookups within TrieNode. Alongside the JavaScript source files (Trie.js and TrieNode.js), documentation is added in English, Simplified Chinese, Russian, Portuguese (Brazilian), Ukrainian, and Korean to support a global audience.

src/data-structures/trie · high confidence

Add Weighted Random algorithm

A new Weighted Random algorithm has been added to the statistics section. This function selects an item from a list based on associated weights, ensuring that items with higher weights are picked more frequently. It uses a cumulative weight approach for efficiency and includes validation to ensure items and weights arrays match in size and are not empty.

src/algorithms/statistics · high confidence

Add Z-algorithm for linear-time pattern matching

Introduces a new Z-algorithm implementation that finds all occurrences of a pattern within a text in linear time O(\|W\| + \|T\|). The module exports a function that returns an array of starting indices where the pattern appears in the text, accompanied by a README explaining the algorithm's logic and complexity, and a test suite verifying correct position detection.

src/algorithms/string/z-algorithm · high confidence

Add binary search algorithm with multilingual documentation

Added the binary search algorithm implementation (binarySearch.js) which supports both primitive values and custom objects via an optional comparator callback, along with corresponding unit tests and README documentation in English, Spanish (es-ES), and Portuguese (pt-BR).

src/algorithms/search/binary-search · high confidence

Add brute-force Travelling Salesman Problem solver

A new brute-force algorithm for the Travelling Salesman Problem has been added to the graph algorithms library. This feature allows users to find the shortest possible route visiting a set of cities and returning to the start by exhaustively checking all possible paths. The implementation includes the core logic in \bfTravellingSalesman.js\, comprehensive unit tests in \\_\test\\_/bfTravellingSalesman.test.js\, and documentation in \README.md\.

src/algorithms/graph/travelling-salesman · high confidence

Add complex number arithmetic and polar form support

The complex-number module now provides a new ComplexNumber class that supports basic arithmetic operations (addition, subtraction, multiplication, and division) as well as conjugate calculation. It also introduces the ability to convert complex numbers into their polar form, exposing the radius (modulus) and phase (argument) in either radians or degrees. Comprehensive tests verify these calculations, including edge cases like pure real/imaginary numbers and the imaginary unit i.

src/algorithms/math/complex-number · high confidence

Add cycle detection algorithms for directed and undirected graphs

New algorithms have been added to the graph module to detect cycles in both directed and undirected graphs. For directed graphs, \detectDirectedCycle\ uses Depth First Search (DFS) to identify cycles and returns the specific path of vertices forming the cycle. For undirected graphs, two approaches are provided: \detectUndirectedCycle\ also uses DFS to return the cycle path, while \detectUndirectedCycleUsingDisjointSet\ uses a Disjoint Set Union (DSU) approach to simply return a boolean indicating whether a cycle exists. Comprehensive tests and documentation (README) are included for these new capabilities.

src/algorithms/graph/detect-cycle · high confidence

Add degree/radian conversion algorithms

Added \degreeToRadian\ and \radianToDegree\ functions in \src/algorithms/math/radian\ to convert angles between degrees and radians, along with corresponding unit tests and documentation.

src/algorithms/math/radian · high confidence

Add dynamic programming algorithm for longest increasing subsequence

A new dynamic programming implementation for the longest increasing subsequence problem has been added, providing an O(n²) solution to find the length of the longest sorted subsequence within a given sequence. This feature includes the core algorithm logic, a corresponding test suite verifying correctness against various input patterns, and documentation detailing the complexity and usage examples.

src/algorithms/sets/longest-increasing-subsequence · high confidence

Add factorial algorithm implementations and documentation

This change introduces the factorial algorithm to the math section, providing both an iterative (factorial.js) and a recursive (factorialRecursive.js) implementation in JavaScript, along with corresponding unit tests. It also adds comprehensive documentation in multiple languages, including English, Chinese (zh-CN), French (fr-FR), Georgian (ka-GE), Turkish (tr-TR), and Ukrainian (uk-UA), ensuring users can understand the mathematical concept and usage across different locales.

src/algorithms/math/factorial · high confidence

Add four algorithmic solutions for the Best Time to Buy and Sell Stock problem

The \best-time-to-buy-sell-stocks\ module now includes four distinct implementations to calculate maximum stock trading profit: a Divide and Conquer approach (O(2^n)), a Peak Valley approach (O(n)), an Accumulator approach (O(n)), and a Dynamic Programming approach (O(n)). Each solution is provided as a standalone JavaScript module with corresponding unit tests that verify correctness and track iteration counts via a visitor callback, accompanied by a README explaining the logic and complexity of each method.

src/algorithms/uncategorized/best-time-to-buy-sell-stocks · high confidence

Add k-Means clustering and k-Nearest Neighbors algorithms

New machine learning algorithms are now available in the library: k-Means clustering for unsupervised grouping of data vectors into clusters, and k-Nearest Neighbors (k-NN) for supervised classification of new data points based on their proximity to labeled training data. Both implementations include full source code, unit tests, and documentation in English and Brazilian Portuguese.

src/algorithms/ml · high confidence

Add linear search algorithm with multi-type support

Introduces a new linear search implementation that returns all indices of matching elements in an array. The function supports searching for numbers, strings, and objects (via an optional comparator callback), and includes documentation in English and Brazilian Portuguese along with corresponding unit tests.

src/algorithms/search/linear-search · high confidence

Add linked list traversal and reverse traversal algorithms

Added new algorithm implementations for traversing a linked list in both forward and reverse order, including the core JavaScript functions, corresponding unit tests, and localized documentation in English, Russian, Portuguese, and Chinese.

src/algorithms/linked-list · high confidence

Add matrix operations and Euclidean distance algorithm

This change introduces a new Matrix utility module in src/algorithms/math/matrix, providing core linear algebra operations including matrix multiplication (dot product), transposition, shape validation, and generation of zero or custom-filled matrices. It also adds a new Euclidean Distance algorithm that calculates the distance between two matrices, leveraging the new Matrix utilities for shape validation and traversal, along with comprehensive test coverage for both the matrix operations and the distance calculation.

src/algorithms/math/matrix · high confidence

Add power-of-two detection algorithms

Added two new functions, \isPowerOfTwo\ and \isPowerOfTwoBitwise\, to determine if a positive integer is a power of two. The first uses a naive division approach, while the second uses a bitwise operation for efficiency; both correctly handle edge cases like zero and negative numbers.

src/algorithms/math/is-power-of-two · high confidence

Add square root algorithm using Newton's method

A new square root function has been added to the math algorithms library, implementing Newton's method to approximate the principal square root of non-negative numbers. The function accepts an optional tolerance parameter to control precision, allowing users to specify the number of decimal places required in the result. It throws an error for negative inputs and handles zero as a special case.

src/algorithms/math/square-root · high confidence

Add topological sorting algorithm for directed acyclic graphs

A new topological sort implementation has been added to the graph algorithms library, allowing users to generate a linear ordering of vertices in a directed acyclic graph (DAG) where every directed edge goes from an earlier to a later vertex. The algorithm is implemented in \topologicalSort.js\ using a depth-first search approach with a stack to record the final order, and includes a test suite verifying correct sorting on a multi-vertex graph structure.

src/algorithms/graph/topological-sorting · high confidence

Added Comparator utility for flexible value comparison

A new Comparator class has been added to src/utils/comparator, providing a reusable utility for comparing values. It supports a default comparison for strings and numbers, allows passing custom comparison functions, and includes methods for equality, less-than, greater-than, and their inclusive variants, as well as a reverse function to invert comparison order. Tests confirm its behavior with both default and custom comparators.

src/utils · high confidence

Added Depth-First Search algorithm for graphs

A new Depth-First Search (DFS) implementation has been added to the graph algorithms library. The \depthFirstSearch.js\ module provides a recursive traversal function that accepts a graph and a starting vertex, along with optional callbacks to control traversal logic (such as preventing revisits) and monitor entry/exit events at each vertex. A corresponding README has been added to document the algorithm and provide references.

src/algorithms/graph/depth-first-search · high confidence

Added Fisher-Yates shuffle algorithm

A new Fisher-Yates shuffle implementation has been added to the sets algorithms library. This function generates an unbiased random permutation of a finite sequence by shuffling elements in place (on a clone of the input array) with time complexity proportional to the number of items. The addition includes the core implementation, a README explaining the algorithm's behavior, and unit tests verifying that the output is a valid permutation of the input.

src/algorithms/sets/fisher-yates · high confidence

Added LRU Cache implementations with Map and Doubly-Linked List variants

The LRU Cache module now includes two distinct implementation examples: a standard version using a HashMap and Doubly-Linked List for O(1) operations, and a simpler version leveraging JavaScript's ordered Map object. Documentation has been updated to explain both approaches, including a new Korean (ko-KR) translation of the README.

src/data-structures/lru-cache · high confidence

Added Palindrome Check algorithm with documentation and tests

Introduced a new \isPalindrome\ function in the string algorithms module that determines whether a given string reads the same forwards and backwards using a two-pointer approach. The addition includes a README file explaining the concept with examples and a test suite verifying correct identification of both palindromic and non-palindromic strings.

src/algorithms/string/palindrome · high confidence

Added Power Set algorithm implementations

The \src/algorithms/sets/power-set\ directory now includes three distinct implementations for generating a power set: a bitwise solution (\bwPowerSet\), a backtracking solution (\btPowerSet\), and a cascading solution (\caPowerSet\). Each implementation is accompanied by its own test suite and documentation in the README, providing users with multiple algorithmic approaches to compute all subsets of a given set.

src/algorithms/sets/power-set · high confidence

Added Sieve of Eratosthenes algorithm implementation

A new implementation of the Sieve of Eratosthenes algorithm has been added to the math library, allowing users to find all prime numbers up to a specified limit. The solution includes the core logic in \sieveOfEratosthenes.js\, comprehensive unit tests in \\_\test\\_/sieveOfEratosthenes.test.js\, and documentation in \README.md\ explaining the algorithm's steps, complexity, and references.

src/algorithms/math/sieve-of-eratosthenes · high confidence

Added Tarjan's algorithm for finding articulation points

The articulation-points module now includes an implementation of Tarjan's algorithm to identify cut vertices in undirected graphs. This new capability allows users to detect single points of failure in network topologies by finding vertices whose removal would disconnect the graph, utilizing a depth-first search approach with discovery and low-time tracking.

src/algorithms/graph/articulation-points · high confidence

Added Unique Paths algorithm solutions

New implementations for the Unique Paths problem have been added to the uncategorized algorithms section, including backtracking, dynamic programming, and a Pascal's Triangle-based approach, along with corresponding unit tests and documentation.

src/algorithms/uncategorized/unique-paths · high confidence

Added Valid Parentheses algorithm solution

A new algorithm problem for the Valid Parentheses challenge has been added to the stack algorithms section. This includes the JavaScript implementation using a Stack and HashTable data structures, along with a comprehensive test suite and documentation explaining both brute-force and optimal approaches.

src/algorithms/stack · high confidence

Added combination algorithms with documentation

Added \combineWithRepetitions\ and \combineWithoutRepetitions\ functions to generate combinations from a set of options, including support for zero-length inputs. A new README provides explanations and formulas for both combination types, along with a cheatsheet for permutations and combinations.

src/algorithms/sets/combinations · high confidence

Added graph bridge-finding algorithm

Users can now identify bridges (cut-edges) in undirected graphs using the new \graphBridges\ module, which implements Tarjan's algorithm via DFS to return edges whose removal increases the number of connected components. This addition includes the core implementation, comprehensive unit tests covering various graph structures, and documentation explaining the concept and references.

src/algorithms/graph/bridges · high confidence

Added in-place square matrix rotation algorithm

Users can now rotate an n x n matrix 90 degrees clockwise using a new algorithm located in the uncategorized algorithms section. The implementation performs the rotation via two reflections (diagonal and horizontal) and includes a test suite verifying the behavior for various matrix sizes.

src/algorithms/uncategorized/square-matrix-rotation · high confidence

Added permutation algorithms and documentation

This change introduces two new algorithms for generating permutations: \permutateWithRepetitions\ and \permutateWithoutRepetitions\, along with a comprehensive README explaining the concepts, formulas, and providing visual cheatsheets. Users can now generate permutations of sets with or without repeated elements using these new utility functions.

src/algorithms/sets/permutations · high confidence

Added playground for experimenting with algorithms

A new playground environment has been introduced in src/playground, allowing users to experiment with data structures and algorithms. It includes a main script (playground.js) that imports existing algorithmic modules (such as factorial), a corresponding test file (playground.test.js) for validating changes, and a README with instructions on how to run the tests using npm.

src/playground · high confidence

Added prime factorization and Hardy-Ramanujan approximation algorithms

The \src/algorithms/math/prime-factors\ directory now includes a new implementation for calculating prime factors of a number, optimized to run in O(sqrt(n)) time complexity. It also provides a function to estimate the count of distinct prime factors using the Hardy-Ramanujan theorem. Documentation in English and Chinese, along with comprehensive test coverage, has been added to support these new capabilities.

src/algorithms/math/prime-factors · high confidence

Added trial division primality test algorithm

A new trial division algorithm has been added to the math algorithms library to determine if a number is prime. The implementation correctly identifies prime numbers greater than 1, returns false for integers less than or equal to 1 (including 1 itself), and handles non-integer inputs by returning false. This change includes the core logic, corresponding unit tests, and documentation for the new feature.

src/algorithms/math/primality-test · high confidence

BinaryTreeNode now supports meta data, height, balance factor, and uncle access

The BinaryTreeNode class has been expanded with new capabilities: nodes can now store arbitrary metadata via a HashTable-based \meta\ property, and expose computed properties for \height\, \leftHeight\, \rightHeight\, and \balanceFactor\. Additionally, an \uncle\ getter allows traversal logic to access a node's uncle (parent's sibling), and utility methods \setValue\, \setLeft\, \setRight\, \removeChild\, \replaceChild\, and a static \copyNode\ method provide more granular control over node structure and copying. These changes enhance the node's utility for implementing balanced tree algorithms like AVL or Red-Black trees.

src/data-structures/tree · high confidence

Fibonacci algorithm implementation with multiple calculation methods and documentation

The Fibonacci module now provides three distinct ways to compute Fibonacci numbers: a function returning the full sequence up to n, a function calculating the nth number using dynamic programming, and a function using Binet's closed-form formula (valid for positions 1–70). The module also includes README documentation in English, French, Georgian, and Chinese to explain the mathematical concept and usage.

src/algorithms/math/fibonacci · high confidence

Introduce Graph data structure with directed/undirected support and edge reversal

Added a new Graph data structure supporting both directed and undirected graphs. The implementation includes core operations for managing vertices and edges (add, delete, find), retrieving neighbors and degrees, and reversing edge directions in directed graphs. Edge keys are automatically generated based on direction but can be customized to remain stable during reversal. The structure also provides methods to get an adjacency matrix and calculate total graph weight.

src/data-structures/graph · high confidence

Introduce singly linked list implementation with custom comparators

The linked list data structure in src/data-structures/linked-list is now available, providing a singly linked list implementation that supports custom comparators for flexible element comparison. The implementation includes core operations such as prepending, appending, inserting, deleting, finding, and deleting the tail, along with traversal capabilities. The change also introduces localized documentation for the linked list in multiple languages including Spanish, Japanese, Korean, Portuguese, Russian, Turkish, Ukrainian, Vietnamese, and Chinese, ensuring users can access the data structure's documentation in their preferred language.

src/data-structures/linked-list · high confidence

Introduction of a sorting algorithm framework with base class and test utilities

The sorting module now provides a foundational structure for implementing sorting algorithms. A new \Sort\ base class has been added, which manages sorting callbacks (for custom comparison and element visiting) and delegates the actual sorting logic to subclasses. Alongside this, a \SortTester\ utility class has been introduced to standardize validation, offering static methods to test basic sorting, negative number handling, custom comparator support, stability, and time complexity via visit counting.

src/algorithms/sorting · high confidence

New algorithms for converting between floating-point numbers and their binary representations

Added new JavaScript modules that implement IEEE 754 binary representation conversions for half-precision (16-bit), single-precision (32-bit), and double-precision (64-bit) floating-point numbers. The \bitsToFloat\ module provides functions to decode binary bit sequences into decimal floating-point values, while the \floatAsBinaryString\ module offers functions to encode decimal floating-point numbers into their binary string representations. Comprehensive test suites and documentation have been included to explain the underlying concepts and validate the conversion logic.

src/algorithms/math/binary-floating-point · high confidence

New bit manipulation algorithms and documentation

The \src/algorithms/math/bits\ directory now includes a comprehensive suite of bitwise operations, such as \fullAdder\, \bitsDiff\, \bitLength\, \isPowerOfTwo\, \multiply\ (signed), and \multiplyUnsigned\, alongside existing utilities like \getBit\, \setBit\, and \countSetBits\. These additions are accompanied by updated English, French, and Chinese README files that document the new capabilities and usage examples for users.

src/algorithms/math/bits · high confidence

Behavioural changes

Added pre-commit linting via Husky

The repository now enforces code linting before every commit by running 'npm run lint' through a new Husky pre-commit hook. This ensures that linting errors are caught early in the development workflow, preventing non-compliant code from being committed.

.husky · high confidence

Heap data structure refactored with shared base class and ad-hoc implementations

The heap implementation has been restructured to use a shared base \Heap\ class that handles common array-based operations (indexing, swapping, heapify) and relies on a \Comparator\ utility for ordering logic. \MinHeap\ and \MaxHeap\ now extend this base class, implementing only the specific comparison logic required for their respective orderings. Additionally, minimalistic, dependency-free 'ad-hoc' versions (\MinHeapAdhoc\ and \MaxHeapAdhoc\) have been added for use in coding interviews where external imports are restricted. The documentation has also been updated to include translations in French, Japanese, Korean, Portuguese, Russian, Turkish, Ukrainian, and Simplified Chinese.

src/data-structures/heap · high confidence

Test coverage

Added test coverage for Binary Search Tree and its nodes; Added test coverage for DoublyLinkedList and DoublyLinkedListNode; Added test coverage for Fibonacci sequence implementations; Added test coverage for HashTable; Added test coverage for Heap data structures; Added test coverage for Merge Sort algorithm; Added test coverage for QuickSort and QuickSortInPlace algorithms; Added test coverage for ShellSort algorithm; Added test coverage for bitwise math utilities; Added test coverage for the Stack data structure; Added test suite for Insertion Sort; Added tests for BinaryTreeNode functionality; Added tests for Dijkstra's algorithm; Added tests for DisjointSet, DisjointSetAdhoc, and DisjointSetItem; Added tests for Fenwick Tree implementation; Added tests for LRU Cache implementations; Added tests for N-Queens algorithm implementations; Added tests for Red-Black Tree insertion and balancing logic; Added tests for Sort class instantiation behavior; Added tests for combination algorithms; Added tests for depth-first search traversal and callback hooks; Added tests for permutation algorithms; Added tests for the articulation points algorithm; Added unit tests for AVL Tree rotations and balancing; Added unit tests for BloomFilter; Added unit tests for BubbleSort algorithm; Added unit tests for LinkedList and LinkedListNode; Added unit tests for PriorityQueue; Added unit tests for Trie and TrieNode data structures; Added unit tests for the Queue data structure; Added unit tests for the Rabin-Karp string search algorithm; Initial test coverage for Graph, GraphVertex, and GraphEdge.

Dependencies

Upgrade to Node.js 22 and update development dependencies

The project now requires Node.js 22.0.0 or higher and npm 10.0.0 or higher to run. Development dependencies have been updated to their latest versions, including Jest 30.2.0, Babel 7.29.0, ESLint 8.57.1, and Husky 9.1.7, ensuring compatibility with the new runtime and leveraging recent improvements in testing, linting, and pre-commit hooks.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 62 → 63 (+0.9)
  • Rubric changed (rubric-2026.09.11 → rubric-2026.09.18) — scores are not directly comparable.

Lenses

  • Code Health 66 → 66 (+0.0)
  • Architecture 100 → 89 (-10.5)
  • Maturity 64 → 64 (+0.0)
  • Readiness 55 → 56 (+0.9)
  • Security 69 → 81 (+12.4)

Resolved (4)

  • Dependency hygiene PARTLY measured — npm pinning read, dependency currency not (no pnpm-resolved versions to grade)
  • High CVE: [GHSA redacted] (package-lock.json)
  • High CVE: [GHSA redacted] (package-lock.json)
  • Off-boarding risk: anonymized user #1

New (5)

  • Dependency hygiene PARTLY measured — npm pinning read, dependency currency not (the committed lockfile resolved no direct production dependency)
  • High CVE: [GHSA redacted] (package-lock.json)
  • High CVE: [GHSA redacted] (package-lock.json)
  • Off-boarding risk: anonymized user #1
  • Projects may be oversized for their cohesion

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

trekhleb/javascript-algorithms was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 1 October 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 85293e3e2b88f4d2ce330d956b139cf628aa1e82 — the exact code this score is about.
  • Scored under rubric-2026.09.18 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-e569280dd5e2.