We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c51193d commit 15f17c3Copy full SHA for 15f17c3
13-Tree-Traversal-Algorithms/01-BFS.js
@@ -37,6 +37,17 @@ class BinarySearchTree {
37
}
38
39
40
+ /**
41
+ * 1. Create a queue (this can be an array) and a variable to store the
42
+ * values of nodes visited
43
+ * 2. Place the root node in the queue
44
+ * 3. Loop as long as there is anything in the queue
45
+ * 4. Dequeue a node from the queue and push the value of the
46
+ * node into the variable that stores the nodes
47
+ * 5. If there is a left property on the node dequeued - add it to the queue
48
+ * 6. If there is a right property on the node dequeued - add it to the queue
49
+ * 7. Return the variable that stores the values
50
+ */
51
breadthFirstSearch () {
52
if (!this.root) {
53
return -1;
0 commit comments