-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Boyer-Moore Majority Vote Algorithm -- -- The Boyer-Moore Majority Vote Algorithm determines if there in a list -- of votes is a candidate that holds more than half of the majority, and -- if so, finds this candidate. It does so in time linear in the length -- of the input list and constant memory. For a detailed description of -- the algorithm, see these papers: -- -- @package majority @version 1.1 module Algorithms.Majority -- | O(length xs), Determines if there in a list of votes xs -- is a candidate that has more than half of the votes, and if so, -- returns that canditate. -- -- E.g. applying majority on the string "AAACCBBCCCBCC" -- yields Just 'C', since 'C' has 7 out of 13 votes. majority :: Eq a => [a] -> Maybe a