import java.util.Arrays;
public class binary_search {
public static void main(String[] args) {
int ar1[] = new int[128];
int p, key=78;
p=Arrays.binarySearch(ar1, key);
System.out.println("element found at index "+p);
Arrays.sort(ar1);
p=Arrays.binarySearch(ar1, key);
long start = System.currentTimeMillis();
Long elapsed = System.currentTimeMillis() - start
System.out.println("Time to do stuff (in milliseconds): " + elapsed );
}
}
I need to binary search to do unsucesfull searches. That's what it does. I also want it to measure the time of the search. Is this a correct implementation? How do I tell the search to do an x amount of searches?