Q. What is the primary purpose of a binary search tree?
-
A.
To store data in a sorted manner
-
B.
To allow for quick access to the last element
-
C.
To implement a stack
-
D.
To manage memory efficiently
Solution
A binary search tree is designed to store data in a sorted manner, allowing for efficient searching, insertion, and deletion.
Correct Answer:
A
— To store data in a sorted manner
Learn More →
Q. What is the result of an in-order traversal of the binary tree with root 1, left child 2, and right child 3?
-
A.
1, 2, 3
-
B.
2, 1, 3
-
C.
3, 1, 2
-
D.
1, 3, 2
Solution
In-order traversal visits the left child first, then the root, and finally the right child, resulting in 2, 1, 3.
Correct Answer:
B
— 2, 1, 3
Learn More →
Q. Which traversal method uses a queue data structure?
-
A.
In-order
-
B.
Pre-order
-
C.
Post-order
-
D.
Level-order
Solution
Level-order traversal uses a queue to keep track of nodes at the current level before moving to the next level.
Correct Answer:
D
— Level-order
Learn More →
Q. Which traversal method visits nodes in the order of left child, right child, root?
-
A.
In-order
-
B.
Pre-order
-
C.
Post-order
-
D.
Level-order
Solution
Post-order traversal visits the left child, then the right child, and finally the root node.
Correct Answer:
C
— Post-order
Learn More →
Showing 1 to 4 of 4 (1 Pages)