Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions