How to improve this function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to improve this function

I have this function that searches for a number in a list and returns True upon finding the number and False if the list does not contain the number. How can I make it more efficient? The function should return the number of iterations it took to find the number and I need to report the number of iterations it takes the improved function to find the numbers: 5, 35, and 70. (without built-in Python functions for the search process!) https://code.sololearn.com/cRgBmg2TebZD/#py

6th Oct 2020, 9:35 AM
Bia_U
Bia_U - avatar
1 Answer
+ 5
Binary search. Bia_U go to the Python course, click on 'More on the Topic'. In there you can look for the same. https://www.sololearn.com/learn/705/?ref=app
6th Oct 2020, 10:18 AM
Avinesh
Avinesh - avatar