Experience of time complexity

Source: Internet
Author: User
Time complexity the code of experience without loops is called Chang (O (1)), and the constant order cannot be a loop most of the single-cycle to linear-order O (n) Double-loop to the square-order O (N2) Triple-loop for the cubic-order O (N3) binary lookup method is the logarithmic-order algorithm if a one-cycle is not , the algorithm must be a logarithmic order, a summary of the time complexity, the size of the problem (how many problems), the frequency of the sentence (the sum of the statements required to solve the problem) time complexity (the rate of growth of the algorithm execution time) as determined 3 times instead of n solve the time complexity is a constant order, If the output of a helloworld, as long as 1 execution of the statement can solve the problem if the execution of the statement execution, but the increase to n can solve the problem is a linear order problem, such as a single heavy loop only need to loop n times to ensure that the problem, that is, the linear order if the execution statement grows more than n times, very N2 The problem of square order, the common double loop is definitely the least N*N time statement to solve the problem is the square order problem if the execution statement grows more than n*n times that is n^ (3) N*n*n execution statement to solve the problem, this is the cubic order problem common triple loop least n*n* N-Times execution is a cubic order problem.

Experience of time complexity

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.