Always wondered why the log is often seen in algorithms
See "Data Structure and algorithm analysis Java Language description" (3rd edition) 2.4.3 section today
To find out the reason for the realization of the maximal sub-sequence and the partition algorithm
Looking at the last sentence on page 29th, the following section reads:
Even if n = 2 ^ k, then T (n) = n * (k + 1) = n log n + n = O (n log n)
We can get k = log n according to the above N = 2 ^ k
So substituting the formula to eliminate the variable K:
n * k + n = n log n + N
At this point, only one variable can clearly show the relative growth rate expressed by the formula.
So if there is a similar conditional relationship (e.g. N = 2 ^ k) During the derivation of the formula
You can substitute formulas to eliminate extraneous variables in the form of log (such as log N)
Little Tips
LOG: Base 2
LG: Base 10
LN: base E
What exactly is log in the algorithm?