Algorithm time complexity and space complexity

Source: Internet
Author: User

I. Time Complexity

 

During algorithm analysis, the total number of statement executions T (n) is a function about the problem scale N. Today, T (n) changes with N and T (n) is determined). The time complexity of the algorithm, that is, the time measurement of the algorithm. t (n) = O (f (n )),

It indicates that the growth rate of Algorithm Execution time is the same as that of F (n) as the increase of the problem scale N. It is called the approximate time complexity of the algorithm, or the time complexity for short. F (n) is a function of problem scale N.

 

O (1) constant order

O (n) linear order

O (n2) Square level

1. Derivation of the Large O-Order Method

  1. Replace all addition constants of running time with constant 1
  2. In the modified number of running functions, only the highest-order items are retained.
  3. If the highest-order item exists and is not 1, the constant multiplied by this item is removed. The result is a large level of o

 

Algorithm time complexity and space 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.