BinarySearch(A, key, begin, end) if (begin > end) return false mid = (begin+end)/2 if (A[mid] == key) // base case return true or found if (A[mid] > key) BinarySearch(A,key, begin, mid-1) else BinarySearch(A,key, mid+1, end) A = 1, 3, 7, 10, 15, 19 Search for 1 BinarySearch(A,1, 0, 5) mid = (0+5)/2 = 2 A[2] = 7 <> 1 7 > 1 BnarySearch(A, 1, 0, 1) mid = (0+1)/2 = 0 A[0] = 1 == 1 Return found. Search for 3 BinarySearch(A,1, 0, 5) mid = (0+5)/2 = 2 A[2] = 7 <> 3 7 > 3 BnarySearch(A, 1, 0, 1) mid = (0+1)/2 = 0 A[0] = 1 <> 3 Return found. BinarySearch(A,3, 1,1) mid = (1+1)/2 = 1 A[1] == 3 found Search for 3 BinarySearch(A,4, 0, 5) mid = (0+5)/2 = 2 A[2] = 7 <> 4 7 > 4 BnarySearch(A, 4, 0, 1) mid = (0+1)/2 = 0 A[0] = 1 <> 4 Return found. BinarySearch(A,4, 1,1) mid = (1+1)/2 = 1 A[1] <> 4 BinarySearch(A,4, 2,1) Recursive multiply Multiply(int a, int b) , a >= 0 if (a == 0) return 0 else return b + Multiply(a-1,b) /* NO THIS IS NOT RECURSIVE for(i=1;i<a;i++) { answer += b; } */