Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose that we have a collection of n silver coins and a selection of n gold coins. All of the gold coins have a different

Suppose that we have a collection of n silver coins and a selection of n gold coins. All of the
gold coins have a different weight. But for each silver coin, we know that there is a gold coin
that weighs exactly the same amount. Assume we have a device that can compare two coins,
and tell us which is heavier (or if they weigh the same). This is the only way we can compare
the weights.
a) Give a brute force algorithm that we can use to arrange all of the coins into pairs that have
the same weight. What is the big-O efficiency of your algorithm?
b) Prove that any algorithm solving this problem must make (nlogn) comparisons.
c) Give an algorithm (based on quick sort) that can solve the problem in time O(nlogn) on
average. Explain why it works.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

Students also viewed these Databases questions

Question

Which of the following statements is not true about mortgages?

Answered: 1 week ago

Question

3. Maximize (the agreement function).

Answered: 1 week ago

Question

time complexity for ( i = 1 ; i Answered: 1 week ago

Answered: 1 week ago