In computer science, big O notation is used to ...

17 downloads 151299 Views 105KB Size Report
In computer science, big O notation is used to categorize algorithms by how they react to alter in input length. It is used to consider the error dedicated while ...
In computer science, big O notation is used to categorize algorithms by how they react to alter in input length. It is used to consider the error dedicated while substituting the asymptotic length, of an arithmetical function, by the value it takes at a large finite case. The well-known case is the problem of considering the remainder term in the prime number theorem. The big O notation describes functions according to their increase rates, dissimilar functions with the same increase rate can be indicated using the same O notation. The letter O is used since an increase rate of the function is also denoted as order of the function. The description of the function in terms of big O notation gives an upper bound on an increase rate of the function. Connected with big O notation are some related notations, using the symbols o, Ω, ω, and Θ, to depict other types of bounds on asymptotic increase rates. The main area of application of big O notation is used in analysis of algorithms. In this uses, the function g(x) occurring within O(...) is selected to be as straightforward as possible, neglecting constant factors and lower order terms. Big O notation is analyzing algorithms for efficiency. For instance, the number of steps it takes to complete the problem of length n can be establish to be T(n) = 4n2 − 2n + 2. As n increases great, the n2 term will come to control, so that all other terms can be ignored, for example when n = 500, the term 4n2 is 1000 times as large as the 2n term. Neglecting the latter would have insignificant effect on the expression value for the purposes. Additional, the coefficients become unrelated when we compare to any other order of expression, such as an expression having the term n3 or n4. Even when T(n) = 1,000,000n2, if U(n) = n3, the latter will at all times exceed the previous once n increases larger than 1,000,000 (T(1,000,000) = 1,000,0003= U(1,000,000)). Also, the number of steps bases on the information of the machine type on which the algorithm executes, but dissimilar kinds of machines usually differ by only a constant factor in the number of steps wanted to implement the algorithm. Thus, the big O notation captures what remainders; we say that the algorithm has order of n2 time complexity. Time complexity In the list of classes of functions is encountered if analyzing the running time of an algorithm. In every case, c is a constant and n increase without bound. The slower-growing functions are generally listed first. Name

Notation

Example

O(1)

constant

Determining if a binary number is even or odd; Calculating (1) n ; Using a constant-size lookup table.

O(log log n)

double logarithmic

Number of comparisons spent finding an item using interpolation search in a sorted array.

O(log n)

logarithmic

Finding an item in a sorted array with a binary search or a balanced search tree.

O ( n) c 0  c  1

fractional power

Searching in a tree.

O(n)

linear

Finding an item in an unsorted list or a tree (worst case) or in an unsorted array.

O(n log* n)

n log-star n

Performing triangulation of a simple polygon using Seidel's algorithm, or the union–find algorithm.

O(n log n)  O(log n!)

linear arithmetic, log linear, or quasi linear

Performing a fast Fourier transform; heap sort, quick sort, or merge sort.

O( n 2 )

quadratic

Multiplying two n-digit numbers; bubble sort, Shell sort, quick sort, selection sort or insertion sort.

O(n c ), c  1

polynomial or algebraic

Tree-adjoining grammar parsing; maximum matching for graphs.

L-notation or subexponential

Factoring a number using the quadratic sieve or number field sieve.

O(c n ), c  1

exponential

Finding the solution to the travelling salesman problem using dynamic programming.

O(n! )

factorial

Solving the traveling salesman problem via brute-force search; finding the determinant with expansion by minors; enumerating all partitions of a set.

Ln a, c,0  a  1  e (c  o(1))(ln n

a

1 a

)(ln ln n )

Suggest Documents