Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This question concerns the following situation: in a well-known University depar

ID: 3907767 • Letter: T

Question

This question concerns the following situation: in a well-known University department, the students are studying subjects in different majors. After enrolment, a list is formed of all the Study objects (each having instance variables studentId, subjCode, major and the corresponding getter methods). Assume that the enrollment is correct (e.g. no student in the same subject more than once, each subject with the same major each time, etc). After the list containing the Study objects is formed, it will be processed and output is printed, which gives on each line a major and the number of students qualified for that major. A student is defined to be qualified for a major provided the student is enrolled in at least two subjects of that major. The printout only gives majors where at least one student qualified, and the printout must be sorted in ascending order of number of students. Show how to design software that accepts a list of Study objects, and prints the desired report. Your answer should describe the data structures that you would use in your software, and indicate by pseudocode the calculation you would perform; also write down and justify the big-Oh worst case cost of your solution.

Don't write the code for this problem, only outline the data structure and Big O.

Explanation / Answer

We are having a list of study objects (studentid, subjectcode, major)

The output we are looking at is list of majors along with the number of students
in that major. It will be displayed in ascending order based on the number
of students. The major will be displayed if it has atleast one student qualified.
For the qualification the student should have two courses from that major

We have study class with the fields mentioned in the question
We have a studylist class which contains the list of study objects (getItem(int index))
We have a major class with name of the major and the number of students (getters
and setters, increment the count)
We have a majorlist of majors which contains the list of majors.It will containg
method add(mjor entry), length of the the list, display() and sort

pseudocode will be as follows:

   Create list of studey objects
   Create a studylist object with the above list
   get an item of the studylist
   Create a majorlist object
   get the list of studyobject from the studylist object
   Call the add(item,list of studyobjects) of the majorlist object
   Search if the same studentid appeared with a different subjectcode and same
   major.
   if it is found:
        Search if that major is there in the major list
        if found then increment the count of that major
        if not found , then make an entry in the majorlist with initial count as 1

   Once all the entries are processesd,
   sort the majorlist
   display the list by calling display function
   of majorlist

   The complecity of processing is of O(n^2) and the sorting complexity
   depends on the methods so we can go for the mergesort with O(log(n))

  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote