In: Computer Science
For an assignment you wrote the method sortByLargestDepth in the class QuakeSortInPlace to sort earthquakes by their depth from largest depth to smallest depth using the selection sort algorithm. Modify this method to do exactly 50 passes and then modify testSort to run this method on the file earthQuakeDataDec6sample2.atom. The file may not be completely sorted as there are more than 50 quakes in the file. After running your program of 50 Selection sort passes on this file, what is the depth of the last earthquake in the ArrayList?
The logical solution determines the first scenario where the selection sort follows up in descending order as the depth gets decreases from higher to lower. Which is sortByLargestDepth method, the functionality goes through the passing of data in the array where each value are mapped to each other with a condition to check the value it passes through. So, we the user have to keep in mind that duplicate value can pass through so a checker has to be there for checking the value it passes through the array.
To check exactly the 50 passes, an array of size have to be taken such that a while condition will carry <=50 with a break statement. so that the value stop right at 50 passes from the file earthQuakeDataDec6sample2.atom. That way first step get passed and the second process to determine the last earthquake in the file, a parameter has to be passed to check the date/time of the earthquake where the current value match with system time/date will determine the last earthquake.
Please note that the value of earthQuakeDataDec6sample2.atom is not provided therefore the solution is provided on assumption.
--------------------------------------------------------------------------------------------------------------------------------------------------------
Please comment on the answer if you have any doubts!! Thank you