Reputation: 1146
I am developing an application in java which suggests possible groups of students (two or three students per group) on the basis of the marks they obtain in various subjects. I would like to study similar algorithms before i devise my own. For instance of there are a total of two courses and also two students per group than the algorithm should pair students up in groups in such a way that student a should be good in subject 1 whereas student b should be good in subject b.
Detailed Explanantion: The input will be in this form:
student1<90.38<labs
Student1<93.01<exam
Student2<90.38<labs
Student2<85.20<exams
. . .
. . .
. . .
. . .
Studentn<61.48<exams
The first part is the unique id of each student, the second part is marks obtained and the third part is the particular course component the marks have been obtained.
The algorithm should create groups of two of students which complement each other on the basis of marks obtained in each component, labs as well as exams.
Output should be somewhat like
student1|student13|
student17|student15|
student8|student10|
. .
. .
. .
studentn|studentm|
where each line corresponds to a single group of two students.
Upvotes: 2
Views: 690
Reputation: 3761
I try to suggest you a Pareto optimal algorithm:
SocialValue = -(*D1*+*D2*+*D3*+*D4*)
. Note the sign minus: it's because you have to maximize SocialValue
, which is the minimization of the sum of values.Upvotes: 0
Reputation: 5772
This is quite easy. I will tell you only algorithm.
- Make two TreeMap. One with value of all the marks in exam and one with all the marks in lab. Use Student ID as the key.
Now start with first index of each TreeMap and pick the values.
2.1. If both values have same key then pick the next one else pick both different key and remove the pair from the maps.
An example may help. Suppose the scenario is like below
Student ID lab exam
1 80 10
2 50 50
3 40 70
4 20 40
So after creating TreeMap it will look like
labMap examMap
<K,V> <K,V>
<1,80> <3,70>
<2,50> <2,70>
<3,40> <4,70>
<4,20> <1,70>
So you can see we will first take 1 and 3.
Then as 2 and 2 is same we will choose 2 and 4.
After 3 and 2.
Atlast 4 and 1.
Upvotes: 2