Which of the following best describes the role of the base case in a recursive implementation of Quick Sort?
To handle the comparison and swapping of elements during the sorting process
To define the condition when the array is fully sorted and the recursion should stop
To partition the array around a chosen pivot element
To select the pivot element for each recursive call
What is the space complexity of Bucket Sort in the average case, assuming a suitable hash function and uniform data distribution?
O(n)
O(1)
O(n log n)
O(log n)
Is Heap Sort a stable sorting algorithm?
Yes
No
What is the primary advantage of using a binary heap in Heap Sort?
Low memory overhead compared to other heap structures
Efficient searching of elements
Constant time insertion of elements
Maintaining a sorted order during element extraction
What is the significance of lexicographic sorting in string processing?
It sorts strings based on their lengths, from shortest to longest or vice versa.
It sorts strings in alphabetical order, considering the order of characters defined by the character encoding (e.g., ASCII or Unicode).
It sorts strings based on their hash values, making it very efficient for comparing large strings.
It sorts strings based on the number of vowels they contain.
What is the space complexity of Quick Sort in the average and worst case scenarios?
O(n) in the average case and O(log n) in the worst case
O(1) in both average and worst cases
O(log n) in the average case and O(n) in the worst case
O(n) in both average and worst cases
Which of the following is a common use case for Merge Sort?
Sorting a linked list
Finding the smallest element in an array
Sorting a nearly sorted array
Sorting a small array with less than 10 elements
How does the time complexity of Radix Sort compare to comparison-based sorting algorithms like Merge Sort and Quick Sort for integers with a wide range?
Radix Sort can be faster under certain conditions
Radix Sort has the same time complexity
Radix Sort is consistently faster
Radix Sort is always slower
Why is Quick Sort often preferred over Merge Sort in practice, despite having the same average-case time complexity?
Quick Sort is more memory-efficient due to its recursive nature
Quick Sort is an in-place sorting algorithm, while Merge Sort requires additional space for merging
Quick Sort has a lower constant factor in its time complexity, making it faster for smaller datasets
Quick Sort is easier to parallelize and implement on multi-core processors
What is the primary purpose of topological sorting in the context of graph algorithms?
To find the shortest path between any two nodes in a weighted graph.
To determine if a graph contains any cycles.
To arrange the nodes of a directed acyclic graph (DAG) in a linear order such that for every directed edge (u, v), node u comes before node v in the ordering.
To find the minimum spanning tree of a graph, connecting all nodes with the minimum total edge weight.