Question: 5 points. Select all answers that apply for each question 1.1-1.5. 1.1 Given the array [13, 1, 3, 2, 8, 21, 5, 1] suppose we
5 points. Select all answers that apply for each question 1.1-1.5. 1.1 Given the array [13, 1, 3, 2, 8, 21, 5, 1] suppose we choose the pivot to be 1 the second element in the array. Which of the following would be valid partitions? A. 1 [1, 2, 3, 5, 8, 13, 21] B. 1 [13, 1, 3, 2, 8, 21, 5] C. 1 [13, 3, 2, 8, 21, 5, 1] D. [1] 1 [13, 3, 2, 8, 21, 5] E. [13] 1 [3, 2, 8, 21, 5, 1] F. [13, 1, 3, 2, 8, 21, 5] 1 2/4 1.2 Suppose we want to create a new quicksort-inspired algorithm that has worst-case (n log n) complexity. Which of the following designs would achieve this goal? A. Before partitioning, check if the input is nearly sorted, then perform insertion sort instead B. Only perform at most logz(n) levels of recursion, and then switch to merge sort. C. Always use the middle element in the list as the pivot instead of the last. D. Shuffle the elements in the array after each stage of partitioning 1.3 Which of the following is true about sorting functions? A. The most optimal partitioning policy for quicksort on an array we know nothing about would be selecting a random element in the array B. The fastest possible comparison sort has a worst case no better than O(n log n). C. Heapsort is usually best when you need a stable sort. D. Sorting an already sorted array of size n with quicksort takes O(n log n) time E. When sorting elements that are expensive to copy, it is generally best to use merge sort. F. None of the above statements is true
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
