Can you either provide the link to your Repl or make a new post with the formatted code? There are a lot of if statements there and I want to make sure I’m using the right indentations when troubleshooting this code.
for binary search, the list needs to be sorted. Also, use bisect as it’s faster and also builtin and easier. If this answer helped you please mark as solved
I am assuming this is a school assignment, so BISECT is not an option and giving you the code either.
Your code is just too complex and trying too many checks. the basic idea of binary search is take the middle of a list. If this is the searched element return 1, otherwise search in the half of the list where the number could be recursively. You just need to extract min and max (tail and head) values and check if the list is composed by two elements.
yeah thats the logic I used,but still some elements its turning out false and i dont think its because of recursion limit becaus recursion error aint throwing up.