I l @ ve RuBoard |
Despite the complex nature of a tree structure, it is easy to print. Again we use recursion. The printing algorithm is:
The code for printing the tree is: void tree::print_one(node *top) { if (top == NULL) return; // Short tree print_one(top->left); std::cout << top->word << '\n'; print_one(top->right); } void tree::print( ) { print_one(root); } |
I l @ ve RuBoard |