In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
How to evaluate the quality of an algorithm? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.
First of all, the algorithm must be correct
Secondly, good algorithms should be friendly, easy for people to understand and communicate, and machine executable.
This algorithm also needs to be robust enough, that is, when the input data is illegal or unreasonable, it can properly make a correct response or deal with it accordingly.
Finally, it must also have high efficiency and low storage requirements.
That is, the so-called time complexity and space complexity
1. Time complexity
Definition: in computer science, the time complexity of an algorithm is a function, and it quantitatively describes the running time of the algorithm. Theoretically speaking, the time it takes for an algorithm to execute can only be known if you put your program on the machine. However, we have a set of analysis methods of time complexity. The time taken by an algorithm is directly proportional to the number of sentences executed in it. The number of times the basic operation in the algorithm is executed is the time complexity of the algorithm.
two。 Why is time complexity measured not by time but by the number of times the basic statement is run?
The execution time of the algorithm depends on the specific software and hardware environment, so the time complexity of the algorithm can not be measured by the execution time, but by the order of magnitude of the number of basic statements.
3. O Asymptotic representation of time complexity (Big O notation)
Is a mathematical symbol used to describe the progressive behavior of a function.
Derivation of large O-order method:
Calculate the order of magnitude of the execution times of the basic statement;
You only need to calculate the order of magnitude of the basic statement execution times, which means that as long as you ensure that the highest power in the function of the basic statement execution times is correct, you can ignore all the coefficients of the lower power and the highest power. This simplifies algorithm analysis and focuses attention on the most important point: the growth rate.
If the algorithm contains nested loops, the basic statement is usually the innermost loop body, and if the algorithm contains parallel loops, the time complexity of the juxtaposed loops is added. For example:
For (iTunes 1; I
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.