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`?ÂSolution
The `trickyTraversal` function is an Inorder Traversal.       It first recursively visits the left child.       Then it prints the current node's data.       Then it recursively visits the right child.     This is the definition of an Inorder Traversal.     For the given tree:     ```        10        / \       5  15       / \  /      2  7 12     ```     Inorder traversal: Left -> Root -> Right     1. `trickyTraversal(10)`       1.1. `trickyTraversal(5)`         1.1.1. `trickyTraversal(2)`           1.1.1.1. `trickyTraversal(nullptr)` -> return           1.1.1.2. Print `2`           1.1.1.3. `trickyTraversal(nullptr)` -> return         1.1.2. Print `5`         1.1.3. `trickyTraversal(7)`           1.1.3.1. `trickyTraversal(nullptr)` -> return           1.1.3.2. Print `7`           1.1.3.3. `trickyTraversal(nullptr)` -> return       1.2. Print `10`       1.3. `trickyTraversal(15)`         1.3.1. `trickyTraversal(12)`           1.3.1.1. `trickyTraversal(nullptr)` -> return           1.3.1.2. Print `12`           1.3.1.3. `trickyTraversal(nullptr)` -> return         1.3.2. Print `15`         1.3.3. `trickyTraversal(nullptr)` -> return     Output: `2 5 7 10 12 15`
Which of the following has signed an agreement with AREAS (Association of Renewable Energy Agencies of States)Â to ensure exchange of knowledge on poli...
Prime Minister Narendra Modi is set to receive Dominica's highest honor for his contributions to:
The Uttar Pradesh government recently decided to set up a bioplastic park with an investment of Rs 2,000 crore. Where will this park be established?
NTPC commissions India’s first Air cooled condenser in which of the following state?
Which four indices were launched by BSE’s Asia Index as part of its revival plan?
Which government department collaborated with the Machines Can See company to launch the 'Machines Can See 2023' Summit?
Who among the following will be attending the Annual Meetings of the International Monetary Fund (IMF) and the World Bank, the G20 Finance Ministers an...
_____________ was chosen as the third woman and the youngest president to head the European Parliament.
What is the projected job creation from the PLI scheme as mentioned in the export performance data?
Which institute’s incubator NSRCEL and Goldman Sachs’ online business education programme for women 10,000 Women has launched Goldman Sachs 10,000...