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

Tree Sample Question

1) The document contains questions about binary trees, binary search trees, and tree traversals. It asks the reader to draw trees based on given conditions, perform traversals, calculate properties of trees, and evaluate expressions represented as trees. 2) It provides examples of constructing binary search trees from sorted data, calculating heights and properties of full m-ary trees, and representing expressions as prefix notation. 3) The questions cover a wide range of tree topics including tree drawings, traversals, calculations involving tree properties, building binary search trees, and evaluating prefix expressions.
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)
108 views

Tree Sample Question

1) The document contains questions about binary trees, binary search trees, and tree traversals. It asks the reader to draw trees based on given conditions, perform traversals, calculate properties of trees, and evaluate expressions represented as trees. 2) It provides examples of constructing binary search trees from sorted data, calculating heights and properties of full m-ary trees, and representing expressions as prefix notation. 3) The questions cover a wide range of tree topics including tree drawings, traversals, calculations involving tree properties, building binary search trees, and evaluating prefix expressions.
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/ 5

1) Draw a tree using the following information:

i) The parent of h is g.
ii) The ancestors of d are (from top to bottom) g, f and l.
iii) e, k and l are siblings.
iv) The descendants of h are a, b, i and j.
v) a, b, c and d are leaves at level 3.
vi) a and b has no other siblings. viie, j and k are leaves.
viii) The tree is balanced.

2) A full m-ary tree has 136 vertices. Among them, 109 are leaves. Calculate
the values of m, and the number of edges in the tree.
3) Considering the dictionary order, construct a Binary Search Tree from the
strings given below. You must follow the order in which the strings are
given
4) Show the result of post-order traversal on the tree you constructed.
5) Is the tree you constructed a balanced tree? Explain your answer in one
sentence.
6) Draw the BINARY TREE that satisfies all of the following conditions.
Letters a − l represent vertices of the tree.
i. The parent of b is e
ii. d is the right child of e.
iii. The left and right children of d are f and a respectively. iv. c and g are
siblings (left and right respectively) and belong t
iv. c and g are siblings (left and right respectively) and belong to the same
level as a. v. The ancestors of j (from bottom to top) are a, d and e. vi. a
does not have any right child. vii. The descendants of g are i, l, k and h.
viii. l is a leaf and is the right child of g. ix. i and h are leaves that belong
to the highest level of the tree.
7) Is the tree you have drawn in question 3(a)
i. A full binary tree? Explain your answer.
ii. A balanced tree? Explain your answer.
8) A full m-ary tree has 271 vertices and 226 leaves. Calculate the number
of edges, the number of internal vertices, and the maximum number of
children that any internal vertex has.
9) Consider the following values for question 4(a): x = (LAST THREE DIGITS
OF YOUR STUDENT ID % 10) + 70 y = (LAST THREE DIGITS OF YOUR
STUDENT ID % 10) + 160
(a) Build a binary search tree for the indexes: 131, x, 140, 146, 148, 99,
156, y, 121, 118, 126, 111. What is the height of this BST?
(b) Provide the prefix and the postfix notations of the following
expression:
(((P + Q) ∗ R)/(P ∗ Q)) + (R/S)
(c) Evaluate the value of the following prefix expression
− + 2 ∗ 3 4 / 16 ↑ 2 3

10) Suppose a binary search tree has only 4 vertices who have no children. Find
out the total number of vertices of the tree.
11) Observe these 7 letters from the English alphabet, ’A’, ’C’, ’E’, ’H’, ’I’, ’S’, ’T’.
Considering the dictionary order, construct a Binary Search Tree from the
letters.
12) Find out the number of edges and height of the tree you constructed in
Question 11. Based on the height, what is the maximum limit of the number of
leaves in such a tree?
13) Is the tree you constructed in Question 11 a balanced tree? Explain with
proper reasoning.
14) Show the order of vertices generated by inorder traversal of the ordered
tree.

15) Show that postorder traversals of both ordered rooted trees in the
following Figures produce the same list of vertices.
16) Represent the expression ((y + 2) ↑ 3) ∗ (x − (y + 3)) − 8 using a binary tree.
Write this expression in Prefix notation.
17) Evaluate the following postfix expression : 9 3 / 5 + 7 2 − ∗
18) Construct a binary search tree from the following sequence of numbers: 50,
30, 90, -10, 120, -40, 70, 60, -20, 80.
19) Draw an ordered rooted tree (T) from the following expression: 2 + 3/(2 −
1) + 5 ∗ (4−1)
20) Find the prefix expression from the above rooted tree (T) and find the
result from the prefix expression
21) Calculate the number of total edges in a full 3-ary tree with 24 internal
vertices.
22) A tree has 11 vertices, namely a,b,c,d,e,f,g,h,i,j and k. Here are some
information about the vertices: i. a is the root ii. The ancestors of k are (in the
decreasing order of level) g,f,b and a iii. i and j are children of c iv. d and e are
siblings of f v. f is the parent of h vi. c is in level 1 Draw the rooted tree
23) A full m-ary tree has 53 internal vertices and 319 leaves. Find out the value
of m
24) Draw a binary search tree using the following words. Consider dictionary
order of the words. Job, Five, Suffer, Smooth, Remarkable, Bird, Carry, Design.
25) Show the postfix notation for the following expression: (𝑎 + 𝑏 ∗ 𝑐) / 7 + (3 ↑
2 ∗ (𝑑 − 𝑒)) + (𝑓 + 8)
26) Evaluate the following postfix notation: 3 4 + 2 5 + / 2 5 3 - * 1 - + 3 3 ↑ +
27)

28)
Evaluate the following postfix notation: 3 4 + 2 5 + / 2 5 3 - * 1 - + 3 3 ↑ +
29)
Using the rooted tree (T) in 27 , find out the following: (i) Parent of C (ii)
Descendant of R (iii) Ancestor of G (iv) Find out the integer value of m for the
rooted tree T and also find out if it’s a full m-ary tree or not.
30) Construct a binary search tree using the following integers:
15,1,-5,18,16,5,-6
31)

32)
Using the rooted tree (T1) in 31) , find out the following: (i) Siblings of d, (ii)
Ancestor of f, (iii) Children of m, (iv) Subtree rooted at g
33)

You might also like