JavaScript Algorithms
The JavaScript algorithms collection includes implementations and examples of popular algorithms in ES6. Algorithmic snippets are primarily a learning resource, as they might already be implemented natively or require optimizations to run in production.
Groups the given data into
k
clusters, using the k-means clustering algorithm.Classifies a data point relative to a labelled data set, using the k-nearest neighbors algorithm.
Sorts an array of numbers, using the quicksort algorithm.
Finds all the indexes of a substring in a given string.
Implementation of the Luhn Algorithm used to validate a variety of identification numbers, such as credit card numbers, IMEI numbers, National Provider Identifier numbers etc.
Sorts an array of numbers, using the bucket sort algorithm.
Sorts an array of numbers, using the heapsort algorithm.
Sorts an array of numbers, using the selection sort algorithm.
Generates all permutations of an array's elements (contains duplicates).
Encrypts or decrypts a given string using the Caesar cipher.
Generates primes up to a given number, using the Sieve of Eratosthenes.
Counts the occurrences of a substring in a given string.
Calculates the distance between two points in any number of dimensions.
Sorts an array of numbers, using the insertion sort algorithm.
Sorts an array of numbers, using the merge sort algorithm.