Meaning of lg * N in Algorithmic Analysis

2019-03-23 23:23发布

I'm currently reading about algorithmic analysis and I read that a certain algorithm (weighted quick union with path compression) is of order N + M lg * N. Apparently though this is linear because lg * N is a constant in this universe. What mathematical operation is being referred to here. I am unfamiliar with the notation lg * N.

6条回答
\"骚年 ilove
2楼-- · 2019-03-23 23:33

lg n refers to log base n. It is the answer to the equation 2^x = n. In Big O complexity analysis, the base to log is irrelevant. Powers of 2 crop up in CS, so it is no surprise if we have to choose a base, it will be base 2.

A good example of where it crops up is a fully binary tree of height h, which has 2^h-1 nodes. If we let n be the number of nodes this relationship is the tree is height lg n with n nodes. The algorithm traversing this tree takes at most lg n to see if a value is stored in the tree.

As to be expected, wiki has great additional info.

查看更多
霸刀☆藐视天下
3楼-- · 2019-03-23 23:36

I'm assuming you're talking about the algorithm analyzed on slide 44 of this lecture: http://www.cs.princeton.edu/courses/archive/fall05/cos226/lectures/union-find.pdf

Where they say "lg * N is a constant in this universe" I believe they aren't being entirely literal. lg*N does appear to increase with N as per their table on the right side of the slide; it just happens to grow at such a slow rate that it can't be considered much else (N = 2^65536 -> log*n = 5). As such it seems they're saying that you can just ignore the log*N as a constant because it will never increase enough to cause a problem.

I could be wrong, though. That's simply how I read it.

edit: it might help to note that for this equation they're defining "lg*N" to be 2^(lg*(N-1)). Meaning that an N value of 2^(2^(65536)) [a far larger number] would give lg*N = 6, for example.

查看更多
Viruses.
4楼-- · 2019-03-23 23:37

The answers given here so far are wrong. lg* n (read "log star") is the iterated logarithm. It is defined as recursively as

         0             if n <= 1
lg* n =
         1 + lg*(lg n) if n > 1 

Another way to think of it is the number of times that you have to iterate logarithm before the result is less than or equal to 1.

It grows extremely slowly. You can read more on Wikipedia which includes some examples of algorithms for which lg* n pops up in the analysis.

查看更多
女痞
5楼-- · 2019-03-23 23:45

The recursive definition of lg*n by Jason is equivalent to lg*n = m when 2 II m <= n < 2 II (m+1) where
2 II m = 2^2^...^2 (repeated exponentiation, m copies of 2)
is Knuth's double up arrow notation. Thus
lg*2= 1, lg*2^2= 2, lg*2^{2^2}= 3, lg*2^{2^{2^2}} = 4, lg*2^{2^{2^{2^2}}} = 5.
Hence lg*n=4 for 2^{16} <= n < 2^{65536}. The function lg*n approaches infinity extremely slowly. (Faster than an inverse of the Ackermann function A(n,n) which involves n-2 up arrows.)

Stephen

查看更多
够拽才男人
6楼-- · 2019-03-23 23:48

Logarithm is denoted by log or lg. In your case I guess the correct interpretation is N + M * log(N).

EDIT: The base of the logarithm does not matter when doing asymptotic complexity analysis.

查看更多
【Aperson】
7楼-- · 2019-03-23 23:49

lg is "LOG" or inverse exponential. lg typically refers to base 2, but for algorithmic analysis, the base usually doesnt matter.

查看更多
登录 后发表回答