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 20:00
What is used to analyze and summarize your data without graphical support
Answers: 1
question
Computers and Technology, 24.06.2019 00:00
Visualizing a game of “tag” to remember the meaning of contagious
Answers: 3
question
Computers and Technology, 24.06.2019 10:30
This device directs network traffic. bridge hub nic repeater router switch
Answers: 3
question
Computers and Technology, 24.06.2019 17:40
Write a program that begins by reading in a series of positive integers on a single line of input and then computes and prints the product of those integers. integers are accepted and multiplied until the user enters an integer less than 1. this final number is not part of the product. then, the program prints the product. if the first entered number is negative or 0, the program must print “bad input.” and terminate immediately
Answers: 2
You know the right answer?
Consider the following quicksort-like sorting algorithm.
Pick two elements of the list. Parti...
Questions
question
English, 06.04.2021 20:20
question
Computers and Technology, 06.04.2021 20:20
Questions on the website: 13722363