Q. If a binary tree is balanced, what is the maximum height of the tree in terms of the number of nodes 'n'?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
In a balanced binary tree, the maximum height is O(log n), as the tree is structured to minimize height.
Correct Answer:
B
— O(log n)
Learn More →
Q. In a binary tree, what is the height of a tree with only one node?
-
A.
0
-
B.
1
-
C.
2
-
D.
Undefined
Solution
The height of a 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 post-order traversal sequence of a binary tree with root 1, left child 2, and right child 3?
-
A.
1, 2, 3
-
B.
2, 3, 1
-
C.
3, 2, 1
-
D.
1, 3, 2
Solution
In post-order traversal, we visit the left subtree, then the right subtree, and finally the root. Thus, the sequence is 2, 3, 1.
Correct Answer:
B
— 2, 3, 1
Learn More →
Q. What is the result of a level-order traversal on a binary tree with root 1, left child 2, and right child 3?
-
A.
1, 2, 3
-
B.
2, 1, 3
-
C.
1, 3, 2
-
D.
3, 2, 1
Solution
In level-order traversal, we visit nodes level by level from top to bottom, resulting in the sequence 1, 2, 3.
Correct Answer:
A
— 1, 2, 3
Learn More →
Q. Which of the following statements about binary trees is true?
-
A.
A binary tree can have at most two children per node.
-
B.
A binary tree must be balanced.
-
C.
A binary tree can only have integer values.
-
D.
A binary tree cannot be empty.
Solution
A binary tree is defined as a tree data structure in which each node has at most two children, often referred to as the left and right child.
Correct Answer:
A
— A binary tree can have at most two children per node.
Learn More →
Showing 1 to 5 of 5 (1 Pages)