00:01
So we would like to show that log of n factorial is big theta of n times log n.
00:14
So first, to establish an upper bound, i'm going to notice that n factorial is equal to, of course, n times n minus 1 times n minus 2 times dot dot dot times 3 times 2 times 1, which is a product of n factors, right? n down to 1.
00:41
N factors, which is less than n times n times n times n dot times n, also for n factors, since almost all of these are just n, or almost all of these are less than n, the exception of n itself.
01:04
This is equal to n to the n.
01:09
So n factorial is less than n to the n, since log is increasing.
01:15
That tells us log of n factorial is less than log of n to the n, which is equal to n times log n.
01:24
Great, so we conclude then that log of n factorial is big o of n log n.
01:34
Now, conversely, i'd like to notice that n factorial, again, n times n minus 1 times n minus 2 dot dot dot 3 times 2 times 1, is greater than n times n minus 1 minus 2 dot dot dot.
01:54
So, this is true to n over 2, or n plus 1 over 2, n minus 1 over 2.
02:05
This in the case of n is even.
02:07
This in the case of n is odd.
02:10
In general, this is going to be, and let me pull this down so i have a little bit more space.
02:18
This should be n minus 2 factors.
02:25
Sorry, not n minus 2, n over 2 factors...