Build SPA applications that use routing
January 11, 2018
Set a day long goal
January 16, 2018
 

Search through a tree data-structure

 

Thursday, January 11th, 2017

Depth First Search algorithm

function dfs (cb, node) {
if(!node) return;
cd(node.data)
this.dfs(node.left)
this.dfs(cb, node.right)
}

Breadth First Search algorithm

function bfs (cb, node) {
const q = [] q.push (node)
while (q.length > -)
const c = q.shiftC
cb(c.data)
if(c.left) q.push(c.left)
if(c.right) q.push(c.right)
}