Write a Java application that implements the recursive Binary Search alogrithm below:

Hi, Please find my implemetation.
I have also prited trace of execution.
public class BinarySearch {
public static <AnyType extends Comparable<? super AnyType>>
int binarySearch(AnyType[] a, AnyType target) {
return binarySearch(a, target, 0, a.length - 1);
}
public static <AnyType extends Comparable<? super AnyType>>
int binarySearch(AnyType[] a, AnyType target, int min, int max) {
if (min > max) {
System.out.println("Min: "+min+", Max: "+max);
return -1; // target not found
} else {
int mid = (min + max) / 2;
System.out.println("Min: "+min+", Mid: "+mid+", Max: "+max);
if (a[mid].compareTo(target) < 0) { // too small; go right
return binarySearch(a, target, mid + 1, max);
} else if (a[mid].compareTo(target) > 0) { // too large; go left
return binarySearch(a, target, min, mid - 1);
} else {
return mid; // target found; a[mid] == target
}
}
}
public static void main(String[] args) {
Integer[] list = {-2, 8, 13, 22, 25, 25, 38, 42, 51, 103};
System.out.println("Returned Value: "+binarySearch(list, 103, 0, 9));
System.out.println();
System.out.println("Returned Value: "+binarySearch(list, 30, 2, 8));
}
}
/*
Sample run:
Min: 0, Mid: 4, Max: 9
Min: 5, Mid: 7, Max: 9
Min: 8, Mid: 8, Max: 9
Min: 9, Mid: 9, Max: 9
Returned Value: 9
Min: 2, Mid: 5, Max: 8
Min: 6, Mid: 7, Max: 8
Min: 6, Mid: 6, Max: 6
Min: 6, Max: 5
Returned Value: -1
*/
Write a Java application that implements the recursive Binary Search alogrithm below: Write a Java application...
#2Trace These JAVA searches by hand on the following dataset. Sorted Data Set: 3, 5, 8, 9, 12, 14, 18, 19, 21, 23, 24, 26 #Trace the sorted data set using a binary search. Search target: 23 #Trace the sorted data set using a binary search. Search target: 15 (To trace a binary search, list the value of first, last, and mid for each pass through the method.) Use this method: private static <T extends Comparable<? super T>> boolean...
I'm trying to make a recursive binary search that checks whether or not the words in a file are correct by comparing it to a dictionary file, but for some reason the method I'm using below is not working and is outputting all the words in the file I am checking as incorrect. (the dictionary is organized in alphabetical order however the file "oliver.txt" is not) my question is what do I have to do to make this work? public...
Java The following questions ask about tracing a binary search. To trace the binary search, list the value of first, last, and mid for each pass through the loop or method. Use one of these methods for your trace. public static int binarySearchIterative(int[] numbers, int target) { boolean found = false; int first = 0; int last = numbers.length - 1; while (first <= last && !found) { int mid = (first + last) / 2; if (numbers[mid] == target)...
(Recursive Binary Search) Write a recursive method recursiveBinarySearch to perform a binary search of an array. The method should receive the search key, starting index and ending index as arguments. If the search key is found, return its index in the array. If the search key is not found, return –1. (NOTE: Complete the recursiveBinarySearch method in the BinaryArray class). java
6 (10 points Remember the recursive Searching algorithm Binary Search. Write a recursive method to search for a target character in the array and return the index location if found or -1 if it is not found. 7 a5 points 17 points cach) Write the code to create a GUI based class Temperature Converter which inherits from JFrame and implements the ActionListerner interface. public static int binary Search(char target, char( theValues, int firstIndex, int lastindex) Example: Clicked "F to C"...
6.3.1 [10] <§6.2> Consider the following binary search algorithm (a classic divide and conquer algorithm) that searches for a value X in a sorted N-element array A and returns the index of matched entry: BinarySearch(A[0..N−1], X) { low = 0 high = N −1 while (low <= high) { mid = (low + high) / 2 if (A[mid] >X) high = mid −1 else if (A[mid] <X) low = mid + 1 else return mid // found } return −1...
JAVA Write a program which will read a text file into an ArrayList of Strings. Note that the given data file (i.e., “sortedStrings.txt”) contains the words already sorted for your convenience. • Read a search key word (i.e., string) from the keyboard and use sequential and binary searches to check to see if the string is present as the instance of ArraryList. • Refer to “SearchInt.java” (given in “SearchString.zip”) and the following UML diagram for the details of required program...
Problem: I am trying to implement a binary search function in Visual Studio 2019 using C#. This is my first program in C# and I translated it from Java. In this program, I am to carry out the same 10,000,000 unsuccessful searches for eight different-sized arrays, namely arrays of sizes, 128, 512, 2048, 8192, 32768, 131072, 524288, and 2,097,152. I need to measure each of the three programs and the time it takes to do the 10,000,000 searches for each...
Java Programming Write a program to find the number of comparison using binarySearch and the sequentialSearch algorithms as follows: Suppose list is an array of 2500 elements. 1. Use a random number generator to fill list; 2. Use a sorting algorithm to sort list; 3. Search list for some items as follows: a) Use the binary search algorithm to search list (please work on SearchSortAlgorithms.java and modify the algorithm to count the number of comparisons) b) Use the sequential search...
Qi. Create a java project Question that includes: • A bubble sort method to sort your arrays. Implement the below recursive binary search. • A java main class where you: o Create an array of characters that contains the letters of your first name followed by your last name, without spaces. o Call the sorting method to sort the array o Call binary search method to find the position of the first letter 'a' in your array. // Recursive Binary...