Chapter 1 Application of algorithms in computers
Chapter 2 Introduction to Algorithms
Insert sort
Algorithm Design (divide and conquer, divide and conquer Analysis)
Chapter 3 function growth (progressive notation, time complexity)
Chapter 4 Recursion
Replacement Method
Recursive tree method
Primary method (proof of primary theorem)
The first chapter is an overview.
The second chapter uses an insert sort as an example to describe what an algorithm is. This book describes the structure of each algorithm, describes how to analyze the algorithm performance, and introduces the Splitting Algorithm and analysis.
Chapter 3 mathematical knowledge
Chapter 4 describes recursion and recursive time complexity analysis methods.
Certificate -------------------------------------------------------------------------------------------------------------------------------------------------
Chapter 1
Having a solid base of algorithmic knowledge and technique is one
Characteristic that separates the truly skilled programmers from the novices.
With modern computing technology, you can accomplish some tasks without knowing
Much About algorithms, but with a good background in algorithms, you can do
Much, much more.
Whether you have a solid algorithm knowledge and technical foundation is an important feature of distinguishing outstanding programmers from new users. With the use of modern computing technology, there is no need for a lot of algorithm knowledge or tasks to complete. However, with a good algorithm Foundation and background, much more can be done, you can complete tasks that cannot be completed by others.
Certificate -------------------------------------------------------------------------------------------------------------------------------------------------
Chapter 2
Insert sorting, the simplest algorithm previously written.
Conventions in this book: pseudocode form, proof of correctness (initialization, persistence of loops without changing pattern, termination)
Time Complexity Analysis: Worst Case and average case analysis, increasing by an order of magnitude
Divide and conquer: Merge and sort, previously written, and posted again:
1) recursively merge the elements of array a from subscript P to R:
Merge-sort (A,P,R)
1If P<R2Then QZookeeper ⌊(P+R)/2 bytes 3 merge-sort (A,P,Q) 4 merge-sort (A,Q+ 1,R) 5 Merge (A,P,Q,R)
2) key code: merge two sequences
Merge (A,P,Q,R) 1N
1
← q - p + 1 2 n
2
← r - q 3 create arrays L[1 ‥ n
1
+ 1] and R[1 ‥ n
2
+ 1] 4 for i ← 1 to n
1
5 do L[i] ← A[p + i - 1] 6 for j ← 1 to n
2
7 do R[j] ← A[q + j] 8 L[n1 + 1] ← ∞ 9 R[n2 + 1] ← ∞10 i ← 111 j ← 112 for k ← p to r13 do if L[i] ≤ R[j]14 then A[k] ← L[i]15 i ← i + 116 else A[k] ← R[j]17 j ← j + 1
Why do I post it again? Note:
Recursion and sub-governance;
Tips for the Sentinel element: compared with the previous use of sentinel elements, it is much easier to merge two rows of 12 to 17 with sequences.
Use the recursive tree to analyze the time complexity of merging and sorting: it is very important. Please read the notes you made during reading.
Exercise:
2.3-2 If not applicable, rewrite and merge two sequential processes
A lot of trouble. Refer to the previously written Merge Sorting.
2.3-5 explains why the time complexity of binary search is log (N). binary search can be iterative or recursive.
Binary Search, classic problem
2.3-6 fold semi-insert sorting: during insertion sorting, the binary search method is used for insertion to increase the time complexity to nlog (n)
2.3-7 design an nlog (n) algorithm to determine whether there are two numbers in the Set S and two numbers equal to a certain number x
Google's pen questions, discussed earlier, sorting, transformation, and transformation.
Questions:
2-1 You can use insert sort for small arrays in the merged sorting process. For more information about the time complexity, see
2-4 reverse order: An Important Problem
The Merge Sorting is slightly improved to count the number of Reverse Order pairs.
Certificate --------------------------------------------------------------------------------------------------------------------------------------------------
Chapter 3 function growth
Omitted
Certificate ------------------------------------------------------------------------------------------------------------------------------------------------
Chapter 4 Recursion
Substitution Method: Form of speculative solution + proof of mathematical induction
Recursive tree method: Important! The time complexity of the divide and conquer algorithm is particularly obvious in the recursive tree. For more information, see the book.
Main method: As mentioned earlier, remember the formula.
Certificate -------------------------------------------------------------------------------------------------------------------------------------------------
Summary:
It can only be an introduction