Abstract
We consider the problem of finding the mode (an element that appears the maximum number of times) in a list of elements that are not necessarily from a totally ordered set. Here, the relation between elements is determined by ‘equality’ comparisons whose outcome is \(=\) when the two elements being compared are equal and \(\ne \) otherwise. In sharp contrast to the \(\varTheta (\frac{n\lg n}{m})\) bound known in the classical three way comparison model where elements are from a totally ordered set, a recent paper gave an \(O(\frac{n^2}{m})\) upper bound and \(\varOmega (\frac{n^2}{m})\) lower bound for the number of comparisons required to find the mode, where m is the frequency of the mode. While the number of comparisons made by the algorithm is roughly \(\frac{n^2}{m}\), it is not clear how the necessary bookkeeping required can be done to make the rest of the operations take \(\varTheta (\frac{n^2}{m})\) time.
In this paper, we give two mode finding algorithms, one taking at most \(\frac{2 n^2}{m}\) comparisons and another taking at most \(\frac{3n^2}{2m} + O(\frac{n^2}{m^2})\) comparisons. The bookkeeping required for both the algorithms are simple enough to be implemented in \(O(\frac{n^2}{m})\) time. The second algorithm generalizes a classical majority finding algorithm due to Fischer and Salzberg.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
References
Alonso, L., Reingold, E.M., Schott, R.: The average-case complexity of determining the majority. SIAM J. Comput. 26, 1–14 (1997)
Alonso, L., Reingold, E.M., Schott, R.: Determining the majority. Inf. Process. Lett. 47, 253–255 (1993)
Alonso, L., Reingold, E.M., Schott, R.: Analysis of Boyer and Moore’s MJRTY. Inf. Process. Lett. 113, 495–497 (2013)
Blum, M., Floyd, R.W., Pratt, V.R., Rivest, R.L., Tarjan, R.E.: Time bounds for selection. J. Comput. Syst. Sci. 7(4), 448–461 (1973)
Boyer, R.S., Moore, J.S.: MJRTY—a fast majority vote algorithm. In: Boyer, R.S. (ed.) Essays in Honor of Woody Bledsoe. Automated Reasoning Series, vol. 1, pp. 105–117. Springer, Netherlands (1991)
Dobkin, D.P., Munro, J.I.: Determining the mode. Theor. comput. sci. 12, 255–263 (1980)
Fischer, M.J., Salzberg, S.L.: Solution to problem 81–5. J. Algorithms 3, 376–379 (1982)
Jayapaul, V., Munro, J.I., Raman, V., Satti, S.R.: Sorting and selection with equality comparisons. In: Dehne, F., Sack, J.-R., Stege, U. (eds.) WADS 2015. LNCS, vol. 9214, pp. 434–445. Springer, Heidelberg (2015)
Knuth, D.E.: The Art of Computer Programming. Sorting and Searching, vol. III. Addison-Wesley, Reading (1973)
Munro, J.I., Spira, P.M.: Sorting and searching in multisets. SIAM J. Comput. 5(1), 1–8 (1976)
Misra, J., Gries, D.: Finding repeated elements. Sci. Comput. Program. 2(2), 143–152 (1982)
Reingold, E.M.: On the optimality of some set algorithms. J. ACM 19(4), 649–659 (1972)
Saks, M.E., Werman, M.: On computing majority by comparisons. Combinatorica 11(4), 383–387 (1991)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2016 Springer International Publishing Switzerland
About this paper
Cite this paper
Jayapaul, V., Raman, V., Satti, S.R. (2016). Finding Mode Using Equality Comparisons. In: Kaykobad, M., Petreschi, R. (eds) WALCOM: Algorithms and Computation. WALCOM 2016. Lecture Notes in Computer Science(), vol 9627. Springer, Cham. https://doi.org/10.1007/978-3-319-30139-6_28
Download citation
DOI: https://doi.org/10.1007/978-3-319-30139-6_28
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-30138-9
Online ISBN: 978-3-319-30139-6
eBook Packages: Computer ScienceComputer Science (R0)