DEV Community

Discussion on: Fun With Linear Time: My Favorite Algorithm

Collapse
 
healeycodes profile image
Andrew Healey

It seems pretty rare that you'd have a large data set and know that there is a majority without knowing what that majority is. But if that was the case, then this would be the optimal algorithm.

It was more important when older computers had different restrictions:

Note that the algorithm fetches the elements of A in linear order. Thus, the algorithm can be used efficiently when the number of votes is so large that they must be read from magnetic tape.