if low highno place left to lookreturn - return - mid (low high/ item nums[midif item =xfound itreturn the index return mid elif itemlook in lower half return recbinsearch(xnumslowmid- elselook in upper half return recbinsearch(xnumsmid+ highwe can then implement our original search function using suitable call to the recursive binary searchtelling it to start the search between and len(nums)- def search(xnums)return recbinsearch(xnums len(nums)- of courseour original looping version is probably bit faster than this recursive version because calling functions is generally slower than iterating loop the recursive versionhowevermakes the divide-and-conquer structure of binary search much more obvious below we will see examples where recursive divide-and-conquer approaches provide natural solution to some problems where loops are awkward recursion vs iteration ' sure by now you've noticed that there are some similarities between iteration (loopingand recursion in factrecursive functions are generalization of loops anything that can be done with loop can also be done by simple kind of recursive function in factthere are programming languages that use recursion exclusively on the other handsome things that can be done very simply using recursion are quite difficult to do with loops for number of the problems we've looked at so farwe have had both iterative and recursive solutions in the case of factorial and binary searchthe loop version and the recursive version do basically the same calculationsand they will have roughly the same efficiency the looping versions are probably bit faster because calling functions is generally slower than iterating loopbut in modern language the recursive algorithms are probably fast enough in the case of the exponentiation algorithmthe recursive version and the looping version actually implement very different algorithms if you think about it bityou will see that the looping version is linear and the recursive version executes in log time the difference between these two is similar to the difference between linear search and binary searchso the recursive algorithm is clearly superior in the next sectionyou'll be introduced to recursive sorting algorithm that is also very efficient as you have seenrecursion can be very useful problem-solving technique that can lead to efficient and effective algorithms but you have to be careful it' also possible to write some very inefficient recursive algorithms one classic example is calculating the nth fibonacci number