Algo1 Helper
Common
use log() to enable logging. Override the VERBOSE function for custom logging.
Trees
found in index.js
class Node : static helper class for Nodes
class Tree : wrapper class for Trees. usage:
let a = Tree.new(5); // this will construct a tree with root node 5
a.root.addLeft(2); // adds a node to the left of the root
a.root.left.addLeft(4); // adds a left node to the left node of the root. etc
a.level_order() / inorder() / postorder() / preorder(); // tree orderings
a.print(); // visually prints out the tree here
{{getters}}
left, right, height // gets respecive values of tree
SearchTree extends Tree
cadding Search tree functionality
min() // returns minimum value in tree
remMin() // removes the minimum value and returns it
delRoot() // remvoes root node
PrQueue
Max Heap / Priority Queue with array representation [L1 null front elem]
let a = new PrQueue([2,3,4,5]);
a.add(6); // adds value to Prq
a.rem_max() // removes the current max elem;
a.heap_sort() // sorts the Heap. ( uses a.build_max_heap() )
Hash Tables
found in hash.js
let h = new HashTable( k=>k%11 , 15) // normal hash table with 8 length and hashing fv
let hq = new QHashTable( k=>k%8 , 15, 1/2, 1/2) // quadratic hash table
let hd = new DHashTable( k=>k%11 , 15, k=> (1+k%10) ) // double hash table
h.fill([2,3,4,56]) //fill elements. Works for all HashTables
h.insert(2); //inserts single element
h.delete(2); //deletes element and prints out path if logging is set
h.search(2); //is same as h.delete(2,false)
Radix Search
found in radix.js
radix_sort( list: array[], digits: int, r (buckets): int );
//will do a full radix sort
counting_sort( list: array[], r) //idk what this does anymore :shrug:
Credits: ATP