Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE SOLVE COMPLETELY AND SHOW ALL STEPS. Problem 3. Assume you execute quicksort using the version of partition from CLRS. We are inter- ested in

image text in transcribedPLEASE SOLVE COMPLETELY AND SHOW ALL STEPS.

Problem 3. Assume you execute quicksort using the version of partition from CLRS. We are inter- ested in the exact fewest number of comparisons quicksort will do as a function of n (i.e., its best case). Asume 2 where k is a natua nmber) (a) (i) Give an example with n 3 that does as few comparisons as possible. (ii) Give an example with n-7 that does as few comparisons as possible. (iii) Give an example with n-15 that does as few comparisons as possible. b) We might guess that the number of comparisons is approximately nlg(n+1)-2n. (Why?) Create a table with a column for n1,3,7,15; a column with the exact number of comparisons for quicksort in the best case; a column with the value of the approximate guess, n lg(n + 1)-2n; and a column with the difference between the exact value and the approximate guess. (c) Using the information from the above table give an exact formula for the number of comparisons. d) Write a recurrence for the number of comparisons in the best case as a function of n. (You may use your notes from class.) (e) Use mathematical induction to prove that your formula is a solution to the recurrence. Problem 3. Assume you execute quicksort using the version of partition from CLRS. We are inter- ested in the exact fewest number of comparisons quicksort will do as a function of n (i.e., its best case). Asume 2 where k is a natua nmber) (a) (i) Give an example with n 3 that does as few comparisons as possible. (ii) Give an example with n-7 that does as few comparisons as possible. (iii) Give an example with n-15 that does as few comparisons as possible. b) We might guess that the number of comparisons is approximately nlg(n+1)-2n. (Why?) Create a table with a column for n1,3,7,15; a column with the exact number of comparisons for quicksort in the best case; a column with the value of the approximate guess, n lg(n + 1)-2n; and a column with the difference between the exact value and the approximate guess. (c) Using the information from the above table give an exact formula for the number of comparisons. d) Write a recurrence for the number of comparisons in the best case as a function of n. (You may use your notes from class.) (e) Use mathematical induction to prove that your formula is a solution to the recurrence

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

Question

brain hat prototyping

Answered: 1 week ago

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago