Suppose that the votes of n people for different candidates (where there can be more than two candidates) for a particular office are the elements of a sequence. A person wins the election if this person receives a majority of the votes.
Pare 562
a) Devise a divide-and-conquer algorithm that deter- mines whether a candidate received a majority and, if so, determine who this candidate is. [Hint:
Assume that n is even and split the sequence of votes into two sequences, each with
b) Use the master theorem to give a big-O estimate for the number of comparisons needed by the algorithm you devised in part (a).
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Discrete Mathematics and Its Applications
- Elements Of Modern AlgebraAlgebraISBN:9781285463230Author:Gilbert, Linda, JimmiePublisher:Cengage Learning,Algebra & Trigonometry with Analytic GeometryAlgebraISBN:9781133382119Author:SwokowskiPublisher:CengageAlgebra: Structure And Method, Book 1AlgebraISBN:9780395977224Author:Richard G. Brown, Mary P. Dolciani, Robert H. Sorgenfrey, William L. ColePublisher:McDougal Littell