Guest User

Untitled

a guest
Aug 17th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. package solver;
  2.  
  3. import noun.BinarySearch;
  4.  
  5. public class StrategyDriver {
  6. public static void main(String args[]){
  7.  
  8. BinarySearch bs = new BinarySearch();
  9.  
  10.  
  11. /*
  12. * It dynamically selects behavior, based on the array size
  13. */
  14.  
  15. int arr[] = {5,2,3,2,5};
  16. bs.setArray(arr);
  17. System.out.println("Value found at index " + bs.search(3) + " from the begin of the sorted array.\n");
  18.  
  19.  
  20.  
  21. int arr2[] = {88, 79, 46, 69, 93, 84, 56, 64, 67, 41, 77, 75, 48, 66, 8, 4, 57,
  22. 4, 41, 7, 84, 56, 68, 48, 42, 60, 94, 30, 59, 66, 5, 89, 78, 62,
  23. 99, 66, 31, 34, 0, 59, 10, 11, 54, 5, 59, 18, 2, 42, 31, 24, 57,
  24. 20, 50, 3, 21, 23, 15, 18, 58, 29, 50, 91, 65, 83, 4, 45, 25, 94,
  25. 27, 6, 19, 10, 51, 74, 32, 66, 0, 47, 32, 62, 33, 4, 54, 13, 5,
  26. 54, 56, 16, 95, 53, 9, 78, 7, 70, 55, 88, 93, 54, 99, 58, 90 };
  27. bs.setArray(arr2);
  28. System.out.println("Value found at index " + bs.search(4) +" from the begin of the sorted array.\n");
  29.  
  30.  
  31.  
  32. }
  33. }
Add Comment
Please, Sign In to add comment