Question: Java Sorting and Searching Assignment ArrayManipulation Class This class will consist of an unsorted array and a sorted array with a maximum size of 50.
Java Sorting and Searching Assignment
ArrayManipulation Class
This class will consist of an unsorted array and a sorted array with a maximum size of 50.
Create a list of 50 or more words in a text file.
Write a method that reads the text file into the unsortedarray. void readFile(String filename)
Write a method that creates an additional array that sorts the original array using Selection Sort. The method returns the count of the number of swaps that occur.- int selectionSort()
Write a method that creates an additional array that sorts the original array using Insertion Sort.
The method returns the count of the number of swaps that occur. int insertionSort()
Write a method that creates an additional array that sorts the original array using MergeSort
The method returns the count of the number of swaps that occur. int bubbleSort()
NOTE: Each of the above three methods create a sorted array. It is not necessary to store the
contents of all three arrays, since the result will be the same. Each method should overwrite
the sorted array, so that there is only one sorted array at any given time.
Write a method that accepts the counts from all three sort methods and outputs the result, indicating which sort was more efficient.- void sortResult(int num1, int num2, int num3)
Write a method that will conduct a sequential search given a word. The method should return the total number of items checked in order to locate the word. The method will need to receive as a parameter the array being searched. This method may receive either the sorted or unsorted array. int sequentialSearch(String word)
Write a method that will conduct a binary search given the same word. The method should return the total number of items checked in order to locate the word. The method will need to receive as a parameter the array being searched. This method can only received a sorted array. int binarySearch(String word)
Write a method that receives the two numbers from the two search methods and outputs the result, indicating which search was more efficient. void searchResult(int num1, int num2)
ArrayDriver Class
Create an instance of ArrayManipulation Class.
Call the readFile() method and send it the name of your file.
Call all three of the sort methods and then call the sortResult() method to determine the results of your sorts.
Call both of the search methods and send it a value that is at the beginning of your list and then call the searchResult() method.
Call both of the search methods and send it a value that is in the middle of your list and then call the searchResult() method.
Call both of the search methods and send it a value that is near the end of your list and then call the searchResult() method.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
