Sample questions
Question 1Medium
'......' Is a directed tree in which outdegree of each node is less than or equal to two.
- Unary tree
- Binary tree
- Dinary tree
- Both B and C
Answer: B. Binary tree
Explanation
Binary tree Is a directed tree in which outdegree of each node is less than or equal to two.
Step-by-step solution
- The question defines a directed tree where each node has out degree at most two.
- That is the definition of a binary tree, option B.
- Option D also needs option C (Dinary) to match, and the question gives no such definition for it.
- So the correct answer is option B, Binary tree.
Why the other options are wrong
- A. A unary tree is not the tree with out degree at most two.
- C. Dinary is not the name matched by the question's definition; binary is.
- D. It depends on option C matching the definition, which the question does not show.
Tip: Out degree at most 2 = binary tree; out degree at most d = d-ary tree.
Question 2Medium
A '_' is an acyclic digraph, which has only one node with indegree 0, and other nodes have indegree 1.
- Directed tree
- Undirected tree
- Dis-joint tree
- Direction oriented tree
Answer: A. Directed tree
Explanation
A directed graph, or digraph, is a graph in which the edges connect vertices in a specific direction.
A digraph differs from a tree in that -
it need not have a root node.
there may be several (or no) paths from one vertex to another.
it is processed differently. Take insertion for example. To add a node to a tree, a link field must be added to a parent node. For a directed graph, a node may be inserted, but there need not be an arc to or from it; or an edge can be inserted between two existing nodes.
Step-by-step solution
- A tree has one root with indegree 0.
- All other nodes have indegree 1.
- This matches the definition of a directed tree.
- Directed tree is an acyclic digraph.
- Final answer: Directed tree.
Why the other options are wrong
- B. Undirected tree does not have direction.
- C. Disjoint tree refers to separate trees, not structure.
- D. Direction oriented tree is not a standard term.
Tip: Remember: Directed tree has one root and no cycles.
Question 3Medium
The number of possible ordered trees with 3 nodes A, B, C is
- 16
- 12
- 6
- 10
Answer: B. 12
Explanation
It is 12. The tree may be of depth 2 or 1. if the depth is 2, we have 6 possible trees. This is because one of the three nodes A, B, C may be the root and the next level may be one of the remaining two nodes. If the depth is 1, the root may be one of the 3 nodes A, B, C. Corresponding to a root, say A, two trees as possible as this.
Step-by-step solution
- In an ordered tree the order of children matters.
- Chain shape (depth 2): choose the root, then the middle node; the last node is the leaf. That is 3 × 2 = 6 ways.
- Root with two ordered children: choose the root, then order the other two. That is 3 × 2 = 6 ways.
- Total is 6 + 6 = 12: option B.
Why the other options are wrong
- A. 16 overcounts; the valid number of ordered trees is 12.
- C. 6 counts only the chain shape and misses the root with two children.
- D. 10 misses some ordered shapes; the correct total is 12.
Tip: Labelled ordered trees on 3 nodes = 2 shapes × 3! labellings = 12.
Question 4Medium
The number of possible binary trees with 4 nodes is
- 12
- 13
- 14
- 15
Answer: C. 14
Explanation
Eight possible trees of depth 3. Six possible trees of depth 2. Altogether 14.
Step-by-step solution
- The number of distinct binary trees with n nodes is the Catalan number, C(n) = (2n)! ÷ ((n+1)! × n!).
- For n = 4: 8! ÷ (5! × 4!) = 40320 ÷ (120 × 24) = 40320 ÷ 2880 = 14.
- So there are 14 different binary tree shapes with 4 nodes.
- The correct answer is option C, 14.
Why the other options are wrong
- A. 12 is below the count of 14.
- B. 13 is one short of the count of 14.
- D. 15 is one more than the count of 14.
Tip: Binary tree shapes with n nodes follow the Catalan numbers: 1, 2, 5, 14 for n = 1 to 4.
Question 5Medium
When representing any algebraic expression E which uses only binary operations in a 2-tree,
- the variable in E will appear as external nodes and operations in internal nodes
- the operations in E will appear as external nodes and variables in internal nodes
- the variables and operations in E will appear only in internal nodes
- the variables and operations in E will appear only in external nodes
Answer: A. the variable in E will appear as external nodes and operations in internal nodes
Explanation
Consider any algebraic expression E involving only binary operations, such as
E = (a-b)/((c*d)-1-e)
E can be represented by means of the binary tree T.That is, each variable or constant in E appears as an "internal" node in T whose left and right subtrees correspond to the operands of the operation.
Step-by-step solution
- Binary operations require two operands, so they must be internal nodes.
- Variables are operands, so they appear as external nodes.
- Each operation connects two external nodes.
- Thus, variables are external and operations are internal.
- Final answer: the variable in E will appear as external nodes and operations in internal nodes.
Why the other options are wrong
- B. Operations should be internal, not external.
- C. Both variables and operations cannot be only internal.
- D. Both cannot be only external as operations need operands.
Question 6Medium
A binary tree T has n leaf nodes. The number of nodes of degree 2 in T is
- log2n
- n - 1
- n
- 2n
Answer: B. n - 1
Explanation
Total no. of nodes in the tree n = n0 + n1 + n2
Where ni is the number of nodes with i children.
Total no. of edges in the tree e = n0*0 + n1*1 + n2*2
But e = n - 1
n1 + 2*n2 = n0 + n1 + n2 - 1
n2 = n0 - 1
n2 = n - 1
Step-by-step solution
- Total nodes = leaf nodes + degree 1 nodes + degree 2 nodes.
- Edges in tree = total nodes - 1 = n0 + n1 + n2 - 1.
- Edges also equal to sum of children: n1 + 2*n2.
- Equating both edge counts: n1 + 2*n2 = n0 + n1 + n2 - 1.
- Simplify to get n2 = n0 - 1.
- Since leaf nodes (n0) = n, then n2 = n - 1.
Why the other options are wrong
- A. Logarithmic relation not valid for binary tree node counts.
- C. Leaf nodes are not equal to degree 2 nodes in a binary tree.
- D. Double counting leaf nodes is incorrect logic.
Tip: Remember: degree 2 nodes = leaf nodes - 1 in any binary tree.
Question 7Medium
A binary tree in which every non-leaf node has non-empty left and right subtrees is called a strictly binary tree. Such a tree with 10 leaves
- cannot have more than 19 nodes
- has exactly 19 nodes
- has exactly 17 nodes
- cannot have more than 17 nodes
Answer: B. has exactly 19 nodes
Explanation
A strictly binary tree with 'n' leaves must have (2n-1) nodes. Verify for some small 'n'.
Step-by-step solution
- Strictly binary trees have every non-leaf node with two children.
- Formula: total nodes = 2 * leaves - 1.
- Leaves = 10, so total nodes
= 2 * 10 - 1
= 19.
- Thus, the tree has exactly 19 nodes.
Why the other options are wrong
- A. Cannot have more than 19 nodes is wrong as it has exactly 19.
- C. 17 nodes would mean only 9 leaves, not 10.
- D. Cannot have more than 17 nodes is wrong as it has exactly 19.
Tip: Remember: strictly binary trees follow total nodes = 2n - 1 where n is leaves.
Question 8Medium
The number of nodes a null tree can have is
- One
- Three
- Zero
- Null tree is invalid tree.
Answer: C. Zero
Explanation
A null tree, also known as an empty tree, has no nodes. Therefore, the number of nodes in a null tree is zero.
Step-by-step solution
- A null tree means there are no nodes.
- Therefore, the count of nodes is 0.
- The correct answer is Zero.
Why the other options are wrong
- A. One node contradicts the definition of a null tree.
- B. Three nodes is not possible in a null tree.
- D. Null tree is valid and has zero nodes.
Tip: Remember: Null tree = zero nodes.
Question 9Medium
State true or false.
i) An empty tree is also a binary tree.
ii) In strictly binary tree, the outdegree of every node is either o or 2.
- True, False
- False, True
- True, True
- False, False
Answer: C. True, True
Explanation
An empty tree is considered a binary tree by definition because it satisfies all the properties of a binary tree, including having at most two children per node. In a strictly binary tree, every node has either zero or two children, which matches the given statement perfectly.
Step-by-step solution
- Statement i: an empty tree is a binary tree by definition, so statement i is true.
- Statement ii: in a strictly binary tree every node has 0 or 2 children, so its out degree is 0 or 2, which is true.
- Both statements are true, so the pair is True, True and the correct answer is C (True, True).
Why the other options are wrong
- A. Statement ii is true, so 'False' for it is wrong.
- B. Statement i is true, so 'False' for it is wrong.
- D. Both statements are true, so 'False, False' is wrong.
Tip: Strictly binary tree: every node has 0 or 2 children; the empty tree counts as a binary tree.
Question 10Medium
A complete n-ary tree is one in which every node has 0 or n sons. If x is the number of internal nodes of a complete n-ary tree, the number of leaves in it is given by,
- x (n-1) + 1
- xn-1
- xn + 1
- x (n + 1)
Answer: A. x (n-1) + 1
Explanation
Degree of internal nodes (except root) = n + 1
Degree of root = n
Degree of leaf nodes = 1
Also No of edges = no. of nodes 1
But n = x + L Thus, no. of edges = x + L -1
From graph theory: sum of degree = 2 * (no. of edges)
Case 1: the tree has only 1 node.
Sum of degree
= 2 * (no of edges)
= 0
Case 2: The tree has more than one node.
(n + 1) * (x - 1) + n + L
= x + L -1
Step-by-step solution
- Let x be the internal nodes and L the leaves; each internal node has n children.
- Total nodes = x + L, so total edges = x + L - 1.
- Edges also equal n × x, since every internal node has n children.
- So x + L - 1 = nx, which gives L = x(n - 1) + 1: option A.
Why the other options are wrong
- B. Xn - 1 ignores the leaves and is not the leaf count.
- C. Xn + 1 is wrong; the leaf count is x(n - 1) + 1.
- D. x(n + 1) gives too many leaves.
Tip: Leaves = internal nodes × (n - 1) + 1. Check with n = 2: one root gives 2 leaves.
Practise all 22 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →