Q. How many leaf nodes can a binary tree with n internal nodes have?
-
A.
n + 1
-
B.
n
-
C.
2n
-
D.
n - 1
Solution
A binary tree with n internal nodes can have n + 1 leaf nodes.
Correct Answer:
A
— n + 1
Learn More →
Q. In which traversal method are nodes visited in the order of left child, root, right child?
-
A.
Pre-order
-
B.
Post-order
-
C.
In-order
-
D.
Level-order
Solution
In In-order traversal, nodes are visited in the order of left child, root, and then right child.
Correct Answer:
C
— In-order
Learn More →
Q. In which traversal method do you visit the left subtree, then the root, and finally the right subtree?
-
A.
Pre-order
-
B.
In-order
-
C.
Post-order
-
D.
Level-order
Solution
In In-order traversal, the left subtree is visited first, followed by the root node, and then the right subtree.
Correct Answer:
B
— In-order
Learn More →
Q. What is the height of a binary tree with only one node?
-
A.
0
-
B.
1
-
C.
2
-
D.
It cannot be determined
Solution
The height of a binary tree with only one node is 0, as height is defined as the number of edges on the longest path from the root to a leaf.
Correct Answer:
A
— 0
Learn More →
Q. What is the main characteristic of a binary tree?
-
A.
Each node has at most two children.
-
B.
Each node can have any number of children.
-
C.
All nodes must have two children.
-
D.
It must be balanced.
Solution
The main characteristic of a binary tree is that each node has at most two children.
Correct Answer:
A
— Each node has at most two children.
Learn More →
Q. What is the maximum number of nodes in a binary tree of height h?
-
A.
h
-
B.
2^h - 1
-
C.
2^h
-
D.
h^2
Solution
The maximum number of nodes in a binary tree of height h is given by the formula 2^h - 1.
Correct Answer:
B
— 2^h - 1
Learn More →
Q. What is the post-order traversal of the binary tree with root A, left child B, and right child C?
-
A.
A B C
-
B.
B A C
-
C.
B C A
-
D.
C B A
Solution
In post-order traversal, the left child is visited first (B), then the right child (C), and finally the root (A), resulting in B C A.
Correct Answer:
C
— B C A
Learn More →
Q. Which of the following is NOT a characteristic of a binary search tree?
-
A.
Left subtree contains only nodes with values less than the root.
-
B.
Right subtree contains only nodes with values greater than the root.
-
C.
Both subtrees must be binary search trees.
-
D.
All nodes must have two children.
Solution
In a binary search tree, it is not necessary for all nodes to have two children; some nodes can have one or no children.
Correct Answer:
D
— All nodes must have two children.
Learn More →
Q. Which of the following is true about a complete binary tree?
-
A.
All levels are fully filled except possibly the last level.
-
B.
All nodes have two children.
-
C.
It is always balanced.
-
D.
It has a maximum height of log n.
Solution
In a complete binary tree, all levels are fully filled except possibly the last level, which is filled from left to right.
Correct Answer:
A
— All levels are fully filled except possibly the last level.
Learn More →
Q. Which traversal method is best for obtaining a sorted list from a binary search tree?
-
A.
Pre-order
-
B.
In-order
-
C.
Post-order
-
D.
Level-order
Solution
In-order traversal of a binary search tree yields the nodes in sorted order.
Correct Answer:
B
— In-order
Learn More →
Q. Which traversal method is best for printing the nodes of a binary tree level by level?
-
A.
In-order
-
B.
Pre-order
-
C.
Post-order
-
D.
Level-order
Solution
Level-order traversal is used to print the nodes of a binary tree level by level.
Correct Answer:
D
— Level-order
Learn More →
Q. Which traversal method visits the root node first in a binary tree?
-
A.
In-order
-
B.
Post-order
-
C.
Pre-order
-
D.
Level-order
Solution
In Pre-order traversal, the root node is visited first, followed by the left subtree and then the right subtree.
Correct Answer:
C
— Pre-order
Learn More →
Showing 1 to 12 of 12 (1 Pages)