Base Case str.length() == 0 str.length() == 1 return true str.charAt(0) != str.charAt(str.length() - 1) return false Rec Case str.length() > 1 Rec Step str.charAt(0) == str.charAt(str.length() - 1) (true for now) palindrome(str.substring(1, str.length() - 1)) "kayak" "aya" "y" public static boolean palindrome(String str) { boolean success = true; if (str.length() > 1) { if (str.charAt(0) == str.charAt(str.length() - 1)) { success = palindrome(str.substring(1, str.length() - 1)); } else { // if (str.charAt(0) != str.charAt(str.length() - 1)) { success = false; } } return success; } f ? l f ? l Index: 0 1 2 3 4 5 6 7 8 9 10 11 List: 1 3 4 5 6 9 12 15 20 22 24 f ? l f ? l f ? l Index: 0 1 2 3 4 5 6 7 8 9 10 11 List: 1 3 4 5 6 9 12 15 20 22 24 f l f ? l f ? l f ? l f ? l Index: 0 1 2 3 4 5 6 7 8 9 10 11 List: 1 3 4 5 6 9 12 15 20 22 24 Base Case i have found the value i was looking for return the index where the value exists f == mid || l == mid i have searched the entire list and i have not found the element i was looking return false Rec Case f < mid || l < mid Rec Step binarySearch(int array[], int first, int last, int value) binarySearch(array, first, last, value) value < array[mid] // rec case A binarySearch(array, first, mid, value); value > array[mid] // rec case B binarySearch(array, mid + 1, last, value);