Question: 3 . 2 . 1 : Recursive algorithm: Search String target _ item and a list of alphabetically sorted strings are read from input. Complete
: Recursive algorithm: Search
String targetitem and a list of alphabetically sorted strings are read from input. Complete the findmiddle function:
If targetitem is alphabetically before midvalue the element at index midindex of the list output 'Search lower half' and recursively call findmiddle to find targetitem in the lower half of the range.
Otherwise, output 'Search upper ha
def findmiddlesearchlist, targetitem, startindex, endindex:
rangesize endindex startindex
midindex startindex endindex
midvalue searchlistmidindex
if targetitem midvalue:
printftargetitem is found at index midindex
elif rangesize :
printftargetitem is not in the list'
else:
Your code goes here
targetitem input
datalist inputsplit
findmiddledatalist, targetitem, lendatalist
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
