So there is an if-else branch in my program with about 30 if-else statements. This part runs more than 100 times per second, so I saw it as an opportunity to optimize, and made it do binary search with a function pointer array (practically a balanced tree map) instead of...

Trying to wrap my head around some basic and common algorithms.. my current understanding of the question is in bold. ( 1 ) Assuming we have a sorted array with n items: at most how many times will a binary search compare elements? I keep seeing ' 0(log(n)) ' pop...

Question: Consider linear search. How many elements of the input sequence need to be checked on the average, assuming that the element being searched for is equally likely to be any element in the array? How do I solve this? Do I need to take the case where the...

Performing a basic linear search with a loop over an array, and not returning the expected value. Given: students = ["Alex", "Kyle", "Libby", "Monkey Boy"] I'm trying to do a basic linear search to see if the name "Monkey Boy" exists, and return it's index. def linear_search(array, name) i =...