Question: In class, we looked at three efficient sorting algorithms-the Merge sort, Quick sort, and Heap sort. The implementations demonstrated in class or included in the


In class, we looked at three efficient sorting algorithms-the Merge sort, Quick sort, and Heap sort. The implementations demonstrated in class or included in the lecture slides were used to sort arrays of integers, but, of course, integers are not the only things that need sorting. When working with objects, the same sorting algorithms can often be applied. In this lab, you will implement two of the three algorithms we examined, and use them to sort an array of Objects. EXAMPLE PROGRAM While there is no example program for this lab, referring to the implementations of all three sorting algorithms as provided in the lab should give you some guidance. Remember that the implementations provided in the lecture are for primitive types, while your lab will need to work with objects. YOUR PROGRAM For your lab, you will need to define a class Student, with private members for first name, last name, and GPA, and any methods you determine that you need (constructors, gets/sets, etc.) Once the class is defined, you will need to populate an array of Student objects to be sorted with data provided in the students.txt file. The format of this data file is as follows: The first line contains an integer, which is a count of the number of student records contained in the file. You can use this value to define the size of the array. Note: When I test your code, I may not use the same input file, so you will need to dynamically size the array based on the file input. Every line after the first contains three pieces of information, separated by spaces: First Name, Last Name, and GPA Once the array is populated with the student data, we are ready to start sorting! Choose two of the three sorting algorithms we discussed in class (Mergesort, QuickSort, and HeapSort), and implement them to sort the Student data w GOK Lab 5- Advanced Sorting In class, we looked at three efficient sorting algorithms-the Merge sort, Quick sort, and Heap sort. The implementations demonstrated in class or included in the lecture slides were used to sort arrays of integers, but, of course, integers are not the only things that need sorting. When working with objects, the same sorting algorithms can often be applied. In this lab, you will implement two of the three algorithms we examined, and use them to sort an array of Objects. EXAMPLE PROGRAM While there is no example program for this lab, referring to the implementations of all three sorting algorithms as provided in the lab should give you some guidance. Remember that the implementations provided in the lecture are for primitive types, while your'lab will need to work with objects. YOUR PROGRAM For your lab, you will need to define a class Student, with private members for first name, last name, and GPA, and any methods you determine that you need (constructors, gets/sets, etc.) Once the class is defined, you will need to populate an array of Student objects to be sorted with data provided in the students.txt file. The format of this data file is as follows: The first line contains an integer, which is a count of the number of student records contained in the file. You can use this value to define the size of the array Note: When I test your code, I may not use the same input file, so you will need to dynamically size the array based on the file input. Every line after the first contains three pieces of information, separated by spaces: o First Name, Last Name, and GPA Once the array is populated with the student data, we are ready to start sorting! Choose two of the three sorting algorithms we discussed in class (MergeSort QuickSort, and HeapSort), and implement them to sort the Student data by GPA. meghocad drivar that arouidas 5. options
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
