0

Can I say that:

log n + log (n-1) + log (n-2) + .... + log (n - k) = theta(k * log n)?

Formal way to write the above:

Sigma (i runs from 0 to k) log (n-i) = theta (k* log n)?

If the above statement is right, how can I prove it?

If it is wrong, how can I express it (the left side of the equation, of course) as an asymptotic run time function of n and k?

Thanks.

Programmer
  • 750
  • 2
  • 9
  • 17

2 Answers2

2

Denote:

LHS = log(n) + log(n-1) + ... + log(n-k)

RHS = k * log n

Note that:

LHS = log(n*(n-1)*...*(n-k)) = log(polynomial of (k+1)th order)

It follows that this is equal to:

(k+1)*log(n(1 + terms that are 0 in limit))

If we consider a division:

(k+1)*log(n(1 + terms that are 0 in limit)) / RHS

we get in limit:

(k+1)/k = 1 + 1/k

So if k is a constant, both terms grow equally fast. So LHS = theta(RHS).

Wolfram Alpha seems to agree.

When n is constant, terms that previously were 0 in limit don't disappear but instead you get:

(k+1) * some constant number / k * (some other constant number)

So it's:

(1 + 1/k)*(another constant number). So also LHS = theta(RHS).

BartoszKP
  • 34,786
  • 15
  • 102
  • 130
  • I need an explicit theta expression, are you saying that this is theta(lg (n^(k+1))? – Programmer Dec 13 '13 at 21:49
  • Thank you very much! Can I say that generally log (polynomial of kth order) = tetha(k*log n)? – Programmer Dec 13 '13 at 21:59
  • @Programmer As I see it now - yes. But I'd be very careful, limits can be very counter intuitive ;) But it's easy to experiment with WolframAlpha. – BartoszKP Dec 13 '13 at 22:01
  • Thank you very much :) The course I'm taking is about algorithms, so the mathematical layer isn't so important. – Programmer Dec 13 '13 at 22:06
  • In you answer you are saying that log (polynomial of k+1 order) = theta(k*log n), while in you comment you said that log(polynomial k order) = theta(k*log n) - is that make sense? – Programmer Dec 13 '13 at 22:22
  • @Programmer Regarding your question: why don't you just check this for yourself, this is trivial. Substitute `k` instead of `k+1` in my derivation, or change it in WolframAlpha input I provided so you'll notice it doesn't matter. – BartoszKP Dec 13 '13 at 22:43
  • I tried to notify you with the @ sign in the second comment, but I didn't succeed (I'm new in Stackoverflow). – Programmer Dec 13 '13 at 22:43
2

When proving Θ, you want to prove O and Ω.

Upper bound is proven easily:
log(n(n-1)...(n-k)) ≤ log(n^k) = k log n = O(k log n)

For the lower bound, if k ≥ n/2, then in the product there is n/2 terms greater than n/2:
log(n(n-1)...(n-k)) ≥ (n/2)log(n/2) = Ω(n log n) ≥ Ω(k log n)

and if k ≤ n/2, all terms are greater than n/2:
log(n(n-1)...(n-k)) ≥ log((n/2)^k) = k log(n/2) = Ω(k log n)

pepo
  • 669
  • 4
  • 7
  • Why log (n*(n-1)*...*(n-k) <= log (n^k)? I mean, notice that the degree of polynomial n*(n-1)*...*(n-k) is (k+1), not k - does it matter? – Programmer Dec 13 '13 at 22:19
  • You're right, it should have been `log(n^(k+1))`, but that's not a problem since this still fits in `O(k log n)`. Same thing in the last line, should be `log((n/2)^(k+1))`, but also doesn't really change anything. – pepo Dec 14 '13 at 00:46