majabogeski / binary-tree-js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Binary Tree In JavaScript

This assignment will require you to implement a binary tree with the following methods.

insertIteratively: inserts a node in the proper location using iteration

insertRecursively: inserts a node in the proper location using recursion

containsIteratively: checks to see if the tree contains a node iteratively

containsRecursively: checks to see if the tree contains a node recursively

findLowest: finds the lowest value in the tree

findHighest: finds the lowest value in the tree

breadthFirstSearch: traverses through the tree and returns an array of all of the values using Breadth First Search (from left to right) - you can read more about it here

DFSPreOrder: traverses through the tree and returns an array of all of the values using Depth First Search Pre-order - you can read more here

DFSInOrder: traverses through the tree and returns an array of all of the values using Depth First Search In-order - you can read more here

DFSPostOrder: traverses through the tree and returns an array of all of the values using Depth First Search Post-order - you can read more here

size : calculates how many nodes are in the tree (do this without adding a size property to your tree! Use a traversal method to calculate this!)

Bonus

remove: removes a node from a binary tree. Remember that this method must take into account if the node has any children and if the node is a leaf. Here is a great video that explains this process.

About


Languages

Language:JavaScript 100.0%