In this challenge we will compare two methods used to calculate the mode value of a list of numbers. In Maths, The mode is the value that appears most often in a set of data. For instance, considering the following list of numbers:
The mode is 8 as the value 8 appears 4 times. You will notice that it is easier to spot the mode of a list of numbers when the numbers are sorted. e.g.:
Method 1: Iterative Approach, using a sorted list
Method 2: Using a hash table to store the frequency of each value
This method relies on the use of a hash table (a.k.a dictionary data strucutre) to store the frequency of each distinct value of the list.
Both of the above algorithm will return the mode of a list. However, on occasion, there could be more than one mode value: if there are multiple numbers that occur with equal frequency, and more times than the others in the set. For instance:
The above list is bimodal as it has two modes: 8 and 30.
Your task is to adapt both of the above algorithms to make sure they identify all the mode values from a given list of numbers.