You have n widgets, each of which is of a certain type.  You want to determine whether there is a majority type; i.e., if there is a type t such that the number of widgets of type t is greater than n/2. For instance, the set of 7 widgets with types A, A, B,C, A, C, A, respectively has a majority type A since there are 4 widgets of that type. On the other hand, the set of 6 widgets with types A, A, B, C, D, A has no majority type. Unfortunately, you are unable to determine the type of any given widget. Instead, the only operation available to you is to call a subroutine Equality Test that takes two widgets as input and returns True if both are of the same type and False otherwise. Give a divide-and-conquer algorithm for determining if there is a majority type in a given set of n widgets. The running time of your algorithm is the number of calls made by your algorithm to Equality Test.  Analyze the running time of your algorithm.  Ideally, the running time of your algorithm should be O(nlogn).  You will receive extra credit if the running time of your algorithm is O(n).

Operations Research : Applications and Algorithms
4th Edition
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Wayne L. Winston
Chapter17: Markov Chains
Section: Chapter Questions
Problem 12RP
icon
Related questions
Question

You have n widgets, each of which is of a certain type.  You want to determine whether there is a majority type; i.e., if there is a type t such that the number of widgets of type t is greater than n/2. For instance, the set of 7 widgets with types A, A, B,C, A, C, A, respectively has a majority type A since there are 4 widgets of that type. On the other hand, the set of 6 widgets with types A, A, B, C, D, A has no majority type. Unfortunately, you are unable to determine the type of any given widget. Instead, the only operation available to you is to call a subroutine Equality Test that takes two widgets as input and returns True if both are of the same type and False otherwise. Give a divide-and-conquer algorithm for determining if there is a majority type in a given set of n widgets. The running time of your algorithm is the number of calls made by your algorithm to Equality Test.  Analyze the running time of your algorithm.  Ideally, the running time of your algorithm should be O(nlogn).  You will receive extra credit if the running time of your algorithm is O(n).

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Intelligent Machines
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole