Q33Comprehension4 Marks11 Dec 2022
Passage
Based on the above data, answer the given subquestions.
nums is a list of integers in which each element lies in the range 1 to 10, endpoints inclusive. A sample list of size 20 could look like this:
L = [2, 1, 3, 5, 1, 4, 9, 5, 9, 4, 1, 3, 5, 6, 4, 7, 10, 1, 7, 5]
The actual list nums has size n.
Let us continue with the list nums and dictionary P. We wish to find the number which occurs the most number of times in nums. most_freq is a function which accepts the dictionary P as argument and returns the number in the list nums that has the highest frequency. Select the correct implementation of this function.
If multiple numbers have the same maximum frequency, then return the largest such number.