01. Algorithm Introduction and List query

Source: Internet
Author: User

As a summary of self-study, this section includes basic algorithm introduction and * * * (later)

Part One.

* Basic concepts of algorithms

A computational process, a method of solving a problem

* Related Review

Recursion: Call yourself and have an end condition

* Two basic properties

Time complexity: One thing to evaluate the efficiency of an algorithm's operation (time spent)

Analogy to some things in life, such as: blink of an eye--an instant, a mental arithmetic question--a few seconds, boil water--a few minutes

In summary, they are different orders of magnitude of time measurement units.

Print (' Hello World ') O (1) Note: In this form, the time complexity is constant, even if there are multiple lines

O (n) Note: N of the loop is n

O (n2) Note: Cycle n*n times

O (n3) Note: Cycle n*n*n times

       Note: The order of magnitude means that in the above process, it is not affected by a row/lines

* A formula used to estimate the run time of the algorithm in time complexity

* Generally, algorithms with high time complexity are slower than algorithms with low complexity

* Common time complexity (sorted by efficiency)

O (1) < O (Logn) < O (n) < O (Nlogn) < O (N2) < O (N2logn) < O (N3)

* How to judge the complexity of time at a glance

The process of halving the cycle, O (LOGN)

Several loops are the complexity of N's several sides.

Spatial complexity: An equation used to estimate the size of the algorithm's memory (space occupied)

"Space Change Time"

01. Algorithm Introduction and List query

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.