What is the overall complexity of several algorithms?

Viewed 219

The time of extract min=O(logn)

bubble-sort=O(n)

Breath-first-search=O(n+E)

For example, if an algorithm runs in O(logn) + O(n) + O(n+E) or O(logn + n + E)(I'm confused), can I say that's an O(logn) overall time complexity of above algorithms?

What is correct?

1 Answers

The Big-O notation shows how (approximately) the runtime would grow when the size of the input grows. When adding complexities, you take the "worst" of them all. O(log(n)) is negligible compared to O(n+E), as is O(n). So, if you have an algorithm that combines all these parts, the overall complexity would be O(n + E).

Related