Question: Can you give a linear-time algorithm? (Hint: Here's another divide-and-conquer approach: Pair up the elements of A arbitrarily, to get n=2 pairs Look at each
Can you give a linear-time algorithm? (Hint: Here's another divide-and-conquer approach: Pair up the elements of A arbitrarily, to get n=2 pairs Look at each pair: if the two elements are different, discard both of them; if they are the same, keep just one of them Show that after this procedure there are at most n=2 elements left, and that they have a majority element if and only if A does.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
