I wonder what's the efficiency of this algorithm in O notation on average.
[deleted]
I have no idea where this misconception comes from.
Big-O notation is a type of bound on a function's growth rate. That function can represent anything. Best case performance, worst case performance, average case performance, memory usage, how many times you are likely to phone someone while you wait, etc.
The standard example showing this is that hash lookups are O(1) or O(n) depending on whether you are asking about the average case or the worst case.