-
Notifications
You must be signed in to change notification settings - Fork 0
BFS
Rayhan Uddin edited this page Jun 2, 2017
·
2 revisions
Tree.prototype.traverse = function (callback) {
var queue=[this];
var n;
while(queue.length>0) {
n = queue.shift();
callback(n.value);
if (!n.children) {
continue;
}
for (var i = 0; i< n.children.length; i++) {
queue.push(n.children[i]);
}
}
};