Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please proof my work and give the answers. Be detailed :) 3. Consider Quick Sort on the array A[lin) and assume that the pivot element

Please proof my work and give the answers. Be detailed :) image text in transcribed
image text in transcribed
image text in transcribed
3. Consider Quick Sort on the array A[lin) and assume that the pivot element x (used to split the array Allo:hi) into two portions such that all elements in the left portion Allom are sx and all elements in the right portion A[m:hi) are >x) is the last element of the array to be split (i. e., A[hi]). For a specific value of n at least 11 (your choice), construct an assignment of the numbers 1...n to the n array elements that causes QuickSort, with the stated choice of pivot, to (a) execute optimally (that is Allo:m) and A[m:hi) are always of equal size) (6) execute in the slowest possible way. Exant! 204 Part Optimal qui A Optimal quicksort is when the preot is the medran of the subarray S. Tulefore, we have to have a set where the first element of the subarry is the subarray is the medran of the Subarray. 9 10 11 mearca n=11= 1 2 3 4 5 6 7 8 start with 1, 2, 3 > 213 213456 +413256 -613254 next half 7,8,9 8 79 8 7 9 10 11 9781011 (n = 6, 1, 3, 2,5,4,9,7,8,10,11 Part B Worst possible Sorted. possible Turcksort is of the que set was already [h=1,2,3,4,5,6,7,8,9,10,11 / 6132 5 4 9 7 810ll [613 25] 4 [9 7 8 10 11] [21] [35]4[67] [89] [101] 1 2 3 4 5 7 8 9 10 11

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

Students also viewed these Databases questions