Advertisement
Aldin-SXR

main() bianry

Mar 13th, 2020
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.41 KB | None | 0 0
  1. public static void main(String[] args) {
  2.        
  3.     /* Sorted array */
  4.     int[] elements = { 3, 4, 5, 11, 14, 19, 21, 26, 33, 49, 56, 71, 72, 74, 89, 90, 98, 100 };
  5.        
  6.     /* Return the index of an element */
  7.     int index = BinarySearch.search(elements, 19);
  8.     System.out.println("index: " + index);
  9.    
  10.     /* Element not found */
  11.     int index2 = BinarySearch.search(elements, 42);
  12.     System.out.println("index: " + index2);
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement