Complexity of the algorithm

Source: Internet
Author: User

Complexity of the algorithm includes time complexity and spatial complexity 1) time complexity

That is, the computational effort required to implement the algorithm. The workload of the algorithm is calculated using the number of basic operations performed by the algorithm to calculate the size of the same problem, and if the basic number of times the algorithm needs to execute depends on a particular input, the following two methods can be used to analyze the workload of the algorithm:

Algorithm workload =f (n)

(1) Average sexual state

Using a weighted average of the number of basic operations under a variety of specific inputs to measure the algorithm's work set X is a specific input in a possible input, p (x) is the probability that x appears, and T (x) is the number of basic operations performed by the algorithm when it is entered as X, the average state of the algorithm is defined as:

The DN represents the worst case complexity of all the possible inputs (2) when the algorithm executes when the scale is n

Refers to the maximum number of basic operations performed by the algorithm when the size is N. It is defined as:

2) spatial complexity of the algorithm

Refers to the amount of memory space required to execute the algorithm. The memory space occupied by the algorithm includes the space occupied by the algorithm program, the storage space occupied by the initial data entered, and the extra space required during the execution of the algorithm, such as the working unit in the execution process and the additional storage space needed for a data structure.

Complexity of the algorithm

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.