K-means clustering
Groups the given data into k
clusters, using the k-means clustering algorithm.
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.
Sort an array of numbers, using the heapsort algorithm.
Sort an array of numbers, using the bucket sort algorithm.
The Caesar cipher is a simple substitution cipher, which can be easily implemented with a few lines of JavaScript code.
Implement the Luhn Algorithm, used to validate a variety of identification numbers.
Sort an array of numbers, using the quicksort algorithm.
Sort an array of numbers, using the selection sort algorithm.
Learn everything you need to know about Big-O notation with this handy cheatsheet.
Use JavaScript's Math.hypot()
to calculate the Euclidean distance between two points.
Learn how to check if a number is prime and how to generate prime numbers up to a given number in JavaScript.
Sort an array of numbers, using the merge sort algorithm.
Sort an array of numbers, using the insertion sort algorithm.
Create arrays of numbers in arithmetic and geometric progression.
Counts the occurrences of a substring in a given string.
Use JavaScript to calculate the greatest common divisor and least common multiple of two or more numbers.
Implement the Levenshtein distance algorithm in JavaScript to calculate the difference between two strings.
Finds a contiguous subarray with the largest sum within an array of numbers.
Sort an array of numbers, using the bubble sort algorithm.
Finds the index of a given element in a sorted array using the binary search algorithm.
Generates an array, containing the Fibonacci sequence, up until the nth term.
Calculates the distance between two vectors.
Finds the first index of a given element in an array using the linear search algorithm.
Find the prime factors of a number using trial division in JavaScript.