Question: Assume that you are given the average mt grades (a i ) and final grades (b i ) of n students in a course. In

Assume that you are given the average mt grades (ai) and final grades (bi) of n students in a course. In order to pass the course, the students should have a mt average of at least 60 or a final score of at least 70 (or have both conditions satisfied). Your input is pairs of integers between 0 and 100, (ai, bi) for each student i (i=1,2,..,n). Note that a student who has a=65 and b=80 passes the course, a student has a=65 and b=40 passes the course and a student who has a=35 and b=80 also passes the course.

  1. (4 points) Write the pseudo-code of an algorithm that counts the number of students who would fail the course.
  2. (2 points) Find the worst-case complexity (in terms of big ) of your algorithm. Explain all details.
  3. (8 points) Write the pseudo-code of an algorithm that determines whether any students received similar grades in the final grade where a similar grade is defined by a difference of at most 2 points. For instance, 76 and 74 are considered similar but 76 and 73 are not considered similar. Your algorithm should return found if there are at least two students that received similar grades and should return not found otherwise.
  4. (3 points) Find the worst-case complexity (in terms of big ) of your algorithm. Explain all details.
  5. (5 points) Assume now that you first sort the list from the highest final grade to the lowest final grade using insertion sort and then determine whether any students received similar final grades. Write the pseudo-code of an algorithm that implements this. Assume that the insertionsort function is given (you don't have to write the pseudo-code but can use the function).
  6. (3 points) Find the worst-case complexity (in terms of big ) of your algorithm in part e (including the sort). Explain all details.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!