Q. In a binary tree, what does a null left child indicate?
-
A.
The node is a leaf
-
B.
The node has only a right child
-
C.
The node has no children
-
D.
The node is the root
Solution
A null left child indicates that the node is a leaf node, meaning it has no children.
Correct Answer:
A
— The node is a leaf
Learn More →
Q. What is the primary purpose of a binary tree's height?
-
A.
To determine the number of nodes
-
B.
To calculate the depth of nodes
-
C.
To evaluate the balance of the tree
-
D.
To find the maximum value
Solution
The height of a binary tree is primarily used to evaluate the balance of the tree, which affects its performance in operations.
Correct Answer:
C
— To evaluate the balance of the tree
Learn More →
Q. What traversal method would you use to get the nodes of a binary tree in sorted order?
-
A.
Pre-order
-
B.
In-order
-
C.
Post-order
-
D.
Level-order
Solution
In-order traversal of a binary search tree (BST) visits nodes in sorted order, making it the correct choice for this requirement.
Correct Answer:
B
— In-order
Learn More →
Q. Which of the following is a valid way to implement a binary tree in Python?
-
A.
Using a list
-
B.
Using a dictionary
-
C.
Using a class
-
D.
All of the above
Solution
A binary tree can be implemented using various data structures in Python, including lists, dictionaries, and custom classes.
Correct Answer:
D
— All of the above
Learn More →
Showing 1 to 4 of 4 (1 Pages)