Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void SplayTree::printTree ()
- {
- prettyPrintTree(root, "", true);
- cout << "------------------------\n";
- }
- void SplayTree::prettyPrintTree(Node* root, string prefix, bool isLeft) {
- if (root == nullptr) {
- cout << "Empty tree";
- return;
- }
- if(root->right) {
- prettyPrintTree(root->right, prefix + (isLeft ? "│ " : " "), false);
- }
- cout << prefix + (isLeft ? "└── " : "┌── ") + root->user.name + "\n";
- if (root->left) {
- prettyPrintTree(root->left, prefix + (isLeft ? " " : "│ "), true);
- }
- }
Add Comment
Please, Sign In to add comment