Skip to content

felipernb/algorithms.js

Repository files navigation

algorithms.js

Build Status Coverage Status Dependency Status devDependency Status Inline docs npm

Atwood's Law applied to CS101.

Classic algorithms and data structures implemented in JavaScript, you know... FOR SCIENCE.

Installing

npm install --save algorithms

Contents

Data Structures

require('algorithms/data_structures');
// or
require('algorithms').DataStructures;
  • AVLTree
  • BST
  • DisjointSetForest
  • FenwickTree
  • Graph
  • HashTable
  • Heap
    • MaxHeap
    • MinHeap
  • LinkedList
  • PriorityQueue
  • Queue
  • Set (HashSet)
  • Stack
  • Treap

Geometry algorithms

require('algorithms/geometry');
// or
require('algorithms').Geometry;
  • BezierCurve

Graph algorithms

require('algorithms/graph');
// or
require('algorithms').Graph;
  • breadthFirstSearch
  • depthFirstSearch
  • eulerPath
  • topologicalSort
Shortest path
  • bellmanFord
  • bfsShortestPath
  • dijkstra
  • floydWarshall
  • SPFA (Shortest Path Faster Algorithm)
Minimum spanning tree
  • prim
  • kruskal

Math algorithms

require('algorithms/math');
// or
require('algorithms').Math;
  • collatzConjecture
  • extendedEuclidean
  • fastPower
  • fibonacci
  • findDivisors
  • fisherYates
  • gcd (Greatest common divisor)
  • greatestDifference
  • lcm (Least common multiple)
  • newtonSqrt
  • nextPermutation
  • powerSet
  • reservoirSampling
  • shannonEntropy

Search algorithms

require('algorithms/search');
// or
require('algorithms').Search;
  • bfs (breadth-first search for binary trees)
  • binarySearch
  • dfs (depth-first search for binary trees)
  • inOrder (default)
  • postOrder
  • preOrder

Sorting algorithms

require('algorithms/sorting');
// or
require('algorithms').Sorting;
  • bubbleSort
  • countingSort
  • heapSort
  • insertionSort
  • quicksort
  • radixSort
  • selectionSort
  • shellSort
  • shortBubbleSort

String algorithms

require('algorithms/string');
// or
require('algorithms').String;
  • hamming
  • huffman
  • decode
  • encode
  • knuthMorrisPratt
  • levenshtein
  • longestCommonSubsequence
  • longestCommonSubstring
  • rabinKarp

Contributing

This project uses Google JavaScript Style Guide which can be a bit strict, but is really helpful in order to have more readable and less error-prone code