slonkar
slonkar

Reputation: 4085

Running time of algorithm with two different operations

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

Answers (3)

wholerabbit
wholerabbit

Reputation: 11566

O(logn) in relation to O(n) decreases exponentially with N, so it is O(n).

Upvotes: 1

Fitz
Fitz

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

SomeWittyUsername
SomeWittyUsername

Reputation: 18368

Total time is O(n) + O(logn) = O(n). So it's O(n)

Upvotes: 4

Related Questions