C Data Structure and algorithm-algorithm complexity

Source: Internet
Author: User

Algorithm complexity is divided into time complexity T (N) and space complexity F (n)

Time Complexity: the time required to execute an algorithm program depends on the speed of hardware, the programming language level, compiler optimization, data size, and execution frequency, the first three indicators have great uncertainty. Therefore, the time complexity of the algorithm is the function of data scale N as long as the latter two indicators are used. T (n) = O (f (n), where O indicates the same order, that is, when n approaches infinity, T (N) and F (N) the ratio is a constant not 0, that is, the progressive time complexity. The ascending order of time complexity is: constant order O (1), logarithm order o (log2n), linear order O (N), linear logarithm order o (nlog2n), square order O (N ^ 2), cubic order O (N ^ 3), k power order O (N ^ K), exponential order o (2 ^ N ).

Space complexity: Memory occupied by algorithms, input data, and running time. Compression storage technology is usually used.

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.