Q. In which scenario is Heap Sort particularly useful?
-
A.
When memory usage is a concern
-
B.
When the data is already sorted
-
C.
When the data is small
-
D.
When stability is required
Solution
Heap Sort is useful when memory usage is a concern because it sorts in place and requires no additional storage.
Correct Answer:
A
— When memory usage is a concern
Learn More →
Q. What is the main disadvantage of using Heap Sort?
-
A.
It is not stable
-
B.
It is slower than Quick Sort
-
C.
It requires additional memory
-
D.
It is complex to implement
Solution
The main disadvantage of Heap Sort is that it is not a stable sorting algorithm, which can be a drawback in certain applications.
Correct Answer:
A
— It is not stable
Learn More →
Q. What is the primary advantage of Quick Sort over other sorting algorithms?
-
A.
Stability
-
B.
Simplicity
-
C.
Average-case performance
-
D.
Worst-case performance
Solution
The primary advantage of Quick Sort is its average-case performance of O(n log n), which is better than many other algorithms.
Correct Answer:
C
— Average-case performance
Learn More →
Q. What is the space complexity of Quick Sort in the worst case?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n log n)
Solution
The space complexity of Quick Sort in the worst case is O(log n) due to the recursive stack space.
Correct Answer:
C
— O(log n)
Learn More →
Q. What is the worst-case 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), which is consistent regardless of the input data.
Correct Answer:
B
— O(n log n)
Learn More →
Q. Which sorting algorithm is stable?
-
A.
Quick Sort
-
B.
Heap Sort
-
C.
Merge Sort
-
D.
Selection Sort
Solution
Merge Sort is a stable sorting algorithm, meaning it maintains the relative order of equal elements.
Correct Answer:
C
— Merge Sort
Learn More →
Showing 1 to 6 of 6 (1 Pages)