Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are given n metal balls B1, . . . , Bn, each having a different weight. You can compare the weights of any two

You are given n metal balls B1, . . . , Bn, each having a different weight. You can compare the weights of any two balls by weighing them on a balance and finding which one is heavier.

(A) Consider the algorithm to find the heaviest ball as follows: 1. Divide the n balls into n 2 pairs of balls. 2. Compare each ball with its pair, and retain the heavier of the two. 3. Repeat the process, until just one ball remains. 1 Illustrate the weighings that the algorithm will do for data given n = 8 and the weights are B1 : 3, B2 : 5, B3 : 1, B4 : 2, B5 : 4, B6 : 0.5, B7 : 2.5, B8 : 4.5 .

(B) Show that for n balls, the algorithm in (A) uses at most n weighings.

(C) Describe an algorithm that uses the results of (A) to find the second heaviest ball using at most log2 (n) additional weighings. (

D) Illustrate the additional weighings that your algorithm in (C) will perform for the data from part (A).

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

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago