Meaning of lg * N in Algorithmic Analysis

前端 未结 6 1899
暖寄归人
暖寄归人 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 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.

提交回复
热议问题