Binary logarithm
In mathematics, the binary logarithm (log2 n) is the logarithm for base 2. It is the inverse function of 2n.
Related Topics:
Mathematics - Logarithm - Base 2 - Inverse function
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
The binary logarithm is often used in computer science and information theory (where it is frequently written lg n), because it is closely connected to the binary numeral system. The number of digits (bits) in the binary representation of a positive integer n is the integral part of lg n + 1, i.e.
Related Topics:
Computer science - Information theory - Binary numeral system - Bit - Integral part
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
: lfloor lg n floor + 1.
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
In information theory, the definition of the amount of self-information and information entropy involves the binary logarithm; this is needed because the unit of information, the bit, refers to information resulting from an occurrence of one of two equally probable alternatives.
Related Topics:
Self-information - Information entropy - Unit
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
The binary logarithm also frequently appears in the analysis of algorithms. If a number n greater than 1 is divided by 2 repeatedly, the number of iterations needed to get a value at most 1 is again the integral part of lg n. This idea is used in the analysis of several algorithms and data structures. For example, in binary search, the size of the problem to be solved is halved with each iteration, and therefore roughly lg n iterations are needed to obtain a problem of size 1, which is solved easily in constant time. Similarly, a perfectly balanced binary search tree containing n elements has height lg n+1.
Related Topics:
Analysis of algorithms - Algorithm - Data structure - Binary search - Binary search tree
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
However, the running time of an algorithm is usually expressed in big O notation, ignoring constant factors. Since log2 n = (1/logk 2)logk n, where k can be any number greater than 1, algorithms that run in O(log2 n) time also run in, say, O(log13 n) time. The base of the logarithm in expressions such as O(log n) or O(n log n) is therefore not important.
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
In other contexts, though, the base of the logarithm needs to be specified. For example O(2lg n) is not the same as O(2ln n) because the former is equal to O(n) and the latter to O(n0.6931...).
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
Algorithms with running time n lg n are sometimes called linearithmic. Some examples of algorithms with running time O(lg n) or O(n lg n) are:
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ Table of Content ~
| ► | Introduction |
| ► | See also |
~ What's Hot ~
~ Community ~
| ► | History Forum Come and discuss about History, Civilizations, Historical Events and Figures |
| ► | History Web-Ring A community of sites, blogs and forums dedicated to History. Do not hesitate to submit your site. |
and are licensed under the GNU Free Documentation License.
Lexicon - Privacy Policy - Spiritus-Temporis.com ©2005.
