The mode of a set of numbers is defined to be the number that occurs most frequently
Fantastic news! We've Found the answer you've been seeking!
Question:
The mode of a set of numbers is defined to be the number that occurs most frequently in the set. The set {4,6,2,4,3,1} has a mode of 4.
a) Suppose we know that there is an (unknown) element that occurs (n/2) + 1 times in the set. Design an O(n) time algorithm to find the mode. Justify the time complexity of your algorithm.
b) Design an algorithm to compute the mode of a set of n numbers. You should try to solve the problem in smallest running time. Justify the time complexity of your algorithm.
Related Book For
Posted Date: