CS112: In-class Exercise 22Binary Search0. Review of binary search.•The array must be sorted, say in ascending order.•Start with integer index variables botset to 0 and topset to array length minus 1.•Do a loop while bot <= top, oCalculate mid = (bot + top)/2;oTest whether the searched item equals the item at index mid. If yes, then item found, return index mid.oIf not, then test whether the searched item is less than the item at index mid. If yes, then reset topto mid-1. If no, then reset botto mid+1.•If not found, return -1.1.Copy the InClass22 folder from the usual locations.2.Open the project using BlueJ.3.Note that the Interactionsclass is all programmed and you don’t have to do anything to it.4.Edit the source file for Algorithms.5.Exercise A. Write the method for public static int linearSearch(String strings, String s)Note that the new keyword staticmeans that this method can be called using the class name (namely, an Algorithms object is not needed).
This is the end of the preview.
access the rest of the document.