A L G O R I T H M _ T I M E
This second algorithm is a bit of a doosy, but its definitely a basis for other algorithms we will encounter.
Is it ordered?
Lets say it is this time. So how can we search this array?
First, lets come up with our own algorithm together
First Try? First Whiteboard
Another Big O trick
If the input halves at each step, its likely O(LogN) or O(NlogN)
This is Binary Search
One of the greatest algos ever!
Lets implement it
To the typescripts!
- dont forget to divide by 2