The measurement method of 2_ algorithm efficiency

Source: Internet
Author: User

0. Getting Started supplements

1) When the computer program is written, the time taken to estimate the operation of the algorithm according to the statistical method has the following main time consumption:

A. The strategy adopted by the algorithm, namely the scheme

B. Code quality generated by compilation

C. Input size

D. Speed of machine execution instructions

2) Asymptotic growth of functions: given f (n) and g (n), if there is a positive integer n, so that for all n>n, there is f (n) > g (n), then f (n) growth is faster than g (n).

1. time complexity of the algorithm —————— > run time requirements

At the time of the algorithm analysis, the total number of executions of the statement T (N) is a function of n, which parses T (n) with N to determine the order of magnitude of T (N).

Time measurement of the algorithm: T (n) =o (f (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. F (n) is a function of the problem size n.

Optimal algorithm: With the increase of N, T (n) is the slowest-growing algorithm.

Common time Complexity:

C (constant)

O (1)

Constant order

An+b

O (N)

Linear order

An^2+bn+c

O (n^2)

Square Order

Elogn+f

O (LOGN)

Logarithmic order

Jn+pnlogn+h

O (NLOGN)

Nlogn Order

1^m

O (2^n)

Exponential order

Time Complexity size Ordering:

O (1) < O (Logn) < O (n) < O (Nlogn) < O (n^2) < O (n^3) < O (2^n) < O (n!) < O (n^n)

2. spatial complexity —————— > Space Requirements
Calculate the storage space required by the algorithm.

The measurement method of 2_ algorithm efficiency

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.