Your screen shot says step 5 is to find the middle value in the sorted array. The middle value is the median. The steps for finding the mode are quite different. Which are you being asked to find?
Are you allowed to use the sort function in the standard library or are you expected to write your own?
Which sort algorithms have been discussed in your class?
Your screen shot says step 5 is to find the middle value in the sorted array. The middle value is the median. The steps for finding the mode are quite different. Which are you being asked to find?
Are you allowed to use the sort function in the standard library or are you expected to write your own?
Which sort algorithms have been discussed in your class?
Suppose the test consists of 200 questions; all questions have the same weight; and there is no partial credit. There are then 201 possible scores — corresponding to how many questions were answered correctly.
A brute force approach to finding the mode is to define a 201-element score-tally array; initialize each entry to 0; scan through the list of per-student scores, incrementing the corresponding entry in the tally array; and finally, find the largest entries in the tally array. (I say entries because several scores may be tied for largest tally.) The mode value is the array index of the maximum tally value(s), not the maximum value itself.
This is known as a sparse array technique - sparse because many entries in the tally array remain 0. There are other techniques that use less storage but require more complicated code.