Question: Suppose we are given a n-element sequence S such that each element in S represents a different vote in an election, where each vote is

Suppose we are given a n-element sequence S such that each element in S represents a different vote in an election, where each vote is given as an integer representing the ID of the chosen candidate (these IDs come from the range 1 . . . n5 ). Suppose you know the number k < n of candidates running. Describe a O(n log k) worst-case algorithm for determining who wins the election. (Thus hashing will not work, as it does not have a good enough worst-case guarantee). The space requirement is O(n), so a table of size n 5 cannot be used. Argue that your running time is correct. Note that k could be much smaller than n and (n log n) is only a partial solution

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!