Q. What is the primary use of a queue data structure?
-
A.
To reverse elements
-
B.
To sort elements
-
C.
To manage tasks in order
-
D.
To store elements randomly
Solution
Queues are primarily used to manage tasks in the order they arrive, following the FIFO principle.
Correct Answer:
C
— To manage tasks in order
Learn More →
Q. What is the time complexity of inserting an element into a binary search tree (BST) in the average case?
-
A.
O(1)
-
B.
O(log n)
-
C.
O(n)
-
D.
O(n log n)
Solution
Inserting an element into a binary search tree (BST) has an average-case time complexity of O(log n).
Correct Answer:
B
— O(log n)
Learn More →
Q. Which traversal method visits all nodes of a binary tree in order?
-
A.
Pre-order
-
B.
In-order
-
C.
Post-order
-
D.
Level-order
Solution
In-order traversal visits all nodes of a binary tree in sorted order, visiting the left subtree, the node, and then the right subtree.
Correct Answer:
B
— In-order
Learn More →
Showing 1 to 3 of 3 (1 Pages)