Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Suppose you are given n apples and n oranges. The apples are all of different weights and all the oranges have different weight. However, for
Suppose you are given n apples and n oranges. The apples are all of different weights and all the oranges have different weight. However, for each apple there is a corresponding orange of the same weight and vice versa. You are also given a weighing machine that (counter to common intuition) will only compare apples to oranges: that is, if you feed an apple and an orange to the machine it will tell you whether the apple or the orange is heavier or if they have the same weight. Your goal is to use this machine to pair up each apple with the orange of the same weight with as few uses of the machine as possible Give a randomized algorithm to determining the pairing. For full-credit, your algorithm should only use the machine O(nlogn) times in expectation. You do not need to prove correctness or analyze the time-complexity of the algorithm. 75 points (Remember that you cannot compare an apple to an apple or an orange to an orange.)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started