subject

Consider the following quicksort-like sorting algorithm.
Pick two elements of the list. Partition based on both of the elements. So the elements smaller than both are to the left, the elements in between are in the middle, and the elements larger than both are to the right.
(a) Given a brief English description of how you would partition. Write high-level pseudo-code for this algorithm. Try to minimize the number of comparisons. Your algorithm should use a linear number of comparisons.
(b) How many comparisons does the partition algorithm use in the worst case? Justify.
(c) How many comparisons does the partition algorithm use on average? Just get the high order term. Justify informally.
(d) Assume that the two partition elements always partition exactly into thirds. Write a recurrence for the number of comparisons. Solve this recurrence using constructive induction. Just get the high order term exactly.
(e) Assume that the two partition elements always partition so exactly one quarter are to the left, one half in the middle, and one quarter to the right. Write a recurrence for the number of comparisons. Solve this recurrence using constructive induction. Just get the high order term exactly.
(f) Challenge problem, will not be graded. Find the exact high order term for the average number of comparisons.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 16:30
You have inserted new slides based on a word outline. how do you format these new slides to match the powerpoint presentation formatting? a. select all slides in the presentation and click format on the home tab. b. select the new slides and click reset on the home tab. c. select all slides in the presentation and click reset on the home tab. d. select the new slides and click format on the home tab.
Answers: 2
question
Computers and Technology, 23.06.2019 11:00
What are the possible consequences of computer hacking? what is computer piracy? describe some examples. what are the effects of computer piracy? what are the possible consequences of computer piracy? what is intentional virus setting? describe some examples. what are the effects of intentional virus setting? what are the possible consequences of intentional virus setting? what is invasion of privacy? describe some examples. what are the effects of invasion of privacy? what are the possible consequences of invasion of privacy? what is an acceptable use policy and what is the purpose of the acceptable use policy what is intellectual property and how can you use it?
Answers: 1
question
Computers and Technology, 23.06.2019 19:00
Whose task it is to ensure that the product flows logically from one step to another?
Answers: 3
question
Computers and Technology, 25.06.2019 08:00
The bus width and bus speed together determine the bus's or bandwidth; that is, the amount of data that can be transferred via the bus in a given period of time.
Answers: 1
You know the right answer?
Consider the following quicksort-like sorting algorithm.
Pick two elements of the list. Parti...
Questions
question
Social Studies, 26.02.2021 23:20
question
Mathematics, 26.02.2021 23:20
question
Mathematics, 26.02.2021 23:20
question
Mathematics, 26.02.2021 23:20
question
Mathematics, 26.02.2021 23:20
question
Mathematics, 26.02.2021 23:20
question
Mathematics, 26.02.2021 23:20
question
Mathematics, 26.02.2021 23:20
Questions on the website: 13722367