diff -r aae1d6bbd33b56fe4ba8c784a9c68ea1fdc1ff64 -r e5c10fcd24001302bb477f4e4660829f7655580d cpp/algorithms/src/Tree.h --- a/cpp/algorithms/src/Tree.h Tue Feb 19 23:47:40 2013 -0600 +++ b/cpp/algorithms/src/Tree.h Wed Feb 20 23:28:11 2013 -0600 @@ -34,6 +34,63 @@ //DeleteTree(root); } + //Node * DFS(T value) + //{ + // return dfs(value, this->root); + //} + + + + Node * BFS(T value) + { + std::vector *> stack; + stack.push_back(this->root); + Node * curr; + while (stack.size() != 0) + { + curr = stack.at(0); + stack.erase(stack.begin()); + cout << "Examining: " << curr->object << endl; + if (curr->object == value) + return curr; + if (curr->left != null) + stack.push_back(curr->left); + if (curr->right != null) + stack.push_back(curr->right); + } + return null; + } + + Node * BFS_R(T value) + { + return bfs_r(value, this->root); + } + + Node * bfs_r(T value, Node * nodes) + { + Node * ret = null; + if (nodes) + cout << "Examined: " << nodes->object << endl; + if (nodes->object == value) + return nodes; + if (nodes->left) + { + ret = bfs_r(value, nodes->left); + if (ret && ret->object == value) + return ret; + } + if (nodes->right) + { + ret = bfs_r(value, nodes->right); + if (ret && ret->object == value) + return ret; + } + + return ret; + } + + + std::vector *> getBoundary() { std::vector *> edges; diff -r aae1d6bbd33b56fe4ba8c784a9c68ea1fdc1ff64 -r e5c10fcd24001302bb477f4e4660829f7655580d cpp/algorithms/src/main.cpp --- a/cpp/algorithms/src/main.cpp Tue Feb 19 23:47:40 2013 -0600 +++ b/cpp/algorithms/src/main.cpp Wed Feb 20 23:28:11 2013 -0600 @@ -34,11 +34,12 @@ r->addLeft(35); r->addRight(50)->addRight(41); Tree tree(root); - vector *> nodes = tree.getBoundary(); - for(size_t i = 0; i < nodes.size(); i++) - { - cout << nodes[i]->object << " "; - } + //vector *> nodes = tree.getBoundary(); + //for(size_t i = 0; i < nodes.size(); i++) + //{ + // cout << nodes[i]->object << " "; + //} + cout << tree.BFS_R(25)->object << endl; cout << endl; tree.DeleteTree(); //root->addRight(