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 10:00
According to alisa miller foreign news bureaus
Answers: 3
question
Computers and Technology, 23.06.2019 00:30
Which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 2
question
Computers and Technology, 23.06.2019 01:00
Complete the sentence about a presentation delivery method
Answers: 2
question
Computers and Technology, 23.06.2019 19:00
Acompany is hiring professionals for web designing. the firm is small with few resources. they want employees who possess problem-solving skills and can independently carry out responsibilities. which kind of employee should they select?
Answers: 2
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, 03.11.2019 07:31