Home  >  Article  >  Backend Development  >  php algorithm problem

php algorithm problem

WBOY
WBOYOriginal
2016-09-23 11:31:041005browse

php algorithm problemHow to tell which one is better

Reply content:

php algorithm problemHow to tell which one is better

In fact, both are O(n), which is consistent in terms of time complexity.
If I have to say which one is the best, it must be A2, because the time complexity increases with the increase of scale n, and the increment is the smallest.

The quality of the algorithm is mainly reflected when the scale is large. You will find how bad the algorithm is. When the scale is small, the current computer power can be completed instantly. Only when the scale is large can the algorithm be shown to be good. Bad, the scale is at least 10,000, that is, n=10,000. The algorithm complexity at this time is of practical significance. So you just look at the big n, whichever one is faster will be better

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn