Help with modified binary search?

Hey guys i need some help with the last part of my assignment. I am currently working on the rest so i cant post up my code, but i know how to do the beginning of it but i dont know how to do the modified binary search.Can anyone help me out here are the instructions just need help on the GPA search.Thanks

Write a program that reads student ID's and their GPA's into two parallel arrays of maximum size 100, sorts the two arrays based on their GPA in descending order and allows the user to search for a range of GPA's and prints the ID's and GPA's of the students whose GPA is found in the given range. To end data entry, the user will enter -1 for the ID. You will use a sort function to sort and a modified binary search function to search for a range of GPA's.

The sort function will take two arrays, one for ID's (string) and one for GPA's (double) and will sort the two arrays based on the GPA's (Remember to sort ID's and GPA's together). The search function will take the array of GPA's (gpas), a range of GPA's such as 2.9 and 3.1 (low, high) and an array of integers (indexes). It will assign the indexes of the array elements that fall in the given range of GPA's to the elements of indexes and return number of GPA's that fell in the given range. Upon the function's return, main will print the ID's and GPA's of those that were found in the given range of GPA's.

The search function must not do the search in a linear fashion, but rather take advantage of the fact that the list is sorted. For example, to search for GPA's that fall within 2.9 and 3.1, it should compare the mid value with those limits. If the mid value is below 2.9, it should adjust the last index and if it's larger than 3.1, it should adjust the first index. Once it finds a value that falls in the range, such as 3.0, it needs to search for any other GPA that might be in that range, either larger or smaller than the one found, such as 2.9 and 3.1. Knowing that the list is sorted, at that point you can just do linear search in both directions to pick up other matching values.
Last edited on
Topic archived. No new replies allowed.