Your questions appear to be about algorithms.
You can find some ideas in:
Introduction to the Analysis of Algorithms by Robert Sedgewick and Philippe Flajolet (princeton.edu)
Algorithms - GeeksforGeeks
Data Structure and Algorithms Tutorial (tutorialspoint.com)
among others.
For the fun of it and to see how others are doing:
Julia on Exercism
Codewars - Achieve mastery through coding practice and developer mentorship
The big O notation is to be taken with a grain of salt, as it is an asymptotic value and neglects possibly large factors. See https://discourse.julialang.org/t/fastest-data-structure-for-a-priority-queue/68472
A small modification of the code there gives:
function findbinsearch(item, collection)
len = length(collection)
left = 1
right = len
found = false
while left <= right
mid = (left + right) >> 1
if collection[mid] == item
found = true
break
end
if collection[mid] > item
right = mid - 1
else
left = mid + 1
end
end
found
end
collection = ["tata", "titi", "toto"]
findbinsearch("tati", collection) # -> false
findbinsearch("toto", collection) # -> true
findbinsearch("titi", collection) # -> true
findbinsearch("tata", collection) # -> true