Q. In the worst case, what is the time complexity of Merge Sort?
-
A.
O(n)
-
B.
O(n log n)
-
C.
O(n^2)
-
D.
O(log n)
Solution
The worst-case time complexity of Merge Sort is O(n log n) because it always divides the array into halves.
Correct Answer:
B
— O(n log n)
Learn More →
Q. What is the space complexity of Heap Sort?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n log n)
Solution
Heap Sort has a space complexity of O(1) as it sorts the array in place.
Correct Answer:
A
— O(1)
Learn More →
Q. What is the time complexity of the worst-case scenario for Quick Sort when the pivot is the smallest or largest element?
-
A.
O(n)
-
B.
O(n log n)
-
C.
O(n^2)
-
D.
O(log n)
Solution
The worst-case time complexity for Quick Sort occurs when the pivot is the smallest or largest element, resulting in O(n^2).
Correct Answer:
C
— O(n^2)
Learn More →
Q. Which of the following statements about Heap Sort is true?
-
A.
It is a stable sort
-
B.
It is an in-place sort
-
C.
It is faster than Quick Sort
-
D.
It requires O(n^2) time in the worst case
Solution
Heap Sort is an in-place sorting algorithm, meaning it requires only a constant amount of additional space.
Correct Answer:
B
— It is an in-place sort
Learn More →
Q. Which sorting algorithm uses a divide-and-conquer strategy?
-
A.
Bubble Sort
-
B.
Selection Sort
-
C.
Merge Sort
-
D.
Insertion Sort
Solution
Merge Sort uses a divide-and-conquer strategy to sort the array.
Correct Answer:
C
— Merge Sort
Learn More →
Showing 1 to 5 of 5 (1 Pages)