0% found this document useful (0 votes)
0 views

Tree Solution

The document contains a series of questions and answers related to binary trees, AVL trees, and binary search trees, covering concepts such as node depth, leaf nodes, rotations, and traversal methods. Each question is followed by multiple-choice options and the correct answer is provided. The document serves as a study guide for understanding tree data structures and their properties.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Tree Solution

The document contains a series of questions and answers related to binary trees, AVL trees, and binary search trees, covering concepts such as node depth, leaf nodes, rotations, and traversal methods. Each question is followed by multiple-choice options and the correct answer is provided. The document serves as a study guide for understanding tree data structures and their properties.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

TREE

Q1. In Binary tree what is the maximum number of node at depth „4‟ if depth start from 1.
(a)16 (b)15
(c)31 (d) 8

Ans D

At depth d there are 2d-1 nodes: - at depth 4 there will be 24-1 =23 nodes =8 nodes
Q2. In a complete k-ary tree, every internal node has exactly k children or no child. The number
of external node in such a tree with n internal nodes is:
(a) nk (b) (n – 1) k+ 1
(c) n(k – 1) + 1 (d) n(k – 1).
Ans (c)
K-ary tree means exactly k children on no child let consider 2-ary binary tree
with 3 internal nodes then 4 external nodes

Let consider 3 any or ternary tree with 4 internal node the external node
i.e (k-1) n+1
 (k-1) n+1 satisfy all the cases
Q3. What is the maximum number of leaf nodes in a binary tree with 15 nodes?
(a)8 (b)15
(c)12 (d)7
Answer:A
We will get maximum no. of leaf nodes when the tree is balanced

Number of leaf nodes = 8.


Q4. What is the minimum number of leaf nodes in a binary tree with 15 nodes?
(a)1 (b)2
(c)0 (d)8
Ans :B
Minimum no .of leaf nodes are always 2. There will be always 2 nodes with degree 1 in
a tree Example
Q5. Consider this binary search tree:

Suppose we remove the root, replacing it with its in-order successor. What will be the new
root?
(a) 16 (b) 24
(c) 25 (d) 2
Ans a

In order =1 2 14 16 24 25
Indore successor of 14 (root nodes) is 16, hence new root will be 16 (as we are
replacing root with its in order successor).

Q6. What does the following algorithm calculate when called with the root of a binary tree as
the input?
int treeAlg(BinaryNode t)
{
if (t.left != null || t.right != null)
return 1 + treeAlg(t.left) + treeAlg(t.right);
else
return 0;
}
(a) the number of nodes in the tree
(b) the length of the shortest path from the root to a leaf
(c) the length of the longest path from the root to a leaf
(d) the number of internal (non-leaf) nodes
And D

