Question
Algorithms You are given n metal balls B_1,.......,B_n, each having a different weight. You can compare the weights of any two balls by comparing their
Algorithms
You are given n metal balls B_1,.......,B_n, each having a different weight. You can compare the weights of any two balls by comparing their weights using a alance to find which one is heavier.
Consider the followin algorithm to find the heaviest ball:
i. Divide the n balls into n/2 pairs of balls
ii. Compare each ball with its pair, and retain the heavier of the two
iii. repeat this process until just one ball remains.
Question: Show that for "n" balls, the algorithm uses at most n comparisons.
(Please illustrate detailed understanding of the problem)
Thank you!
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