I need to compute an arithmetic mean(average), median, and mode for up to 50 test scores. The data are contained in a text file.
To determine the median, I must first sort the array. The median is the score in the middle of the range. This can be determined by selecting the score at last/2 if last is odd. The mode is the score that occurs the most often. After building the frequency array, use it to determine which score occurred most often. (Two scores can occur the same number of times) I am working on a Unix operating system.© BrainMass Inc. brainmass.com December 24, 2021, 4:42 pm ad1c9bdddf
You mentioned computing the mean; I assume you're able to do that without much difficulty since you didn't mention it in the second paragraph.
<br>In order to compute the median, you mentioned having to sort. Since you didn't mention a particular method, I will describe a simple and effective sort that should do what you need.
<br>Insertion Sort is one of the simplest sorting methods, and is very intuitive. Unfortunately, it is inefficient for large lists, but for smaller lists (like the ones you will be working with), it should do the job. If you need to sort a list of numbers, one way to do it is to start by finding the smallest number in the list. ...
Ideas for computing the mean are listed.