125k views
5 votes
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.Consider an algorithm that computes the total score on all exams for each student, and the average class score on each exam. You need to analyze the running time of this algorithm.A. What are the basic operations you would count toward the running time?B. What is the worst-case running time as a total count (not big O) of these basic operations?C. What is the big O running time?D. Is your algorithm linear, quadratic, or some other order?

User Patbarron
by
3.3k points

1 Answer

2 votes

Answer:

Check the explanation

Step-by-step explanation:

A. The fundamental or basic operations are addition and division.

B. The total figure for each student (which starts at 0) will be included to c times. Given that there are r student totals, there are r*c additions for the totals. (An optional correct answer is r*(c-1) if you begin the accumulator with the initial item in a column, and perform (c-1) additions.)

Each exam average will be included to r times. In view of the fact that there are c exams, this gives another c*r additions.

All the exam average will be divided exactly once by the amount of students, c. So, c divisions.

C. O(rc)

D. LINEAR (Note: The Big O appears like a quadratic value, although the INPUT SIZE is rc, and the running time is linearly relative to the input size.)

User Mark Kortink
by
3.5k points