A program P reads 500 integers in the range from 0 to 100 representing the marks of 500 students. It then print the

frequency of each mark above 50. Suggest the best data structure for P to store the frequencies and justify.

The best data structure for program P to store the frequencies of marks above 50 would be a hashmap.

A hashmap allows for constant time lookup and insertion, making it very efficient for storing and updating frequencies. In this case, the hashmap can store the mark as the key and the frequency as the value. Whenever a mark above 50 is read, the program can simply check if the mark is already in the hashmap and update the frequency accordingly.

Additionally, a hashmap allows for easy retrieval of frequencies when needed for printing, as the program can simply iterate through the keys to find marks above 50 and print out their corresponding frequencies.

Overall, a hashmap is the best data structure for this scenario due to its efficiency in lookup, insertion, and retrieval operations.