• recategorized by
1,022 views
0 0 votes

Suppose a binary search tree has been constructed from the following sequence of numbers in the order in which they arrive : $6, 2, 10, 1, 5, 7, 11, 3, 9, 4, 8.$ Consider the following piece of code :

Show(root) $ \{ \text { if (root != NULL)}$

$\qquad \quad \{ \text{printf}( “ \% d”, \text{root} \rightarrow \text{key)};$

$\qquad \qquad$ show $\text{(root} \rightarrow \text{right)};$

$\qquad \qquad$ show $\text{(root} \rightarrow \text{left)};$

$\qquad \qquad$ }

$\qquad \quad$ else

return ;

$\qquad$ }

The sequence printed will be :

  1. $6, 11, 10, 7, 8, 9, 2, 4, 3, 5, 1$
  2. $6, 11, 7, 9, 8, 10, 2, 5, 1, 3, 4$
  3. $6, 10, 11, 7, 9, 8, 2, 5, 3, 4, 1$
  4. $6, 10, 2, 11, 7, 9, 8, 5, 3, 4, 1$

2 Answers

Answer:
Position:
Show:

Related questions

0 0 votes
1 1 answer
658
658 views
soujanyareddy13 asked Jan 9, 2022
658 views
When the left sub-tree of the tree is one level higher than that of the right sub-tree, then the balance factor is _____________ .$0$$1$$-1$$2$
0 0 votes
1 1 answer
482
482 views
soujanyareddy13 asked Jan 9, 2022
482 views
Total number of nodes at the $\text{n}^{th}$ level of a full binary tree can be given as _______________ .$\text{2n+1}$$\text{2n}^{2}$$2^\text{n}$$\text{2n-1}$
0 0 votes
1 1 answer
617
617 views
soujanyareddy13 asked Jan 9, 2022
617 views
Let $\text{T(n)}$ be the number of different binary search trees on $\text{n}$ distinct elements-then $\text{T(n)} = \displaystyle{\sum_{k=1}^{n}} \text{T(K-1)} \; T(x)$ ...
0 0 votes
2 2 answers
586
586 views
admin asked Jul 21, 2022
586 views
The preorder traversal of a binary search tree is given by $12, 8, 6, 2, 7, 9, 10, 16, 15, 19, 17, 20$.Then postorder traversal will be:$2, 6, 7, 8, 9, 10, 12, 15, 16, 17...