@tomasperezv/data-structures

Experiments with data structures.


Keywords
data, structures
License
ISC
Install
npm install @tomasperezv/data-structures@0.2.0

Documentation

CS Data Structures and Algorithms

Data structures and Algorithms implemented in Javascript.

Author

Tomas Perez - tom@0x101.com

http://www.tomasperez.com

Installation

$ npm install

Run the tests

If you want to run the tests, you need to install mocha globally:

$ npm install -g mocha

Then you can run the tests:

$ npm test

  BinaryOperator
    getBit
      βœ“ Returning bits 
    setBit
      βœ“ Setting bits 
    clearBit
      βœ“ Clearing bits 

  Insertion sort
    βœ“ Trivial cases 
    βœ“ Non trivial cases 

  Merge sort
    βœ“ Already sorted array 
    βœ“ Non trivial cases 

  Quick sort
    βœ“ Partition method 
    βœ“ Already sorted array 
    βœ“ Non trivial cases 

  Two Sum
    βœ“ Basic tests 

  BFS
    Solve algorithm
      βœ“ BFS simple search 

  Closest leaf
    Solve algorithm
      βœ“ Determine the closest leaf in a binary tree 

  DFS
    Solve algorithm
      βœ“ DFS simple search, iterative version 
      βœ“ DFS simple search, recursive version 

  Dijkstra
    Error handling
      βœ“ Empty graph 
    Solve algorithm
      βœ“ Single source path search: one vertex 
      βœ“ Single source path search: multiple nodes 

  LargestCommonSubstring
    The algorithm works as expected
      βœ“ Basic cases 

  LargestOfTwoNumbers
    The algorithm works as expected
      βœ“ Basic cases 

  Min Height in binary trees
    Solve
      βœ“ Empty BinaryTrees 
      βœ“ Basic cases 

  SortedArrayToBST
    The algorithm works as expected
      βœ“ Basic cases 
      βœ“ Edge cases 

  TreeTraverse
    In Order
      βœ“ Traverses properly a binary tree in-order 
      βœ“ Traverses properly a binary tree post-order 
      βœ“ Traverses properly a binary tree in-order 

  BinaryTree
    Creation
      βœ“ Empty BinarySearchTree 
      βœ“ Simple BinarySearchTree 
    Inserting elements in a Binary Search Tree
      βœ“ Basic insertion 
    Get largest element in a Binary Search Tree
      βœ“ Construct the BST and search for the largest 

  BinaryTree
    Creation
      βœ“ Empty BinaryTrees 
      βœ“ Leave values must be BinaryTreeNode 
      βœ“ Simple creation 

  DoubleLinkedList
    Insertion
      βœ“ Simple insertion 
      βœ“ Can not insert an invalid a value 
      βœ“ Can insert multiples values 

  HashTable
    The data structure works as expected
      βœ“ Keys validation 
      βœ“ Insertion 
      βœ“ Hash function 

  List
    isEmpty
      βœ“ Checking if a list is empty 
    Insertion
      βœ“ Simple insertion 
      βœ“ Can not insert an invalid a value 
      βœ“ Can insert multiples values 

  MinHeap
    The data structure works as expected
      βœ“ Basic cases 

  Node
    Creation and initialization
      βœ“ Simple creation 
      βœ“ Can not initialize a node without a value 
    Handling previous node
      βœ“ Can assign a value to the previous node 
      βœ“ Can not assign invalid values to the previous node 
    Handling next node
      βœ“ Can assign a value to the next node 
      βœ“ Can not assign invalid values to the next node 

  SuffixTree
    Inserting words in a suffix tree
      βœ“ Simple insertion and retrieval 
    Application of a suffix tree for computing common substrings
      βœ“ Is q a substring of S 
      βœ“ How many times does q appear in S 
      βœ“ Longest common substring of S and q 

  Tree
    Creation
      βœ“ Empty trees 
      βœ“ isLeaf 
      βœ“ Leave values must be TreeNode 
      βœ“ Simple creation 

  Trie
    Inserting and retrieval
      βœ“ Simple insertion and retrieval of words 

  60 passing (98ms)

License

Public Domain.

No warranty expressed or implied. Use at your own risk.