egonSchiele / grokking_algorithms

Code for the book Grokking Algorithms (https://amzn.to/29rVyHf)
Other
11.72k stars 3.8k forks source link

feat: enhance recursive binary search to correctly return found index #298

Open armineyvazi opened 2 weeks ago

armineyvazi commented 2 weeks ago

Enhanced the recursive binary search function to properly return the index of the found item. Adjusted the recursive calls to ensure the found index is propagated back through the call stack, and added a base case to return -1 when the item is not found.