This is the question:
A spreadsheet keeps track of student scores on all the exams in a course. Each row of the spreadsheet corresponds to one student, and each column in a row corresponds to his/her score on one of the exams. There are r students and c exams, so the spreadsheet has r rows and c columns. Devise an algorithm to compute the exam averages for each student and the class average for each exam.
(It's from an ungraded practice problem set, not homework).
It seems fairly straightforward to me to do this in linear time($O(c*r)$), but I suspect there is a faster way to do it. Is there a reasonable way to do this with better O()?
My thoughts: At first I thought I could do this by storing the average values and updating them, but I don't think this would really satisfy the requirements of the problem: given just the exam scores, getting the averages would take at least as much time, if not more.
Any help is appreciated! In particular, helpful hints are welcomed, and a helpful hint leading me to the answer will be accepted as an answer.