83.8k views
3 votes
You wish to traverse a binary search tree in sorted order using preorder traversal. Arrange the following actions in the correct order to accomplish this.

I Print the right subtree recursively
II Print the root
III Print the left subtree recursively

a) I, II, III
b) III, II, I
c) II, III, I
d) III, I, II

User Marylynn
by
7.4k points

1 Answer

6 votes

Answer:

The answer is "Option b".

Step-by-step explanation:

In a binary tree, searching is a process, in which all node will have a comparable key and respects its constraint that maybe the keys in a certain node is greater than keys in all node, and the right subtree of that nodes and shorter than with the links in all node throughout the rights subtree of that node.

  • In traverse method, access all the tree nodes via the root, and afterward processing all subtrees iteratively are recognized as Travers prefix, that's why except option b all were wrong, which can be explained as follows:
  • In pre-order traversal, first, we print left subtree, then root node, and at the last right subtree.
User Shahana
by
7.6k points