Question
Using Arrays with Sorting and Searching Algorithms 1) This program has six required outputs and involves searching and sorting an array of integers. Write a
Using Arrays with Sorting and Searching Algorithms
1) This program has six required outputs and involves searching and sorting an array of integers. Write a java application that initializes an array with the following numbers, in this order: 23, 17, 5, 90, 12, 44, 38, 84, 77, 3, 66, 55, 1, 19, 37, 88, 8, 97, 25, 50, 75, 61, and 49. Then display the unsorted values. This is required output #1 of 6 for this program.
2) Using a sequential search of the unsorted array, determine and report the relative (i.e. 0,1, 2, 3, 4, etc.) positions of the following numbers in the array (or -1 if not found), and the number of searches required to locate the numbers: 25, 30, 50, 75, and 92. This is required output #2 of 6.
3) Then display the total number of searches for all five numbers. This is required output #3 of 6.
4) Sort the numbers using a recursive quicksort and then display the sorted array. This is required output #4 of 6.
5) Using a binary search of the sorted array, determine and report the 1-relative positions of the following numbers in the array (or -1 if not found), and 2-the number of searches required to locate the numbers: 25, 30, 50, 75, and 92. This is required output #5 of 6.
6) Finally, display the total number of searches for all five numbers. This is required output #6 of 6. (There are six required sets of output as numbered in the above paragraphs.) Create an object-oriented solution for this assignment. Create a class called SArray (Search Array) that accepts the initial array through the constructor. The class should have a recursive quick sort sorting method that will sort the array. The class should have two methods for searching. One that does a sequential search that accepts as input the integer value that is to be searched for and returns the index in array where the search value is if found, and -1 if not found. The other search method should be a binary search of a sorted array that accepts as input the integer value that is to be searched for and returns the index in the array where the search value is if found, and -1 if not found. Create a toString method to display the contents of the array. The driver/main class could not only pass in the initial array values but call various methods to perform the searches, sorting, and array contents display thus enabling you to display the information in the six items above.Make sure you upload your java source code and a screen snapshot of all of your program's outputs
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