Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*JAVA* Adapt the following methods to operate on Strings rather than int arrays: class BinarySearch { // binarySearch() // pre: Array A[p..r] is sorted static

*JAVA* Adapt the following methods to operate on Strings rather than int arrays: class BinarySearch { // binarySearch() // pre: Array A[p..r] is sorted static int binarySearch(int[] A, int p, int r, int target){ int q; if(p > r) { return -1; }else{ q = (p+r)/2; if(target == A[q]){ return q; }else if(target < A[q]){ return binarySearch(A, p, q-1, target); }else{ // target > A[q] return binarySearch(A, q+1, r, target); } } } 

public static void mergeSort(int[] A, int p, int r){ int q; if(p < r) { q = (p+r)/2; // System.out.println(p+" "+q+" "+r); mergeSort(A, p, q); mergeSort(A, q+1, r); merge(A, p, q, r); } }

 public static void merge(int[] A, int p, int q, int r){ int n1 = q-p+1; int n2 = r-q; int[] L = new int[n1]; int[] R = new int[n2]; int i, j, k; for(i=0; i                        

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

3 4 5 6 g 19

Answered: 1 week ago

Question

=+If the United States experiences a productivity slowdown,

Answered: 1 week ago