
(Intro to Java)
Explain the answers to the below questions. include a written answer to the question using step-by-step explanation
5. Fill in the missing lines of the binarySearch method below:
public static int binarySearch(double array[], double value) {
int low = 0;
int high = array.length - 1;
while (low <= high) {
int mid = (low + high)/2;
if (array[mid] == value) {
return _______________;
} else if (________________) { //search the left half
high = mid - 1;
} else {//search the right half
low = ________________;
}
} //end of while loop
return -1;
}
Now, re-write the above method for an array of Strings.

Step by stepSolved in 2 steps

- (Java) Q3 explain the answers to the below questions using step-by-step explanation. Fill in the missing line of code for the insert method for an array: public static void insert(String array[], int numElements, int indexToInsert, String newValue) {if (array.length == numElements) {System.out.println("Array is full. No room to insert.");return;}for (int i = numElements; i > indexToInsert; i--) {//fill in the missing line of code here}array[indexToInsert] = newValue;}arrow_forward(Java) question 3arrow_forward(Java) choose the correct multiple choicearrow_forward
- (Intro to Java)arrow_forward(JAVA) Data Structures - Implementing a Queue using a Circular Array I've added the QueueOverflowException class, but I'm having trouble with the ArrayQueue Class. If you can do so, can you please add comments to every class and method in just the ArrayQueue class. ****THIS IS THE CLASS THAT NEEDS ADDITIONAL CODE.***** public class ArrayQueue implements QueueInterface{ public static final int MAX = 10; private T elements[]; private int front; private int rear; public ArrayQueue() { //awkward syntax! elements = (T[]) new Object[MAX]; front = MAX - 1; rear = MAX - 1; } //implement your methods here please} ***THE FOLLOWING CLASSES ARE GIVEN AND NEEDED TO COMPLETE THE PROGRAM**** public class Tester{ public static void main() { QueueInterface q = new ArrayQueue(); for (Character ch = 'A'; ch < 'F'; ++ch) q.insert(ch); while (!q.isEmpty()) System.out.println(q.remove());…arrow_forward(Java) Q3 Explain the answer step-by-step . Include verbal explanation. Thank you! The below class pertains to questions 3: public class Address { private int number; private String street;}3. Add the following methods to the Address class: a. a toString method b. two mutator methods - setNumber and setStreet c. two accessor methods - getNumber and getStreetarrow_forward
- (Java) Q1 explain the answers to the below questions using step-by-step explanation.arrow_forward(Java) Q 5,6 Explain the answer step-by-step . I want to understand how to do it so please include verbal explanation. Thank you! Part 1 Write the class described below: The name of the class is Student The class has two public member variables: A String called name and a double called gpa The class has a public member method called printStudent. This method prints out the message: "Hi! My name is " + name + ".\nAnd my gpa is " + gpa It returns nothing Part 2 Now, declare a new Student object named jackie, and assign it the values "Jackie Chan" for the name and 3.5 for the gpa. Finally insert the object jackie into the below ArrayList: ArrayList<Student> al = new ArrayList<Student>();arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





