I decided to take a few big parts. Today, I started to study in open classes. One is to consolidate my understanding of algorithms, and the other is to share my learning experience.
The algorithm class at Princeton University seems to have been completed. There are only handouts, and there seems to be no video. Next I will take an introduction to algorithms at MIT.
I am a lazy child. I hope you can supervise me. No supervision, I can't continue, er, haha. Thank you.
Why learning algorithms?
(1) What is more important than performance? Correctness, conciseness, maintainability, cost, functionality, modularity, security, scalability, and user experience.
(2) If algorithms and performance are not important, why? Why learning? Performance and experience are associated. Real-time performance is the foundation of other products. performance is like currency. You use java to replace c, and the performance is reduced by three times for the advantages of other aspects, such as objectization, exception mechanism.
Sorting Problems
(1) Insert Sort)
Insert Sort Analysis:
The running time depends on input, such as the number of inputs and input sorting. The number of moves and comparisons can be used to measure the time complexity.
Maximum time (the worst case is a commitment, a guarantee): the input is in reverse order.
Comparison times: (n + 2) (n-1)/2
Number of moves: (n + 4) (n-1)/2
Average time (Expected Value of Time): n + input distribution, for example, even distribution.
Minimum Time (preferably): Enter the forward order.
Times: n-1
Number of moves: 0
Is insertion sorting fast? When n is very small, it is very fast. When n is very large, it will be very slow, usually n <= 8.
(2) Merge Sort)
Merge two sorted sequences into one. The Merge Sorting Algorithm depends on the merge operation.
Merge Sort Analysis:
In reality, when n> 30, Merge Sorting will beat insertion sorting.
The number of comparison operations is between and.
The number of assignments is.