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