Question

Consider the following C++-like pseudo-code for a binary tree traversal:     ```cpp     struct Node {         int data;         Node left;         Node right;     };     void trickyTraversal(Node root) {         if (root == nullptr) {             return;         }         if (root->left != nullptr) {             trickyTraversal(root->left);         }         std::cout data right != nullptr) {             trickyTraversal(root->right);         }     }     ```     Given the following binary tree:     ```           10          /  \         5    15        / \    /       2   7  12     ```     What will be the output of `trickyTraversal(root)` where `root` points to the node with data `10`? 

A `2 5 7 10 12 15`
B `10 5 2 7 15 12`
C `2 7 5 12 15 10`
D `10 5 15 2 7 12`
Practice Next

Hey! Ask a query