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.

templatetypedef
  • 328,018
  • 92
  • 813
  • 992
themaestro
  • 11,712
  • 19
  • 51
  • 72
  • Do you really mean “log times N”? – Gumbo Mar 06 '11 at 18:55
  • 6
    No, it's "log star", the number of times log must be iterated to reach a constant. The asymptotically tight upper bound on that particular variant of union find is m times inverse Ackermann, but there's an easier analysis that gets the weaker bound quoted. – user635541 Mar 06 '11 at 19:07
  • 2
    https://secure.wikimedia.org/wikipedia/en/wiki/Union_find#History – starblue Mar 06 '11 at 19:15

6 Answers6

35

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.

jason
  • 220,745
  • 31
  • 400
  • 507
  • 4
    To add to that: It grows so slow that in practice it can be treated as a constant – Voo Mar 06 '11 at 22:51
0

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

Glasby
  • 101
  • 1
0

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.

DRobinson
  • 4,341
  • 19
  • 29
-4

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.

ChrisJ
  • 4,883
  • 19
  • 18
-4

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

user623879
  • 3,842
  • 8
  • 32
  • 52
-4

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.

Tom Murphy
  • 295
  • 2
  • 12
  • 2
    `lg*` is the iterated logarithm. – jason Mar 06 '11 at 19:11
  • Something new learned. So in the same manner sqrt* ones out like lg*. I'm surprised there is a real world algorithm that demonstrates it, and so I'll be checking out the weighted quick union with path compression and the wiki article. – Tom Murphy Mar 06 '11 at 21:08