- 🔭 Class that implements Binary Search Tree Data Structure in Javascript
- 🥅 Feel free to use but UNDERSTAND what the code does
- ⚡ JAVASCRIPT Code only
Click Here for Original GEEKS FOR GEEKS Article I
Click Here for Original GEEKS FOR GEEKS Article II
//tested using https://repl.it/languages/javascript
var BST = new BinarySearchTree();
//Insert Nodes into BST
BST.insert(15);
BST.insert(25);
BST.insert(10);
BST.insert(7);
BST.insert(22);
BST.insert(17);
BST.insert(13);
BST.insert(5);
BST.insert(9);
BST.insert(27);
//Get Root node
var root = BST.getRootNode();
//Prints OBJECT with nodes to console
console.log(root);
//Shows Order of Node Traversal
console.log("BFS");
BST.printLevelOrder(root);//BFS recursive
console.log("DFS-Inorder");
BST.inorder(root); //DFS recursive
console.log("DFS-Preorder");
BST.preorder(root); //DFS recursive
console.log("DFS-Postorder");
BST.postorder(root); //DFS recursive