Meaning of lg * N in Algorithmic Analysis

前端 未结 6 1905
暖寄归人
暖寄归人 2021-02-05 05: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 th

相关标签:
6条回答
  • 2021-02-05 05:58

    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.

    0 讨论(0)
  • 2021-02-05 06:00

    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

    0 讨论(0)
  • 2021-02-05 06:05

    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.

    0 讨论(0)
  • 2021-02-05 06:14

    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.

    0 讨论(0)
  • 2021-02-05 06:16

    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.

    0 讨论(0)
  • 2021-02-05 06:19

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

    0 讨论(0)
提交回复
热议问题