At the beginning, I talked about the analysis of the space complexity and time complexity of the algorithm. How did the algorithm come from and how it evolved step by step? I have read the path of the algorithm before. This is a bit familiar with it, is the specific example of the time complexity analysis is not very good
Yes, you should exercise more. After all
This is a basic thing ~
Then there is recursion and sub-governance ~ We only have time to talk about recursion tonight ~
Actually, we have seen recursion ~ I used to think it was very easy when I first started to get started, and it was very difficult to get started slowly. That is, when I realized the code, I encountered a mental obstacle. If I was a sophomore, I learned recursion ~ An important foundation
In the past, I was impressed by calling myself, "shirking responsibility", mathematical formulas, recursive graphs, and the classic Fibonacci series ~
In the past, when reading or writing recursive code, we encountered a mental obstacle, which is hard to explain. However, we need to understand one of the steps and get stuck. Why ~
Through tonight's course, I think it may be because I have a wrong understanding of recursive algorithms ~ We should fully grasp its nature (the most direct contact nature to be taken out) and "not seeking for a thorough solution "~
Tonight, the teacher put the essence of recursive space into a stack. The critical ending condition is at the top, and the bottom layer is N. This is like a grenade, the top is an insurance ring. The code we want to write is insurance.
Ring (critical termination condition) and explosive (recursive relationship, reaction chain )~ This memory is very important, because it makes it clear what you want to write, there will be no mental barriers ~ It's easy to understand. What kind of recursive code should be written ~
To write recursive code, you must first introduce the critical termination condition and recursive relationship, and then implement the code !!! To analyze the time complexity of recursion, you must first write a recursive analysis !!! Recursion: focuses on "returning" and turning to "returning!
For example, the Fibonacci series F [N] = f [n-1] + F [N-2], the analysis is T (n) into two T (N) (T (n-1) and T (n-2) are seen as T (n), is T (n) = 2 T (n) + O (1 ),
Every T (n) is changed to 2 T (n), and there are N, that is, the complexity of O (2 ^ n ~ (There is also an O (n), which is ignored )~ <Note! The two words "change" here are very important ideas!>
There is also the full arrangement ~ Classic ~
Perm (n) = (changed to) RN (Perm (n-1) + rn-1 (Perm (n-1) ...... R0 (Perm (n-1 ))
Recursive Algorithms are almost all about finding the relationship between F (N) and F (n-1) or F (n/2!
I believe these are actually very simple. I know that the direction I understand is wrong, that is, the method of opening is wrong, so I learned the algorithm so slowly !!! Come on !!!
Note 1: Recursion