Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Introduction to Algorithms!
You have completed Introduction to Algorithms!
Preview
There's more than one way to implement the binary search algorithm and in this video we take a look at a new concept called recursion.
Resources
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
we'll name this
recursive_binary_search.py.
0:00
Okay, so I'm going to add our
new implementation here, so
0:05
that we don't get rid of that
first implementation we wrote.
0:08
Let's call this new function
recursive_binary_search.
0:11
Unlike our previous implementation,
0:15
this version is going to behave slightly
differently in that it won't return
0:17
the index value of the target
element if it exists.
0:22
Instead, it will just return a true value
if it exist, and a false if it doesn't.
0:25
So recursive_binary_search,
and like before,
0:29
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up