if an algorithm takes a total time of T(log n + n^2), is this big O(log n + n^2) or simply big O(n^2) ?

Recommended Answers

All 2 Replies

Big O takes the biggest part of the time expression because it has the biggest effect. :) As n gets bigger and bigger, the log n part will get less and less significant as the n^2 part starts to dominate. Since you can toss anything smaller than n^2 in the expression, your big O turns out to be O(n^2).

I hope that helps!

awesome - thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.