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