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, 21.06.2019 15:00
Marissa is a high school student who wants to be a hydroelectric production manager. she talks to her guidance counselor about her education path, and the counselor says that she needs to get an associate’s degree from a four-year college and will follow that with significant on-the-job training. what error did the counselor make while advising marissa? marissa will not have on-the-job training. marissa also needs a three-year apprenticeship. marissa only needs to attend a two-year college. marissa needs a bachelor’s degree.
Answers: 1
question
Computers and Technology, 22.06.2019 09:00
Meenu wants to create a high quality drawing in a variety of colours. which device should she use for the same?
Answers: 1
question
Computers and Technology, 22.06.2019 16:20
Consider the following statements, then select one of the answers below: the signal() function shown below registers "sig_handler()" as the signal handler function for the sigkill signal, without the complexity of using when the sigkill signal is sent to a process running this code, by a user typing "kill -kill ", where the correct process id is used for to target the process, sig_handler() will be executed.
Answers: 1
question
Computers and Technology, 22.06.2019 23:30
The next button in the review section shows the next available comment. next slide with no comment. previous comment. edited comment.
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, 02.12.2019 06:31
question
History, 02.12.2019 06:31
Questions on the website: 13722363