subject

Suppose that you are given n red and n blue water jugs, all of different shapes and sizes. All red jugs hold different amounts of water, as do the blue ones. Moreover, for every red jug, there is a blue jug that holds the same amount of water, and vice versa. It is your task to find a grouping of the jugs into pairs of red and blue jugs that hold the same volume of water. To do so, you may perform the following operation: pick a pair of jugs, one red, one blue, fill the red jug with water, and then pour the water into the blue jug. This operation will tell you if the two jugs hold the same amount of water, and if not, which one holds more water. Assume that such a comparison takes one unit of time. Your goal is to find an algorithm that solves this problem. Remember that you may not directly compare two red jugs or two blue jugs. Describe an algorithm that uses (n?) comparisons (in worst case) to group the jugs into pairs. b. Prove a lower bound of ſlog3 (n!)] for the worst case, and log3 (n!) for the average case number of comparisons to be performed by any algorithm that solves this problem. c. Write pseudo-code for an algorithm that solves this problem and that runs in (average case) time (n logn). (Hint: modify the algorithms Partition() and Quicksort().)

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:10
Look at the far left lane in the picture. explain what the red car is doing and what it needs to do to travel safely.
Answers: 2
question
Computers and Technology, 23.06.2019 03:30
How can you repin an image on your pinterest pin board a. click on the "repin" button b. click on the "add pin" button c. click on the "upload a pin" button d. click on the "save pin" button.
Answers: 2
question
Computers and Technology, 23.06.2019 17:00
The more powerful, 60 volt cables and the main power shut-off on an hev are both colored orange.
Answers: 1
question
Computers and Technology, 24.06.2019 00:10
Read each statement below. if the statement describes a peer-to-peer network, put a p next to it. if the statement describes a server-based network, put an s next to it. p - peer-to-peer s - server-based
Answers: 1
You know the right answer?
Suppose that you are given n red and n blue water jugs, all of different shapes and sizes. All red j...
Questions
question
Mathematics, 29.09.2020 08:01
question
Mathematics, 29.09.2020 08:01
question
Mathematics, 29.09.2020 08:01
question
History, 29.09.2020 08:01
question
Mathematics, 29.09.2020 08:01
question
Mathematics, 29.09.2020 08:01
question
Mathematics, 29.09.2020 08:01
Questions on the website: 13722367