You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To record their understanding algorithms, data structure, the process of simple comprehensive and detailed as possible, let the learning algorithm using flexible, refueling(ง •̀_•́)ง
56
+
57
+
## logarithmic
58
+
log<sub>10</sub>100 It's equivalent to saying, "how many tens do you multiply?" the answer is, of course, two
59
+
so log<sub>10</sub>100=2,The logarithmic operation is the inverse of the power operation
60
+
61
+
left|right
62
+
---|---
63
+
2<sup>3</sup> = 8 | log<sub>2</sub>8 = 3
64
+
2<sup>4</sup> = 16 | log<sub>2</sub>16 = 4
65
+
2<sup>5</sup> = 32 | log<sub>2</sub>32 = 5
66
+
67
+
If you don't, we won't wait for you
68
+
69
+
## The elapsed time
70
+
Take binary search for example, how much time can you save by using it? Simply look for the Numbers and if the list contains 100 Numbers, you need to guess 100 times.
71
+
In other words, the number of guesses is the same as the length of the list, which is called linear time, while binary search is different if the list contains 100 elements
72
+
It takes up to seven times, and if the list contains four billion digits, it should be guessed 32 times, while the running time of the subsearch is logarithmic time `O(log)`
73
+
74
+
## Big O notation
75
+
The big O notation is a special representation of how fast the algorithm can be. There's a diaosi. In fact, you often have to copy other people's code.
76
+
In this case, you know how fast these algorithms are
77
+
78
+
- The running time of the algorithm increases at different speeds
79
+
- For example, the difference between a simple find and a binary search
80
+
element|Easy to find|Binary search
81
+
---|---|---
82
+
100|100ms|7ms
83
+
10000|10s|14ms
84
+
1 000 000 000 |11day|30ms
85
+
-` O ` said hair is pointed out that how fast algorithms, such as list contains ` n ` element, a simple search need to check each element, so you need to perform ` n ` time operations
86
+
Using large ` O ` said ` O (n) to make this operation `, binary search need to perform log<sub>n</sub> using large ` O ` said to`O(log n)`
87
+
- Some common big O runtime
88
+
- O(log n) ,It's also called log time, and this algorithm includes binary algorithms
89
+
- O(n),Also known as linear time, this algorithm includes simple lookups.
90
+
- O(n * log n) Quick sort
91
+
- O(n<sub>2</sub>),Selection sort
92
+
- O(n!) Factorial time
93
+
- Here is the point
94
+
- The speed of the algorithm is not the time, but the growth of operands
95
+
- When we talk about the speed of the algorithm, what we're talking about is how fast will it run as the input increases
96
+
- The running time of the algorithm is expressed in large O notation
97
+
- O(log n) is faster than O (n), and the more elements that need to be searched, the more the former is faster than the latter
98
+
99
+
100
+
## A simple comparison of recursion and loops:
101
+
102
+
1. From a procedural point of view, the recursion manifests itself as calling itself, and the loop does not have this form.
103
+
2. Recursive proceed from the ultimate goal of the problem, and gradually to a complex problem into a simple problem, and simple question solution and complicated problem, at the same time the presence of the benchmark, can eventually get a problem, is the reverse. And the circulation is from the simple question, step by step forward development, finally get the question, is positive.
104
+
3. Any cycle can be represented by recursion, but it is necessary to use the loop to achieve recursion (except for one-way recursion and tail recursion), and the stack structure must be introduced to stack the stack.
105
+
4.In general, non-recursive efficiency is higher than recursion. And recursive function calls are expensive and recursive times are limited by stack size.
106
+
107
+
## Progressive learning
108
+
1. Fork 我的项目并提交你的 `idea`
109
+
2. Pull Request
110
+
3. Merge
111
+
112
+
## 纠错
113
+
If you find something wrong, you can initiate a [issue](https://github.com/PuShaoWei/designPatterns-go/issues)or [pull request](https://github.com/PuShaoWei/designPatterns-go/pulls),I will correct it in time
0 commit comments