Data structure and algorithm 2016-06-02

Source: Internet
Author: User

1. The time complexity of an algorithm refers to the corresponding relationship between the running time of the algorithm and the size of the problem. An algorithm is composed of the control structure and the original operation, and its execution time depends on the combined effect. In order to facilitate the comparison of different algorithms of the same problem, the frequency (frequency) of the basic operation repetition in the algorithm is usually used as the time complexity of the algorithm. The basic operation in the algorithm generally refers to the statement in the deepest loop of the algorithm, therefore, the frequency of the basic operation statement in the algorithm is a function f (n) of the problem scale N, which is recorded as T (N) =o (f (n)).

If an algorithm does not have a loop statement, the execution frequency of the basic operation in the algorithm is independent of the problem scale N, which is called the O (1), also known as the constant order. If the algorithm has only one cycle, then the execution frequency of the basic operation of the algorithm is linearly increasing with the problem size n, which is called O (n), also known as the linear order. Commonly used are square order O (n^2), Cubic O (n^3), logarithmic order, etc.

Data structure and algorithm 2016-06-02

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.