- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Creating a BinaryTree using Javascript
Let us understand how we're going to create and represent a binary search tree in Javascript. We'll first need to create the class BinarySearchTree and define a property Node on it.
Example
class BinarySearchTree { constructor() { // Initialize a root element to null. this.root = null; } } BinarySearchTree.prototype.Node = class { constructor(data, left = null, right = null) { this.data = data; this.left = left; this.right = right; } };
We've simply created a class representation of our BST class. We'll fill this class in as we proceed to learn functions that we'll add to this structure.
- Related Articles
- Creating a Set using Javascript
- Creating a Priority Queue using Javascript
- Creating a linked list using Javascript
- Creating a hash table using Javascript
- Creating Arrays using Javascript
- Creating Dictionary using Javascript
- Creating a Doubly Linked List using Javascript
- Creating a Simple Calculator using HTML, CSS, and JavaScript
- Creating JavaScript constructor using the “new” operator?
- Creating auto-resize text area using JavaScript
- Creating a Dynamic Report Card using HTML, CSS, and JavaScript
- Creating Animated Counter using HTML, CSS, and JavaScript
- Creating a Stack in Javascript
- Creating a Queue in Javascript
- Creating a Graph in Javascript

Advertisements