Answered step by step
Verified Expert Solution
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
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 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 recurrenceStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started