Question

In: Computer Science

For an assignment you wrote the method sortByLargestDepth in the class QuakeSortInPlace to sort earthquakes by...

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?

Solutions

Expert Solution

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


Related Solutions

1- Write a class called MedicalStaff that is a Person (the class that you wrote in...
1- Write a class called MedicalStaff that is a Person (the class that you wrote in last lab). A MedicalStaff has specialty (i.e. Orthopedic, cardiology, etc.). 2- Then write two classes: Doctor class has office visit fee. Nurse class has title (i.e. RN, NP, etc.) Both classes inherit from MedicalStaff. Be sure these are all complete classes, including toString method. 3- Write a tester to test these classes and their methods, by creating an array or ArrayList of Person and...
Bubble and Selection Sort For this assignment, you are to consider bubble and selection sort. Both...
Bubble and Selection Sort For this assignment, you are to consider bubble and selection sort. Both are O(n^2) however it may be possible to classify one algorithm as being more efficient than the other. You are to discuss which algorithm you feel is the most efficient and in what cases it will be more efficient. Provide any relevant test cases and code to support your belief. Submit a pdf containing your findings and test results along with any relevant code...
Can someone fix solver class. it suppose to call method from sort class for insertion and...
Can someone fix solver class. it suppose to call method from sort class for insertion and heap sort. However its not giving the outuput.. Run following class Solver where 20 array instances of 1M random integers are sorted using Insertion- sort and Heap-sort, respectively public class Solver {    public static void main(String[] args) { final int SIZE = 1000000; // 1 million final int Instances=20; int[][] TwoDimArray = new int[Instances][SIZE];    Sort s = new Sort();    for(int i=0;...
24.10 Lab Ch24: MergeSortDouble Create a class MergeSortDouble and implement a sort(double[]) method using merge sort...
24.10 Lab Ch24: MergeSortDouble Create a class MergeSortDouble and implement a sort(double[]) method using merge sort algorithm. Test will call the sort() method. java please!
Add a sort instance method to the IntList class, so that x.sort() returns an IntList that...
Add a sort instance method to the IntList class, so that x.sort() returns an IntList that is a version of the IntList x, sorted in non-decreasing order. You may use any sorting algorithm you like. There should be no side effect on x. //IntList Class public class IntList { private ConsCell start; public IntList(ConsCell s) { start = s; } public IntList cons (int h) { return new IntList(new ConsCell(h,start)); } public int length() { int len = 0; ConsCell...
For this assignment, find out how to do a bubble sort, selection sort, or insertion sort...
For this assignment, find out how to do a bubble sort, selection sort, or insertion sort in Java. You have the option to choose but you must label (with comments) the algorithm you choose to implement. Convert that algorithm to a generic algorithm and constraint it to only using numerics. Your method should accept an array as a parameter and sort the content of the array. If you wish, you can throw an exception if the contents of the array...
Complete the coding/testing of the heap sort method we began in class. Then modify your program...
Complete the coding/testing of the heap sort method we began in class. Then modify your program so that it outputs a comparison of the actual number of swaps it performs to the predicted number of swaps, and a comparison of the actual sort effort to the predicted and minimum sort effort. The output should be formatted exactly as shown below. Actual swaps = xxxx; Predicted swaps = xxxx Actual sort effort = xxxx; Predicted sort effort = xxxx; Min sort...
This is an exercise in correctly implementing insertion sort and selection sort. This assignment includes a...
This is an exercise in correctly implementing insertion sort and selection sort. This assignment includes a text data file containing information on tutorial websites for a variety of programming languages. The data file is named Tutorials. It contains records of programming tutorial websites. The record structure for this text file is: FIELD 1 = Programming Language FIELD 2 = Name and Description of Website FIELD 3 = URL Web Address of Language Tutorial The structure of the file is that...
Sorting with Binary Search Tree This assignment asks you to sort the lines of an input...
Sorting with Binary Search Tree This assignment asks you to sort the lines of an input file (or from standard input) and print the sorted lines to an output file (or standard output). Your program, called bstsort (binary search tree sort), will take the following command line arguments: % bstsort [-c] [-o output_file_name] [input_file_name] If -c is present, the program needs to compare the strings case sensitive; otherwise, it's case insensitive. If the output_file_name is given with the -o option,...
Assignment - Number Guessing with a Class For this assignment you will revisit the number guessing...
Assignment - Number Guessing with a Class For this assignment you will revisit the number guessing game in which the user picks a number, and your program tries to guess the number. For review, a sample run of the program is printed below. In the example the user picks the value 72 for the first game, and then 25 for the second game. The user's input is in bold. Here is how the output might look (exact numbers may vary)...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT