Question: write a python program which accepts as input, an alphabetically sorted of length n and a search character. s and performs both linear search binary
write a python program which accepts as input, an alphabetically sorted of length n and a search character. s and performs both linear search binary search. the program outputs the index atvwhich the search is sucessful, then the index returned should be -1. the program should also display how many companirs are made by each of the following mechanisms before giving the answer. use seperate user defined functions for both the linear search and binary search. case=1 input=acefhjilmoqr //input string q //search character output=9 //index of found location 10 //number of comparisons by linear search 3 //number of comparisons by binary search
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
