-1

Here's the equation:

enter image description here

Upper Bound:

Without the log i understand the Upper bound on this would be O(n^2), but with the log will the upper bound be O(log n^2)? Or is the log negated?

Lower Bound:

If we assume that this is only run once, then shouldn't this be lower bounded by O(1)?

bagofmilk
  • 1,492
  • 8
  • 34
  • 69
  • What do you mean by "assume that this is only run once"? And what do you mean by "lower bounded"? `g(x) = 1` is a lower bound for `f(x) = 2*log(3n+n^2)`, but I don't see how that helps. – Nelfeal Dec 14 '18 at 18:18

2 Answers2

2

log(n^2) = 2*log(n). That means O(log n^2) = O(log n).

Nelfeal
  • 12,593
  • 1
  • 20
  • 39
0

First of all lower bound is marked as Ω not O.

Also, Ω(1) is a lower bound but it's not a tight one since for n >= 3:

2log(3n + n^2) > log(n) = Ω(log(n))

and for the upper bound:

2log(3n + n^2) < 2 * log(n^3) = 6log(n) = O(log(n))

And since F(n) = O(log(n)) and F(n) = Ω(log(n))

it means it's a tight bound and it's marked as: Θ(log(n))

Tomer Wolberg
  • 1,256
  • 10
  • 22
  • Sorry but both of those are false: `2log(3n + n^2) > log(n)` and `2log(3n + n^2) < 2 * log(n^3)`. – Nelfeal Dec 15 '18 at 05:47
  • @Nelfeal It's not false... For `n > 2.31`: `3n + n^2 < n^3` => `2log(3n + n^2)<2log(n^3)` and for every positive `n`:`2log(3n + n^2) > log(n)`. – Tomer Wolberg Dec 16 '18 at 16:25
  • Then specify that `n > 2.31` (or rather `n >= 3` since it's supposed to be an integer). Otherwise it's false, even `2log(3n + n^2) > log(n)`: with `n = 0.1` for example. – Nelfeal Dec 16 '18 at 16:41
  • @Nelfeal it doesn't matter if it's from `n >= 3` or `n>=1000000000` as long as it's true when n approaches infinity, complexity describes the limiting behavior of a function. Also no one said n has to be an integer. And `2log(3n + n^2) > log(n)` for every positive number (including 0.1) I don't understands your point. – Tomer Wolberg Dec 16 '18 at 17:06
  • I'm aware of what matters in terms of complexity. Nevertheless, your statements are still false unless you specify a lower bound for `n`, or something in the lines of "for a large value of `n`". As for `n` being an integer, it's very often the case when talking about the complexity of an algorithm; surely you know what I mean. Finally, `2*log2(3*n + n^2) > log2(n)` [*is* false for `n = 0.1`](https://www.google.com/search?q=2*log2(3*0.1+%2B+0.1^2)+-+log2(0.1)+%3D). – Nelfeal Dec 16 '18 at 17:20
  • @Nelfeal Right, I meant `2*log2(3*n + n^2) > 2log2(n)` not `2*log2(3*n + n^2) > log2(n)` sorry for that. But still it doesn't matter because it's obvious that both statement are true when `n->infinity`. But fine I'll edit the answer to clarify that. – Tomer Wolberg Dec 16 '18 at 17:31