Question: I need help making this Java class. If anything I at least need help with the sorting methods (selectionSort and insertionSort). I am stuck and

I need help making this Java class. If anything I at least need help with the sorting methods (selectionSort and insertionSort). I am stuck and confused and need a lot of help. Thanks

The PersonSort class is the tester class for this program. It has four static methods: main, populate, selectionSort and insertionSort.

The main method

creates an ArrayList (ArrayList) of Person objects

populates it from a file that is supplied to you

copies the ArrayList to another one

uses the first ArrayList and sorts it using an insertion sort algorithm

displays the sorted ArrayList

uses the second ArrayList and sorts it using a selection sort algorithm

displays the sorted ArrayList

The populate method reads in the Person data from a file (see below for the format). See slide 99 for a good example of how to do this. DO NOT assume that you know how many records are in the file. It creates a Person object from each line in the file and adds the object to the first ArrayList.

The selectionSort method sorts the ArrayList using the selection sort algorithm.

The insertionSort method sorts the ArrayList using the insertion sort algorithm.

You must implement these sorting algorithms. A version of this code is containined in the Lesson 3 Source Code. You are not permitted to use the sort method of the Collections framework, or its swap method.The Person objects must be sorted, first by birthday and then by name.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!