Time complexity: a theoretical definition

Source: Internet
Author: User
Tags constant

The asymptotic growth of the function : given two functions f (n) and g (n), if there is an integer n, so that for all n > N,f (n) is always greater than g (n), then we say that f (n) is growing nearly faster than G (n).

definition of algorithm time complexity
At the time of the algorithm analysis, the total number of executions of the statement T (N) is a function of the problem size n, which then analyzes the change of T (n) with N and determines the order of magnitude of T (N). The time complexity of the algorithm, which is the time measurement of the algorithm, is recorded as: T (n) =o (f (n)). It indicates that with the increase of the problem size n, the growth rate of the algorithm execution time is the same as the growth rate of f (n), which is called the asymptotic time complexity of the algorithm, referred to as the time complexity. where f (n) is a function of the problem size n. This method uses capital O () to represent the algorithm's time complexity notation, which we call the Big O notation. In general, the algorithm with the slowest growth of T (n) is the optimal algorithm with the increase of N.

derivation of the large O-order:
1. Replace all the addition constants in the run time with constant 1.
2. In the modified run Count function, only the highest order is preserved.
3. If the highest order exists and is not 1, the constant multiplied by the item is removed. The result is the Big O-order.

The time complexity of the common time is spent from small to large
O (1) < O (Logn) < O (n) < O (Nlogn) < O (N2) < O (n3) < O (2n) < O (n!) < O (NN)

The above is quoted from the "Big Talk data Structure"

Asymptotic Analysis
It is asymptotic analysis to consider the efficiency of the algorithm when the input scale tends to be infinite.
Asymptotic analysis is to ignore the effects of specific machines, programming, or compilers, and only observe the efficiency of the algorithm when the input size n takes the trend infinity.

O, Ω, θ indicate

O visualize the asymptotic upper bounds of the ⩽ function
Omega imagined as the asymptotic lower bound of the ⩾ function
Θ imagined = The exact bounds of the function

The above is quoted from the "Algorithm of the Road"

Θ (g (n)) ={f (n): Presence of normal number c1,c2 and n0, so that for all n⩾n0, there is 0⩽c1g (n) ⩽f (n) ⩽c2g (n)}

O (g (n)) ={f (n): Presence of normal number C and n0, so that for all n⩾n0, there is 0⩽f (n) ⩽CG (n)}

Ω (g (n)) ={f (n): Presence of normal number C and n0, so that for all n⩾n0, there is 0⩽CG (n) ⩽f (n)}

O (g (n)) ={f (n): For any normal number C, there is a constant n0>0, so that for all n⩾n0, there is 0⩽f (n) ⩽CG (n)}

Ω (g (n)) ={f (n): For any normal number C, there is a constant n0>0, so that for all n⩾n0, there is 0⩽CG (n)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.