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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started