Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Computer Science Introduction to Algorithms Algorithms in Code Recap: Algorithms in Code

Kareem Jeiroudi
Kareem Jeiroudi
14,984 Points

There's an error in the recursion implementation code

I believe, I've spotted an error in this code, where in the scope of the last if-else statements the function binary_search_recursive(args) is being called instead of recursive_binary_search(args). I hope you fix this soon.

# see the function's name!
def recursive_binary_search(list, target, start=0, end=None):
    if end is None:
        end = len(list) - 1
    if start > end:
        return -1

    mid = (start + end) // 2

    if target == list[mid]:
        return mid
        if target < list[mid]:
            # see the function called!
            return binary_search_recursive(list, target, start, mid-1)
            return binary_search_recursive(list, target, mid+1, end)

1 Answer