parhloo sab kuch
parhloo sab kuch

Reputation: 17

Overall complexity with multiple operations?

If I have an unsorted array and if I first sort it by using quick sort with a run time of O(nlgn) and then search for an element using Binary search, with a run time of O(lgn) then what would be the over all run time of both these operations? Would that individual run times be added?

Upvotes: 0

Views: 264

Answers (1)

Dima Ogurtsov
Dima Ogurtsov

Reputation: 1607

It will be O(n logn) because O(n logn + logn) = O(n logn) So yes, you sum it, but in this case it doesn't matter

If the function f can be written as a finite sum of other functions, then the fastest growing one determines the order of f(n) Wikipedia

Upvotes: 1

Related Questions