Blog Archives
Talking on Sentinal Sequential Search
This is very common to see developers writing “For” loops to search an item in an array which has entries in a “random order”. The complexity for such loops will be,
BEST CASE = O(1)
WORST CASE = O(n)
AVERAGE CASE = O(n/2)
Need to stress “Random order”?
Yes, there is high weight on this term “Random Order”, because it’s wise to choose binary search on a sorted array 😉