2

I've never used log before, nor worked with big-O notation, so I'm completely useless at this stuff. Any, any, any help or direction you can give would be helpful as the professor hasn't covered this in the least and this is the type of thing he's throwing at us on exams:

Find a(n) where s(n) = O(a(n)) for:

$$s(n) = (n \log_2 n + 1)^2$$

I just have no idea where to even begin.

By way of apology / context, I've read my discrete math text book chapter on log and big-O notation 8-10 times now, scoured Google for a full day, banged my head against this for hours more and come up with nothing. I don't know how but I'm in my 4th year of college and somehow none of my classes covered logarithms and I'm just not finding good resources on how to learn this stuff, so here I am for help. (I've given up on passing the class already, just trying to keep learning so I can hopefully pass when I retake next semester.)

Steverino
  • 155
  • 1
    Just curious: what are you studying if you are working with big-O notation (pretty serious coputer engineering stuff) but haven't covered logarithms, which are basically a highschool thing? – orion Mar 26 '14 at 07:51
  • I'm in a discrete math course for a Computer Science degree. We've done induction, pumping lemma, set theory, lang theory, etc and I had no problems. Until logarithms came up I had a B+ in this class. I don't know if it's a symptom of public schooling, raw bad luck or what, but I made it through middle and high school and university algebra, geometry, trig, calc, 2 years of CS before I saw a single logarithm, and now I'm getting dumped off the deep end into problems like these, it's a shock. I also have to parse logarithms containing / contained w/in square roots, etc. I feel so clueless... – Steverino Mar 26 '14 at 17:55
  • This seems a really unbalanced course. Complete lack of elementary function theory and calculus... – orion Mar 26 '14 at 21:23

1 Answers1

1

What you big-O does is just follow the biggest contribution that dominates over all others when $n$ is really large. And you ignore any constant prefactors that really don't matter. It just tells you in what way an expression grows.

Just square this:

$$n^2 (\log_2 n)^2+2n\log_2 n+1$$ You see that at least the $+1$ is completely irrelevant here.

On the other hand: logarithm (any base, they are all proportional to one another via $\log_{a}n=\frac{\log n}{\log a}$ where $\log $ can be a natural logarithm, or base-10, whatever you prefer) grows much more slowly than any power of $n$ does. So $O(1)<O(\log n)<O(n)<O(n\log n)$.

The middle term is negligible compared to the first one, so you can write

$$s(n)=O(n^2(\log n)^2)$$

orion
  • 15,781
  • I'd vote you up but my rep isn't high enough. This is a good answer, it never occurred to me you can leave (n^2)(log n)^2 in that form, but it makes sense. I understand the basic idea that (log_2 n) is the number of powers 2 must be raised in order to make n. But I don't know the properties of log any further than that. I am going to try Khan Academy and other sources in the future, the textbook the professor picked for us is good on many topics but expects us to already know log. – Steverino Mar 26 '14 at 17:49
  • You can probably accept the answer anyway. Logarithms are not difficult. Very important, but not difficult. When you figure out $\log(ab)=\log a+\log b$ that's basically it (from this it follows that $\log a^k=k\log a$ and everything else). Then you just have to get a feeling how they behave as a function: $\log 1=0$, negative for <1, negative pole at x=0, and extremely slowly increasing at x>1. Base $a$ of log tells which $a^x$ you are inverting (useful: base 2, base e (natural) and base 10, which basically counts digits of the number). They are all proportional. There. Logs in 500 chars :) – orion Mar 26 '14 at 20:59
  • @fts_acer maybe this will help

    http://math.stackexchange.com/questions/722125/what-are-logarithms

    – orion Mar 26 '14 at 21:09