Reputation: 4085
I have an algorithm with two operations. 1st operation running time is O(n) and running time for 2nd operation is O(log n). In this situation what will be the running time for complete algorithm ? will it be O(n) or O(n) + O(log n) ?
Upvotes: 2
Views: 255
Reputation: 11566
O(logn)
in relation to O(n)
decreases exponentially with N, so it is O(n)
.
Upvotes: 1
Reputation: 580
O(n + log(n)) = O(n)
Your time complexity will be O(n)
http://en.wikipedia.org/wiki/Big_O_notation
Upvotes: 7