CS2810 OOAIA: A7 solved

$35.00

Category:

Description

Create a class in C++ to represent Students. This class should also support the
functionality to compare two Students based on the given constraints.
The class should have the following attributes.
● ID (Unique for a student)
● Scores in five subjects(No two students will have the same set of scores in all
five subjects).
● Skill value (Unique for a student).
● Any other attributes of your choice.
The condition for comparing arbitrary students A and B is:
● Rank(A) < Rank(B) if M1 (A)>M1
(B)
● Rank(A) < Rank(B) if Mi(A)==Mi(B) and Mi+1 (A)>Mi+1
(B) for i=1 to 4 where
Mi(A) denotes marks of student A in subject i.
Rank is defined as the position of a student in the sorted order using the above
condition. It is indexed from 1.
There can be 5 types of operations:
1. ADD: Add a student.
2. FIND: Find the difference in ranks between two students given their
respective IDs.
3. COUNT: Given a student ID, find the number of students with absolute
difference in skill values more than d. i.e. count(|val_i – val_id| > d) ∀ i.
4. PRINT: Print the current list of student IDs in the order of their ranks.
As and when a new student is added it is expected that all of them are to be in
sorted order i.e. positioning them in their appropriate rank.
You need to choose an appropriate data structure to perform operations efficiently.
Input Format
The operations format are as follows:
1.
2.
3.
4.
Output Format
Output of every query should be printed on a separate line.
1. ADD: nothing to be printed. (no newline as well).
2. FIND: output is an integer.
3. COUNT: output is an integer.
4. PRINT: output is a space separated list of student IDs. Note that there is a trailing space
in the end.
Constraints
Number of ADD operations ≤ 10
5
Number of PRINT operations ≤ 10
2
Number of FIND+COUNT operations ≤ 10
5
Sample Testcase
ADD 1 28 15 72 79 53 880704511
ADD 2 9 27 78 89 81 133736473
ADD 3 94 2 98 99 43 102803388
PRINT
ADD 4 92 61 56 39 96 154547114
ADD 5 19 73 39 13 88 138195161
ADD 6 33 68 17 69 73 749942762
PRINT
FIND 2 3
COUNT 5 7006739
ADD 7 58 64 7 12 3 587319490
ADD 9 96 89 58 43 49 550217891
PRINT
Output
3 1 2
3 4 6 1 5 2
5
4
9 3 4 7 6 1 5 2
Design Submission Format
For the design submission on Moodle, please submit a .tar.gz file named as your roll number.