Computers and Technology, 24.05.2021 18:30 candy7693
Consider the search method (of some class) below which is intended to return the index of the position in array a where key is found. If key is not in the array a, -1 is returned.
public int search (int key){
int low=0;
int hight=a. length-1;
while (low<=high){
int mid=(low+high)/2;
int diff=a[mid]-key;
if (diff==0) // a[mid]==key
return mid;
else if (diff<0) //a[mid]
low=mid+1;
else
high=mid-1;
}
return -1;
}
private int [ ] a;
Suppose:
a={8, 10, 1, 5, 7, 9, 6, 2}
What value will search return? Why?
8
4
3
-1
No value will be returned. An is thrown.
Answers: 3
Computers and Technology, 24.06.2019 07:00
Why would a business likely use a java applet - to back up their data files for the business - to create a program that a customer can launch in their web browser - to create music on a powerpoint presentation - to organize files on their company directory
Answers: 3
Computers and Technology, 24.06.2019 19:00
In python a floating-point number must be written using scientific notation?
Answers: 1
Computers and Technology, 25.06.2019 02:30
What are the charges for invasion of privacy on computers
Answers: 1
Consider the search method (of some class) below which is intended to return the index of the positi...
Mathematics, 22.05.2021 06:40
Physics, 22.05.2021 06:40
Mathematics, 22.05.2021 06:40
Spanish, 22.05.2021 06:40
Mathematics, 22.05.2021 06:40
Mathematics, 22.05.2021 06:40
History, 22.05.2021 06:40
History, 22.05.2021 06:40