Q. In which scenario does Quick Sort perform poorly?
-
A.
When the array is already sorted
-
B.
When the array is in reverse order
-
C.
When the array has many duplicate elements
-
D.
When the array is small
Solution
Quick Sort performs poorly with a time complexity of O(n^2) when the array is already sorted, especially if the pivot is chosen poorly.
Correct Answer:
A
— When the array is already sorted
Learn More →
Q. What is the average time complexity of the Quick Sort algorithm?
-
A.
O(n)
-
B.
O(n log n)
-
C.
O(n^2)
-
D.
O(log n)
Solution
The average time complexity of Quick Sort is O(n log n) due to its divide-and-conquer approach.
Correct Answer:
B
— O(n log n)
Learn More →
Q. What is the primary data structure used in the implementation of Heap Sort?
-
A.
Array
-
B.
Linked List
-
C.
Stack
-
D.
Queue
Solution
Heap Sort primarily uses an array to represent the binary heap structure.
Correct Answer:
A
— Array
Learn More →
Q. What is the space complexity of Merge Sort?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n log n)
Solution
The space complexity of Merge Sort is O(n) because it requires additional space for the temporary arrays used during merging.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the worst-case time complexity of Heap Sort?
-
A.
O(n log n)
-
B.
O(n^2)
-
C.
O(n)
-
D.
O(log n)
Solution
The worst-case time complexity of Heap Sort is O(n log n) because it builds a heap and then sorts it.
Correct Answer:
A
— O(n log n)
Learn More →
Q. Which of the following is NOT a characteristic of Quick Sort?
-
A.
In-place sorting
-
B.
Recursive algorithm
-
C.
Stable sorting
-
D.
Divide-and-conquer
Solution
Quick Sort is not a stable sorting algorithm, meaning it does not guarantee the relative order of equal elements.
Correct Answer:
C
— Stable sorting
Learn More →
Q. Which of the following sorting algorithms 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 →
Q. Which sorting algorithm is based on the divide-and-conquer paradigm?
-
A.
Bubble Sort
-
B.
Insertion Sort
-
C.
Merge Sort
-
D.
Selection Sort
Solution
Merge Sort is a sorting algorithm that uses the divide-and-conquer paradigm to sort elements.
Correct Answer:
C
— Merge Sort
Learn More →
Q. Which sorting algorithm is generally faster for small datasets?
-
A.
Quick Sort
-
B.
Merge Sort
-
C.
Heap Sort
-
D.
Insertion Sort
Solution
Insertion Sort is generally faster for small datasets due to its low overhead and simplicity.
Correct Answer:
D
— Insertion Sort
Learn More →
Showing 1 to 9 of 9 (1 Pages)