Reputation: 13
Can anyone explain to me which one is better: O(n^1/2) or O(logn). The complexity table in text book says O(logn) is better than O(n) and O(n^2). I think I can conclude that O(logn) is better than O(n^k) where k>=1, but how about when k is between 0 and 1. Is O(logN) still better? Thank you
Upvotes: 1
Views: 8225
Reputation: 1439
While n goes to infinity logn is strictly smaller than n^k where 0 < k < 1. (It can be proved by L'Hopitals rule from calculus I guess.) Thus O(logn) is preferable.
Upvotes: 5