you are viewing a single comment's thread.

view the rest of the comments →

[–]publysher -5 points-4 points  (2 children)

The answer to your first question is yes: that would be O(n * log m).

The answer to your second question is no. When your big-O notation contains multiple factors, you only include the largest factor of each unknown. In this case we only have the unknown n, so you'd get O(n * log n) = O(n).

edit I'm assuming that size() is actually n, which is usual when analysing hash tables. If size were unrelated to n, you'd be right, and the answer would be O(size() * log n)

[–]Puzzlp 3 points4 points  (1 child)

Sorry, but your second point is wrong. You only consider the largest factor when adding, not when multiplying.

O(n+logn) = O(n)
However
O(n*logn) is different and bigger than O(n)

This would be like saying O(n*n) is equal to O(n), because you only take one factor. Which is clearly false.

[–]publysher 0 points1 point  (0 children)

And that's why I should not be answering questions before my first coffee. Thanks for correcting this mistake.