Q. In a queue, which operation is performed in constant time?
-
A.
Enqueue
-
B.
Dequeue
-
C.
Peek
-
D.
All of the above
Solution
All operations (enqueue, dequeue, and peek) can be performed in constant time O(1) in a properly implemented queue.
Correct Answer:
D
— All of the above
Learn More →
Q. What is the time complexity of binary search on a sorted array?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
Binary search divides the array in half with each step, leading to a time complexity of O(log n).
Correct Answer:
B
— O(log n)
Learn More →
Q. Which of the following data structures allows for dynamic resizing?
-
A.
Array
-
B.
Linked List
-
C.
Stack
-
D.
Queue
Solution
A linked list can grow and shrink dynamically as elements are added or removed, unlike arrays which have a fixed size.
Correct Answer:
B
— Linked List
Learn More →
Q. Which of the following is a characteristic of a binary tree?
-
A.
Each node has at most two children
-
B.
Nodes are stored in a linear fashion
-
C.
All nodes have the same number of children
-
D.
It is always balanced
Solution
In a binary tree, each node has at most two children, which is a defining characteristic.
Correct Answer:
A
— Each node has at most two children
Learn More →
Q. Which of the following is NOT a characteristic of a stack?
-
A.
LIFO order
-
B.
Dynamic size
-
C.
Random access
-
D.
Push and pop operations
Solution
Stacks operate in a Last In First Out (LIFO) manner and do not allow random access; elements can only be accessed in the order they were added.
Correct Answer:
C
— Random access
Learn More →
Q. Which sorting algorithm has the best average-case time complexity?
-
A.
Bubble Sort
-
B.
Insertion Sort
-
C.
Merge Sort
-
D.
Selection Sort
Solution
Merge Sort has an average-case time complexity of O(n log n), which is better than the average-case complexities of the other options.
Correct Answer:
C
— Merge Sort
Learn More →
Showing 1 to 6 of 6 (1 Pages)