Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void printBFS(Node<T>* _root)
- {
- if(_root)
- {
- queue<Node<T>*> q;
- q.push(_root);
- while(!q.empty())
- {
- Node<T> *helper = q.front();
- q.pop();
- cout << helper->data << " ";
- if(helper->left)
- q.push(helper->left);
- if(helper->right)
- q.push(helper->right);
- }
- }
- }
- void printDFS(Node<T>* _root)
- {
- if(_root)
- {
- cout << _root->data << " ";
- printHelpDFS(_root->left);
- printHelpDFS(_root->right);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement