Reputation: 347
I'm working on some homework and I want to make sure my analysis of the upper bound for the solution is correct.
Here's what I do.
The complexity of my solution is therefore O(n+ k·logn). I was wondering whether I can safely approximate to O(n), if I take into consideration that k is a constant.
Upvotes: 0
Views: 42
Reputation: 65498
Yes, if k is a constant, then Θ(n + k log n) = Θ(n) + Θ(k log n) = Θ(n) + Θ(log n) = Θ(n).
Upvotes: 1