Binary search finds a target in a sorted list by repeatedly halving the search space. plaintext Input: lst=[1,3,5,7,9,11], target=7 Output: 3 (index of 7) Input: lst=[1,3,5,7,9,11], target=4 Output: -1 (not found) Recursion fits naturally: check the middle element.
If it's the target, done. If target is smaller, search left half. If larger, search right half.