GithubHelp home page GithubHelp logo

javascriptbst's Introduction

Binary Search Tree Javascript (Recursive)

Hi there, I'm Khaleel aka Magnificvs (Magnificus) 👋

I'm a Developer, Mystic and Dreamer

  • 🔭 Class that implements Binary Search Tree Data Structure in Javascript
  • 🥅 Feel free to use but UNDERSTAND what the code does
  • ⚡ JAVASCRIPT Code only

Languages and Tools:

JavaScript

Modified from GEEKS FOR GEEKS Brilliant Explanation:

Click Here for Original GEEKS FOR GEEKS Article I

Click Here for Original GEEKS FOR GEEKS Article II

⚡⚡⚡HOW TO USE ⚡⚡⚡

//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

⚡⚡⚡VISUALIZATION⚡⚡⚡

Breadth First Search

JavaScript
via MEDIUM

Depth First Search - InOrder

Traversal
via SITE

Depth First Search - PreOrder

Traversal
via SITE

Depth First Search - PostOrder

Traversal
via SITE

javascriptbst's People

Contributors

wmdirn avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.