def binary search iterative(datatarget) """return true if target is found in the given python list "" low high len(data)- while low <high mid (low high/ if target =data[mid]found match return true elif target data[mid] high mid only consider values left of mid else low mid only consider values right of mid return false loop ended without success code fragment nonrecursive implementation of binary search the targetor we narrow the range of the candidate subsequence where we made the recursive call binary search(datatargetlowmid - in the original versionwe simply replace high mid in our new version and then continue to the next iteration of the loop our original base case condition of low high has simply been replaced by the opposite loop condition while low <high in our new implementationwe return false to designate failed search if the while loop ends (that iswithout having ever returned true from withinwe can similarly develop nonrecursive implementation (code fragment of the original recursive reverse method of code fragment def reverse iterative( ) """reverse elements in sequence "" startstop len( while start stop [start] [stop- [stop- ] [start startstop start stop swap first and last narrow the range code fragment reversing the elements of sequence using iteration in this new versionwe update the values start and stop during each pass of the loopexiting once we reach the case of having one or less elements in that range many other linear recursions can be expressed quite efficiently with iterationeven if they were not formally tail recursions for examplethere are trivial nonrecursive implementations for computing factorialssumming elements of sequenceor computing fibonacci numbers efficiently in factour implementation of fibonacci generatorfrom section produces each subsequent value in ( timeand thus takes (ntime to generate the nth entry in the series