How computers run - seven key points to becoming good friends with algorithms (5)

1. Algorithm is translated into Chinese as "algorithm", and the definitions are:
(1) A set of finite rules that are clearly defined and used to solve problems according to limited steps. For example, under a given accuracy, the calculation steps for solving sin x are recorded in detail.
(2) Express the steps to solve the problem in words or pictures.
2. "Sentinel" refers to a type of data containing a special value that can be used to identify the end of data. The end of a string is represented by 0, and the end of a linked list is represented by -1. Special data like this is a sentinel.
3. Point 1: The steps to solve the problem in the algorithm are clear and limited.
4. Point 2: Computers do not rely on intuition but solve problems mechanically.
5. Point 3: Understand and apply typical algorithms.
6. Point 4: Take advantage of the computer’s processing speed.
7. Point 5: Use programming skills to improve program execution speed.
8: Point 6: Find the patterns between numbers.
9. Point 7: Think about the algorithm on paper first.
10. The sieve of Eratosthenes is an algorithm used to screen out all prime numbers within a certain range. The basic idea is to divide the number to be determined by all positive integers smaller than it.
11. Sentinel’s understanding: Suppose you are standing 100 meters away from the edge of the cliff. There is an object placed every meter on the ground, and you need to find the apple. If you have to check whether you have reached the edge of the cliff every meter you advance, this will take a lot of time. If you set up a sentry, place an apple 101 meters away from the edge of the cliff. This apple will be the sentinel. In this way, you only need to check whether the item is an apple every meter forward. When you get the apple and you have reached the edge of the cliff, it means that the apple is a sentinel and you have not found the apple you are really looking for.
Insert image description here
Insert image description here

Guess you like

Origin blog.csdn.net/weixin_46504000/article/details/131745307