Motivation

“Bad programmers worry about the code. Good programmers worry about data structures and their relationships.” Linus Torvalds

Introduction

Tree

The tree is a linear data structure, order in a hierarchical manner. heavily used in any hierarchical system development, like:

File system, organizational profile

Binary Tree

The binary tree is the specific kind of tree where the maximum amount of children node is two.

Binary Search Tree

It is a binary tree where left nodes contain less value than the right nodes.

image credit: tutorials point

Common Term

Path = The specific way/nodes to access from one node to another.

Tree-Traversal = Visiting all nodes in a particular way.

root = First node of a Tree.

Key = Value of each node.

level = Specific break down of a tree.

Before move on

if you like proper documentation, please follow the below link.

And if you, like to see without the article itself, scroll down to the bottom and you will find the full code section.

Implementation

Before implementing a tree data structure, it is sagacious to understand javascript basic operations and methods.

Our binary search tree has some sub functionality.

Insert = insert data into node Travers = traverse nodes for accessing values Search = search within nodes Remove = remove node/nodes

Basic structure

A Node object will contain all specific information of an individual node which accept 3 arguments dat, left, right .