Taking example
Stack
treeAlg ( (1) treeAlg( (1)
1+ treeAlg(2)+ treeAlg((3) 1+t(4)+t(5)
2 1 0 0

t(4) t(5) t(3) t(6)


0 0 1+t(6)+t(NULL) 0
Tree alg(1) ie (tree alg (root )
Returns 2+1=3
No of nodes in tree =6
Length of the shortest path=2
Length of the longest path=2
No of non-leaf nodes=3The algorithm returns no.of non-leaf nodes
Q7. If the following keys are inserted in to the empty AVL tree ( 1,3,7,4,5,8,6,2 ). Find the total
number of rotation ______?

Ans :-3
Ans :-3

Total no of rotations =3

Q8. Which one of the following rates of growth is correct for the number of leaves L(N) in a
complete binary tree with N nodes?
(a) L(N) = θ(N) (b)L(N) = θ (logN)
(c)L(N) = θ (N logN) (d)L(N) = θ (N2)
Ans A
In complete binary if there are n nodes then the no .of leaf nodes are (n+1)/2
leaf nodes hence if we increase n linearly then no .of nodes will also increase
linearly L(N)=O(n).

Q9. Draw the binary search tree with keys 1, 2, 3, 4, 5, 6, 7, 8 such that the preorder starts with
3, 1, 2, 7 and the postorder ends with 5, 8, 7, 3. Then find the complete postorder traversal.
(a) 2 1 4 6 8 5 7 3 (b)2 1 4 6 5 8 3 7
(c)1 2 4 5 6 8 7 3 (d)2 1 4 6 5 8 7 3
Ans: D
Binary search tree with keys  1 2 3 4 5 6 7 8
Inorder: - 1 2 3 4 5 6 7 8
Preorder starts with:-3 1 2 7
Postorder ends with: - 5,8,7,3
Using Preorder and inorder

Now using in order and post order if we add other nodes

Now 4 and 6 are left as the given tree is binary search tree  after adding 4 and
6 the tree will be:-
The post order of the tree will be:-
21465873

Q10. What would the recursive procedure below print if called on the root of the tree given
below?

void traverse(x)
{
if (x != null)
{
print x.data;
traverse(x.left);
traverse(x.right);
print x.data;
}}
(a) ABCDEABCDE (b) ABBEEDDCCA
(c) ABBCCDDEEA (d) ABBCDEEDCA
Ans :- D

Representing traverse (x) with t(x)


t(A) t(B) t(c) T(d) t(e)
1 print A 3 prints B 8print C 10 print D 12 print ∈
2 t(B) 4 t(null) 9 t(D) 11 t(∈) 13 t(null)
7 t(c) 5 t(null) 18 t(null) 16 t(null) 14 T(null)
20 print A 6 print B 19 print c 17 print D 15print ∈

Output ABBCDEEDCA

Q11. Which of the following are necessarily true of the linked implementation of a binary tree?
(i) The worst-case space complexity is (|V|)
(ii) Each internal vertex has neither a left pointer nor a right pointer of NIL
(iii) Each terminal vertex has both a left pointer and a right pointer of NIL
(a) (i) only (b) (i) and (ii) only
(c) (i) and (iii) (d) (ii) and (iii)
Ans :-A
(i)TRUE
(ii) FALSE internal vertex may have any one of the right pointer or left pointer as nil
(iii) True
Q12. Which node is the deepest when the items 3, 6, 5, 2, 4, 7, 1 are inserted into an initially
empty binary search tree?
(a) 1 (b) 3
(c) 4 (d) 7
1. Ans :-c

The node with the item 4 is at the deepest level.

Q13. Suppose that we have a binary tree with fields left, right, and data as usual; the data fields
contain integers. An integer field value is also present in each node. The root of the tree is r.
assuming the procedure mystery is as shown below, what would be the effect of the call
mystery(r, 0)?
void mystery(x, i) {
if (x != null) {
x.value = x.data + i;
x.value = mystery(x.left, x.value);
x.value = mystery(x.right, x.value);
return x.value
}}
(a) For all nodes x in the tree, set the value field to be equal to the sum of the data fields of
the descendants of x.
(b) For all nodes x in the tree, set the value field to be equal to the sum of the data fields of
the ancestors of x.
(c) For all nodes x in the tree (except the root), set the value field to be equal to the sum of
the data fields in x and its parent.
(d) For all nodes x in the tree, set the value field to be equal to the sum of the data fields of
all nodes in the tree.

Q14. Suppose that we have the numbers between 1 and 500 in a binary search tree and we
perform a search for the number 331 starting at the root of the tree. Which of the following
cannot be a sequence of nodes examined?
(a) 492, 7, 105, 390, 331
(b) 9, 250, 390, 100, 331
(c) 5, 105, 401, 243, 331
(d) 1, 475, 252, 333,331
Ans :_B
(A)
492, 7, 105, 390, 331

7 105 331
492 390
This can be the sequence

(B)
9, 250, 390, 331,
Not in increasing order
100,
9 250 100
331
390
This cannot be sequence
(C)
1 252
331
475 333
This is also a possible sequence
Q15. Which of the following, from the following list produce the same BST as A E F G B D C
when inserted in the order given into an initially empty tree.
(i) A C B E G D F
(ii) A E B F D C G
(iii) A E B G C D F
(iv) A E G C F D B
(v) A E G D C B F
(vi) E A G B D F C
(a) i only (b) ii only
(c) iii, v and vi only (d) none
Ans :-b
Given order :- AEFGBDC
BST:-

only (II)
has same bst as given bst

Q16. What is the minimum and maximum height of a binary tree that contains 100 nodes?
(Assume root at height 0)
(a) Min: 10; Max 99 (b) Min: 6; Max 50
(c) Min: 10; Max 50 (d)Min: 6; Max 99
Ans (D)
Minimum height the minimum height of the tree will be when the tree will be
FULL binary tree.
2h+1-1=100
2h+1-1=100+1
2h+1-1=101
(h+1)_log22=log2101
h+1=log2101
h2=7-1
h=6
Maximum height when the tree will be in the form of chain
Height = no of edges =n-1
=100-1=99

Q17. Refer to method do Something:


int doSomething (TreeNode *root) {
if (root != null)
if (rootRight() = = null)
return rootValue();
else
return doSomething(rootRight());
return null;}
Which best describes what doSomething does?
(a) It returns the largest element in a nonempty binary search tree.
(b) It returns the largest element in a nonempty tree.
(c) It returns an element at the highest level of a nonempty tree.
(d) It returns the smallest element in a nonempty binary search tree
Ans :- A

dosomething (5)

dosomethind (15)

doeomthing (21) return =21
it return the largest element in non-empty binary search tree.

Q18. An AVL tree of minimal size with height 5 will have how many nodes? (Assuming root is
at height zero)
(a) 6 (b) 12
(c) 20 (d) 32
Ans (C)
n(h)total no of nodes with height h
n(n)=n(h-1)+n(h-2)+1
n(0)=1
n(!)=2
n(2)=1+2+1=4
n(3)=4+2+1=7
n(4)=7+4+1=12
n(5)=12+7+1=20

Q19. The worst case time complexity of search and insert operations in BST is :
(a)O(n),O(logn) (b) O(logn),O(logn)
(c) O(n),O(n) (d) O(logn),O(n)
Ans (C) BST (binary search tree)can be in the form of chain in the worst case
complexity of search and insert operation will be o(n) ando (n) respectively.
Q20. The worst case time complexity of insert , delete , Search operations in AVL tree is :
(a)O(n),O(logn),O(logn) (b) O(logn),O(logn)
(c) O(n),O(n),O(n) (d) O(logn),O(logn),O(logn)

Ans (D) AVL tree is always balanced hence complexity of insert delete and search
operation will be O(log n) , O(log n ),O(logn) respectively.
Q21. What is the balance factor for the highlighted node?

(a) -1 (b) -2
(c) 2 (d) 1
Ans :-C

Q22. If output of in-order traversal of a binary tree is GDBHEIACJF and output of post-order
traversal is GDHIEBJFCA what is the output of pre-order traversal?
(a) ABGDEHICJF (b) ABDGEHICJF
(c) ABDGEHICFJ (d) ABGDEHICFJ
Ans :-c
Inorder –GDBHEIACJF
Post order –GDHIEBJFCA
Tree:-

PREORDER: - ABDGEHICFJ

Q23. Suppose that we insert a 48 into the AVL tree (also known as height-balanced tree) shown
below. Which rotation will be performed?

(a) A single rotation at 23 (b) A single rotation at 46


(c) A double rotation at 23 (d) A double rotation at 46

Ans D
48 will be inserted here due to this 46 and 23 and 51 gets unbalanced 48 is
inserted to the left child of the right child of the 46(ie in the night then in the left
). Hence RL rotation will be required to balance it.
(Single double rotation at 46 is required)
# Note: - we balance the node which is closes to the leaf due to which other
nodes automatically gets balance .

Q24. Each of the following lists of numbers is inserted, in the order given, into a binary search
tree. Which list produces the most balanced tree?
(a) 2, 4, 7, 5, 8, 10 (b) 9, 7, 2, 1, 4, 0
(c) 5, 1, 2, 6, 3, 4 (d) 6, 4, 1, 8, 10, 5
Ans :-d
Ans:-D

Most balanced among all four option is the D option.

Q25. How many AVL trees containing the keys 1, 2, 3, 4 can be built?
(a) 2 (b) 3
(c) 4 (d) 5

Ans :-C
Different AVL tree with the keys containing 1,2,3,4 are:-
(1) (2) (3)

Q26. Refer to method whatsIt:


int whatsIt (TreeNode *tree) {
int x, y;
if (tree = = null)
return -1;
else {
x = 1 + whatIt(treeLeft());
y = 1 + whatIt(treeRight());
if (x > = y)
return x;
else
return y;
}}
Method whatsIt returns -1 for an empty tree. What does method whatsIt do when invoked
for a nonempty tree?
(a) It returns the largest value in the tree.
(b) It returns the number of nodes in the subtree that has the greatest number of nodes.
(c) It returns the level of the tree.
(d) It returns either the leftmost value or the rightmost value of a tree, whichever is larger
Ans :- C

Whatsit(50) Whatsit(10) Whatsit(14)


X=1+ whatsit(10) X=1+ whatsit(14) X=1+ whatsit(null)
Y=1+whatsit(8) Y=1+ whatsit(null) Y=1+ whatsit(null)
x=2,y=1 x=1.y=0 x=0,y=0
Whatsit (null) =-1
 if return no.of level of tree.

For next two question:


Consider the following element are inserted in to an empty AVL tree in the given order 4, 10, 3, 8, 5, 2, 25
Q27. How many rotations are applied to construct an AVL tree with the given elements
(a)1 (b)2
(c)3 (d)4
Ans:-A
4, 10,3,8,5,2,25

Only one rotation is required


Q28. Identify the root element of AVL tree?
(a)10 (b)8
(c)5 (d)4
Ans :- D the root of the above tree is (4)
For next three questions consider the following tree:

Q29. What is the pre-order traversal of above tree?


(a) C D K G A J E B F H L (b) G A J K D E F L H B C
(c) C D E B K G A J F H L (d) C D K G J A B FH L E
Ans :-A
Pre order: - Root left child, middle child right child CDKGAJEBFHL

Q30. What is the post-order traversal of above tree?


(a)C D K G A J E B F H L (b) G A J K D E F L H B C
(c) C D E B K G A J F H L (d)C D E B K F H G A J L
Postorder: - Right Child middle child left child Root.
Postorder: - GAJKDEFLHBC.

Q31. What is the in-order traversal of above tree?


(a) G K A J D C E F B L H (b) G A K J D E C F B L H
(c) G K A J D C E F L H B (d) G K A J D C E F B H L
Indore :- left child Root Middle child Right child
: - First child Root other child
Indore: - G K A J D C E F B L H

Q32. A full binary tree with 2n+1 nodes contain


(a) n leaf nodes (b) n non-leaf nodes
(c) n-1 leaf nodes (d) n-1 non-leaf nodes
Ans:-B
A Full Binary Tree with 2n+1 nodes contains (n) non leaf node
Example
It contains 3 non-left node i.e n non leaf node
It contains 4 leaf nodes i.e n+1 leaf nodes.
Ans:-B

Q33. If a node in a BST has two children, then its inorder predecessor has
(a) no left child (b) no right child
(c) two children (d) no child

And:-B
And:-B
If a node in a BST has two children then its in order pre decessor has no right child
Example

Inorder: - 1 2 4 5 6 7 8 9
Consider the node 4
Its in order predecessor or is 2, it does not have right child .
And:-B

Q34. A full binary tree with n leaves contains


(a) n nodes (b) log2n nodes
(c) 2n –1 nodes (d) 2n nodes
Ans :-c
A full binary tree with n leaves contains 2n-1 nodes
Example

Q35. Which of these is not a binary search tree?

Ans :-a
For next two questions consider that the following keys are inserted keys into an AVL tree
in the Following order: 40, 20, 15, 25, 30, 80, 75, 95, 90, 35, 100
Q36. Which key would be in the root of the tree after inserting all the keys?
(a)75 (b) 40
(c) 35 (d) 30
Ans :-A
40,20,15,25,30,80,75,95,90,35,100
Q37. What is the height of the above AVL tree?(Assume root at height zero)
(a) 3 (b) 4
(c) 5 (d) 6
Ans :-B height of the tree is (4)
Q38. What is the best Big-O runtime (e.g., O(1), O(log n), O(h), or O(n)) for searching for an
element in each hierarchical data structure with n elements and tree height h?
(a) BinaryTree - O(n), BinarySearchTree - O(h), AVL Tree - O(log n)
(b) BinaryTree - O(logn), BinarySearchTree - O(n), AVL Tree - O(log n)
(c) BinaryTree - O(n), BinarySearchTree - O(n), AVL Tree - O(n)
(d) BinaryTree - O(h), BinarySearchTree - O(h), AVL Tree - O(log n)
Ans :-A
Binary tree:-0(n)
In worst case we have traverse all nodes to search an elements.
Binary Search tree:-O (h)
In binary search tree. Searching depends upon height of the tree .if it is chain
then o(n),(and d in chain O (h)=(n)
If it is balanced searching requires o (log n) i e o (n) =o (log n)
It depends upon the height in BST (they are asking about best big O,
We will prefer o (n) over o (n)
AVL tree: - O (log n)
Q39. What is the best Big-O runtime (e.g., O(1), O(log n), O(h), or O(n)) for inserting an element
into each hierarchical data structure with n elements and tree height h?
(a) BinaryTree - O(n), BinarySearchTree - O(h), AVL Tree - O(log n)
(b) BinaryTree - O(h), BinarySearchTree - O(n), AVL Tree - O(h)
(c) BinaryTree - O(n), BinarySearchTree - O(n), AVL Tree - O(log n)
(d) BinaryTree - O(h), BinarySearchTree - O(h), AVL Tree - O(log n)
Ans :-a
For insertion
Binary tree: - O (n)
BST: - o(n) insertion complexity o (n) is also correct but here in the question
they are asking about best big O – run time
We will prefer O (n) once O (n)
Avl Tree :- o (logn )

Q40. In how many ways we can insert the elements {1, 2, . . . , 7} into an empty AVL tree so that
we don’t have to perform any rotations on it?___________
Ans :- 240
With 3 as root we can insert in 8 different combination of only
{3} {2, 6} {1, 3, 7} {4}
{3} {1,6} {2 5 7} {4}
{3} {2 5} {1, 4 6} {7}
{3} {1 5} {2 4 6} {7}
{3} {2 6} {1 4 7} {5}
{3} {1 6} {2 4 3} {5}
{3} {2 5} {1 4 7} {6}
{3} {1 5} {2 4 7} {6}
Where each of the combinations permutated in 2!3! =12 ways this give total if
12*8 i.e 96 incretion sequence with 3as root.
With 4 as root balanced all only kind of AVL is created and sequence is
{4}{2, 6}{1, 3, 5,7}which given 48 permutation
With 5 as root we have 8 insertion sequence with 12 permutation in each
{same as 3 as root} i.e total of 12* 8 ie 96 sequence
So total ways to insert keys in AVL without rotation is 48+2* 96=48+192=240
Q41. Suppose a binary tree holds 127 keys. Then our node-based implementation of that tree has
how many NULL pointers?
(a) 64 (b) 128
(c) 256
(d) The answer cannot be determined from the information given.
Ans :-b
If a tree holds n keys then there are n+1 null pointer
Example

Q42. Assuming each node in a BST takes 20 bytes of storage, how much memory is (in bytes)
necessary to store a “perfect” binary tree of height 3?__________
Ans :300
A perfect binary tree is a binary tree in which all interior nodes name two
children and all leaves have the same depth or same level
Total nodes=15
Total space =15x 20=300 byte.
Q43. Which of the following height is not possible for a binary tree with 90 nodes?
(a) 7 (b) 6
(c) 5 (d) None of these

Ans :-c
Considering height starts with O.
Maximum no.of nodes with
Height 7=255
Maximum no.of nodes with
Height 6 =26+1 -1=27
Maximum no of node with
Height 5 =25+1=63
With 90nodes height 5 is not possible .
Q44. Suppose that we have numbers between 1 and 1000 in a binary search tree and want to
search for the number 363. Which of the following sequences could not be the sequences of
nodes examined?
(I) 2, 252,401, 398, 330, 344, 397, 363.
(II) 924,220,911,244,898,258,362,363.
(III) 925, 202, 911, 240, 912, 245, 363.
(IV) 2,399,387,219,266,382,381,278,363.
(V) 935, 278, 347, 621, 299, 392, 358, 363.
(a) I, II & III (b) III & V
(c) III, IV & V (d) II, IV, V
Ans :- B
(I) 2, 252, 401, 393, 330, 344, 397, 363
2, 252, 33, 344
401, 298, 397
This is possible
(II) 924, 220, 911, 244, 898, 258, 362, 363
220, 244, 252, 362
363
924, 911, 898.
This is also possible
(III) 925, 202, 911, 240, 912, 245, 363
202, 240, 245
925, 911, 912
This is not possible because this should be in decreasing order

(IV) 2, 399, 387, 219, 266, 382, 381, 278, 363,


2, 219, 266, 278
399, 387, 382, 381
This is also possible order.
(V) 935,278,347,621,299,392,358,363
Not in increasing order
273, 347, 299, 358
363
935, 621, 392
This is not a possible order .
For the next six questions, consider the following binary tree

Q45. What does the following code mystery return when called with the root node of a given
binary tree?______
Assume isLeaf is the Boolean function return true if the left and right child of a node is
NULL.
int Mystery(Node *root)
{
int res = 0;
if (root != NULL)
{
if (isLeaf(root->left))
res += root->left->key;
else
res += Mystery(root->left);
res += Mystery(root->right);
}
return res;
}

Ans :- 48

res+ res=res+5 res5 Res=5


res=res+mystery (9) res=res+my(12) res=res+my(5)
res=res+mystery
(49)
Stery(19) my(12) my(5)
Res=0
Res=5+23 res=28+50=78
res=28+my(52)

My (49) my (52)

Q46. What does the following Mystery function return when called with the root node of a given
binary tree ____________
int Mystery ( Node *root)
{
int ms, ls, rs;
if ( root == NULL )
return 0;
else
{
ls = Mystery( root->left);
rs = Mystery( root->right);
ms = root->value + ls + rs;
return ms;
}
}
Ans :- 235

Is =my(9) Is=my(5) Is=my(null) Is=my(null)


Is =my(49) Is=my(12) rs=my(null) rs=my(null)
ms=20+is+rs ms=9+is+rs ms=5+is+rs ms=12+is+rs
my(9) mu(5) my(12)
my (null)=0
ms=12+5+9=26
Is =my(23) Is=my(null) Is=my(50) Is=my(null)
Is =my(52) Is=my(null) rs=my(null) rs=my(null)
ms=49+is+rs ms=23+is+rs ms=52+is+rs ms=50+is+rs

My(49) my(23) my(52) my(50)


ms=50+52+23+49+5+12+9+20=235
Q47. What does the following Mystery function return when called with the root node of a given
binary tree? ____________
int Mystery(node *root)
{
if (!root)
return 0;
if (root->left == NULL && root->right == NULL)
return root->data;
int leftsum = Mystery(root->left);
int rightsum = Mystery(root->right);
root->data += leftsum;
return root->data + rightsum;
}
Ans :;-220 the given code the by of all value
=50+52+23+49+5+12+9+20+15=235
Q48. What will be the printed value when called printOrder1with the root node of a given binary
tree?
void printOrder1(struct node* node)
{
if (node == NULL)
return;
printOrder1(node->left);
printOrder1(node->right);
printf("%d\t ", node->data);
}
(a) 5 15 12 9 23 50 52 49 20
(b) 20 9 49 5 12 23 52 15 50
(c) 5 9 12 15 20 23 49 50 52
(d) 20 9 5 12 15 49 23 52 50
Ans :A
It is the algorithm for postorder
Tree

Post Order :- 5 15 12 9 23 50 52 49 20
Q49. What will be the printed value when called printOrder2with the root node of a given binary
tree?
void printOrder2(struct node* node)
{
if (node == NULL)
return;
printOrder2(node->left);
printf("%d\t ", node->data);
printOrder2(node->right);
}
(a) 5 15 12 9 23 50 52 49 20
(b) 20 9 49 5 12 23 52 15 50
(c) 5 9 12 15 20 23 49 50 52
(d) 20 9 5 12 15 49 23 52 50
Ans C it is algorithm for inorder

Inorder =5,9,12,20,23,49,50,52
Q50. What will be the printed value when called printOrder3 with the root node of a given binary
tree?
void printOrder3(struct node* node)
{
if (node == NULL)
return;
printf("%d\t ", node->data);
printOrder3(node->left);
printOrder3(node->right);
}
(a) 5 15 12 9 23 50 52 49 20
(b) 20 9 49 5 12 23 52 15 50
(c) 5 9 12 15 20 23 49 50 52
(d) 20 9 5 12 15 49 23 52 50
ans :d it is the algorithm for Preorder
Preorder :-20, 9 , 5,12,49,23,52,50

You might also like