Breadth FIrst Tree Traversal : Convert live test into Jest test.

This commit is contained in:
Eric Lavault
2021-10-11 14:48:06 +02:00
parent 036ac907ae
commit e3d605c528
2 changed files with 29 additions and 17 deletions

View File

@ -22,7 +22,7 @@ class BinaryTree {
for (let i = 1; i <= h; i++) {
this.traverseLevel(this.root, i)
}
return this.traversal.toLocaleString()
return this.traversal
}
// Computing the height of the tree
@ -48,19 +48,4 @@ class BinaryTree {
}
}
const binaryTree = new BinaryTree()
const root = new Node(7)
root.left = new Node(5)
root.right = new Node(8)
root.left.left = new Node(3)
root.left.right = new Node(6)
root.right.right = new Node(9)
binaryTree.root = root
console.log(binaryTree.breadthFirst())
// 7
// / \
// 5 8
// / \ \
// 3 6 9
export { BinaryTree, Node }