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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started