Applying the searching/sorting/manipulation algorithms from 11.4.8, now specifically to arrays of objects and extended/inherited objects.
This subtopic doesn't introduce new algorithms โ it's about correctly applying search, sort, insert, delete and related array manipulation techniques (11.4.8) to more complex data:
Example
// Selection sort adapted to sort an array of Learner objects by average for (int i = 0; i < learners.length - 1; i++) { int minIndex = i; for (int j = i + 1; j < learners.length; j++) { if (learners[j].getAverage() < learners[minIndex].getAverage()) { minIndex = j; } } Learner temp = learners[minIndex]; learners[minIndex] = learners[i]; learners[i] = temp; }
๐ก Exam Tip
When adapting an algorithm you already know to work on objects, the core algorithm structure barely changes โ the only real change is comparing a specific FIELD of each object (e.g. .getAverage()) instead of comparing simple values directly.