Why is binary search a preferred algorithm for searching in sorted arrays compared to linear search?
Binary search uses less memory than linear search.
Binary search works correctly even on unsorted arrays, while linear search does not.
Binary search is easier to implement and understand than linear search.
Binary search has a time complexity of O(log n), which is significantly faster than linear search's O(n) complexity for large datasets.
In the context of Heap Sort, what is the process called where we ensure that a subtree maintains the heap property?
Sift-up
Heapify
Sift-down
Heap-balance
Counting sort is often used as a subroutine in which other sorting algorithm?
Merge Sort
Radix Sort
Heap Sort
Quick Sort
What is a potential limitation of Heap Sort compared to some other efficient sorting algorithms?
It is not well-suited for sorting linked lists.
Its average-case time complexity is worse than some other algorithms.
It is less efficient when the input data is already nearly sorted.
It requires the entire dataset to be in memory.
What is the primary advantage of using a binary heap in Heap Sort?
Efficient searching of elements
Low memory overhead compared to other heap structures
Constant time insertion of elements
Maintaining a sorted order during element extraction
Which of the following best describes the role of the base case in a recursive implementation of Quick Sort?
To partition the array around a chosen pivot element
To select the pivot element for each recursive call
To define the condition when the array is fully sorted and the recursion should stop
To handle the comparison and swapping of elements during the sorting process
What is a key characteristic of in-place partitioning within the context of Quick Sort?
The algorithm sorts the array by recursively dividing it into smaller subarrays and then merging them back together.
In-place partitioning is only applicable when the input array is already sorted in reverse order.
The partitioning process is performed entirely within the original array, without requiring the allocation of substantial additional memory proportional to the input size.
The partitioning step always selects the first element of the subarray as the pivot.
What is the space complexity of Bucket Sort in the average case, assuming a suitable hash function and uniform data distribution?
O(1)
O(n)
O(log n)
O(n log n)
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(log n) in the average case and O(n) in the worst case
O(1) in both average and worst cases
O(n) in both average and worst cases
How does Merge Sort handle the base case of a single-element subarray?
It considers a single-element array as inherently sorted.
It performs a swap operation on the element.
It throws an error, as a single-element array cannot be sorted.
It recursively divides the single-element array.