多数投票算法 --- A linear time majority vote algorithm

算法文档原文:

A Linear Time Majority Vote Algorithm

This algorithm, which Bob Boyer and I invented in 1980 decides which element of a sequence is in the majority, provided there is such an element. How would you determine the majority element of:
sequence:  A A A C C B B C C C B C C
You could count the number of occurrences of each element. Here is how we do it, in one pass.

For details, see


A A A C C B B C C C B C C

你可能感兴趣的:(Python,算法)