Having collected student profiles with scores in various subjects such as physics, chemistry, and math, I am looking to identify a group of dominant students based on their individual subject scores. For instance:
let students = [{name: "A", phy: 70, chem: 80, math: 90},
{name: "B", phy: 75, chem: 85, math: 60},
{name: "C", phy: 78, chem: 81, math: 92},
{name: "D", phy: 75, chem: 85, math: 55}];
A student is considered dominant over another if they meet the following two conditions: 1. student_1 >= student_2 for all parameters 2. student_1 > student_2 for at least one parameter
I initially attempted to use a nested loop, which resulted in a brute-force algorithm. I introduced a new parameter called "passed" to keep track of dominance. Below is the code:
let students = [{ name: "A", phy: 70, chem: 80, math: 90, passed: true },
{ name: "B", phy: 75, chem: 85, math: 60, passed: true },
{ name: "C", phy: 78, chem: 81, math: 92, passed: true },
{ name: "D", phy: 75, chem: 85, math: 55, passed: true }];
let weak_student: any;
// logic and code here...
console.log(students);
After running the code, I identified students A and D as having their "passed" flag set to false. Now, I am looking to achieve the same results using alternative algorithms such as Divide & Conquer, Nearest Neighbor, Branch & Bound, or any other efficient methods. I also aim to compare the time and space complexity of the different algorithms for larger datasets.