Question
Given the following code snippet, which operation is
performed on the binary tree to produce the output: 4, 2, 5, 1, 3 ? class Node {Â Â Â Â Â int data;Â Â Â Â Â Node left, right;Â Â Â Â Â Node( int value) {Â Â Â Â Â Â Â Â Â data = value;Â Â Â Â Â Â Â Â Â left = right = null ;Â Â Â Â Â }Â }Â Â void traverse (Node root) {Â Â Â Â Â if (root == null )Â Â Â Â Â Â Â Â Â return ;Â Â Â Â Â traverse(root.left);Â Â Â Â Â System.out.print(root.data + " " );Â Â Â Â Â traverse(root.right);Â }ÂSolution
The given code performs Inorder Traversal on a binary tree. In this traversal method, the left subtree is visited first, followed by the root node, and finally the right subtree. The recursive calls in the code explicitly follow this order:
- traverse(root.left) visits the left subtree.
- System.out.print(root.data) processes the root node.
- traverse(root.right) visits the right subtree.
What title was adopted by Chandragupta II?Â
What is the targeted GHG intensity reduction by 2035 under the IMO’s Net-Zero Framework?
Which Indian badminton duo reached the quarter-finals at the Paris Olympics 2024?
According to the Annual Survey of Industries (ASI) 2023-24, which state was among the top 5 in terms of industrial employment?Â
What is the government’s target for the number of GI tags by 2030?
What is the targeted female labour-force participation rate by 2030 under the Shram Shakti Niti 2025?Â
When is National Mountain Climbing Day celebrated annually?
What major change did the Infosys Science Foundation implement in the Infosys Prize criteria starting May 15?
Which country recently lost its measles-free status after more than a year of continuous transmission?Â
Who led India to second place in the Asian Para Archery Championships 2025 by winning double gold?Â