3 ms·
BFS is a 4 line algorithm that doesn't need to be memorized. I wouldn't trust a developer who can't even reason this out with understanding runtime order comple
by jmaley 10y ago
BFS is a 4 line algorithm that doesn't need to be memorized. I wouldn't trust a developer who can't even reason this out with understanding runtime order complexity.
bool bfs(int x) {
q = new LinkedList<Node>;
q.push(root)
while (q.size != 0 && q.peak() != x);
return q.size ? true : false;
}
- kkapelon 10y agoI just said "<insert your favourite algorithm here>". BFS is just an example. Oh, well...