Data structure and algorithm 2--time complexity and space complexity __ data structures and algorithms

Source: Internet
Author: User

Algorithm efficiency measurement methods: Ex-post statistical methods, ex ante analysis and estimation methods.

The time complexity of the algorithm: in the analysis of the algorithm, the total execution times of the statement T (N) is about the problem scale n function, and then analyze T (n) with N and determine the order of magnitude T (N). The time complexity of the algorithm is recorded as: T (n) =o (f (n)). It indicates that the growth rate of the algorithm execution time is the same as that of F (n) with the increase of the problem scale N, which is called the asymptotic time complexity of the algorithm, referred to as time complexity. With the increase of the input scale n, the slowest growth of T (n) algorithm is the optimal algorithm.

The method of large O-order is deduced: 1. Substituting constant 1 for all additive constants in the running time; 2. In the modified run-times function, only the highest order is preserved; if the highest order exists and is not 1, the constant that multiplies the item is removed. (Consider series)

Linear order: generally contains non nested loops involving linear order, linear order is with the expansion of the problem scale n, the corresponding number of calculation is linearly increasing.

Square Order: 2 loops are nested together.

Log Order:

Analysis of time complexity of function call

The spatial complexity of the algorithm: the required storage space for the algorithm, S (n) =o (F (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.