␉␉//DeleteTree(root);␍␊ |
␉}␍␊ |
␍␊ |
␉//Node<T> * DFS(T value)␍␊ |
␉//{␍␊ |
␉//␉return dfs(value, this->root);␍␊ |
␉//}␍␊ |
␍␊ |
␍␊ |
␍␊ |
␉Node<T> * BFS(T value)␍␊ |
␉{␍␊ |
␉␉std::vector<Node<T> *> stack;␍␊ |
␉␉stack.push_back(this->root);␍␊ |
␉␉Node<T> * 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<T> * BFS_R(T value)␍␊ |
␉{␍␊ |
␉␉return bfs_r(value, this->root);␍␊ |
␉}␍␊ |
␍␊ |
␉Node<T> * bfs_r(T value, Node<T> * nodes)␍␊ |
␉{␍␊ |
␉␉Node<T> * 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<Node<T> *> getBoundary()␍␊ |
␉{␍␊ |
␉␉std::vector<Node<T> *> edges;␍␊ |