Brooks Patton
I have been working in the IT field for most of my professional career, first as a Systems Administrator at NASA Ames Research Center, as a software developer, and now I am an instructor at Galvanize.
in JavaScript
Binary Search Tree
A binary search tree is a data structure for storing data in a way that is easy and quick to search through later.
Think of linked lists but with children instead of siblings
Depth first and breadth first are not the only ones available
But they are given in interviews sometimes
how do we go about searching?
start depth first search
parameters node, isMatch callback
if node is undefined, return false
if node is a match, return true
if there is a left node
recursively go down left branch
if there is a right node
recursively go down right branch
no more children, return false
make the tests pass for depth first search
answer the following question
how do we go about searching?
start breadth first search
parameters root node, isMatch callback
create a queue
add the root node to the queue
start forever loop
if queue is empty, return false
get node from queue
if the node matches, return true
add the nodes children to the queue
make the tests pass for breadth first search
By Brooks Patton
depth first search, and breadth first search algorithms with javascript
I have been working in the IT field for most of my professional career, first as a Systems Administrator at NASA Ames Research Center, as a software developer, and now I am an instructor at Galvanize.