Algorithm complexity analysis method and algorithm overview

Source: Internet
Author: User

algorithm Definition : A description of the solution steps that solve a particular problem.

algorithm features : poor, deterministic, feasibility, input, output

design requirements for algorithms : correctness, readability, robustness, high efficiency and low storage requirements

algorithm Measurement Method : Post-mortem method (unscientific), pre-analysis and estimation method


The asymptotic growth of the function: given two functions f (n) and g (n), if there is an integer n, so that for all n>n,f (n) is always greater than g (n), then we say that f (n) is growing nearly faster than G (n).

So, can come to the conclusion: Determine an algorithm is not good, you can compare the algorithm's key execution times function of the asymptotic growth, the basic can be analyzed: an algorithm, with the increase of N, it will be better than the other algorithm, or more and more worse than an algorithm.


Steps to derive the large O-order:

    • Replace all addition constants in run time with constant 1

    • Only the highest order is kept in the modified run Count function

    • If the highest order exists and is not 1, the constant multiplied by the item is removed

The result is the Big O-order


With this step, we can get the algorithm to run the number of expressions, and quickly get its time complexity, that is, the large O-order.

It is easy to deduce the large O-order, but the expression of how to get the number of runs is a mathematical foundation.

Common time complexity ordering:

O (1) <o (LOGN) <o (n) <o (NLONGN) <o (n^2) <o (n^3) <o (2^n) <o (n!) <o (N^n)

Algorithm complexity analysis method and algorithm overview

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.