1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| void printBinaryTree(const BinaryTreeNode* rootNode) {
if(rootNode == NULL) { return ; }
queue<const BinaryTreeNode*> nodesQueue; nodesQueue.push(rootNode); while(!nodesQueue.empty()) { const BinaryTreeNode* node = nodesQueue.front(); cout << node->value << " "; nodesQueue.pop();
if(node->left != NULL) { nodesQueue.push(node->left); } if(node->right != NULL) { nodesQueue.push(node->right); } } }
|