Solved

The Partial Binary Search Method Below Is Designed to Search

Question 67

Multiple Choice

The partial binary search method below is designed to search an array of String objects sorted in ascending order. Select the expression that would be needed to complete the method. public static int search(String[] a, int low, int high, String item)
{
If (low <= high)
{
Int mid = (low + high) / 2;
Int result = ____________________________;
If (result == 0)
{
Return mid;
}
Else if (result < 0)
{
Return search(a, mid + 1, high, item) ;
}
Else
{
Return search(a, low, mid - 1, item) ;
}
}
Return -1;
}


A) a[low].compareTo(item)
B) item.equals(a[mid])
C) item.compareTo(a[mid])
D) a[mid].compareTo(item)

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents