Using arrays to reduce the time complexity of a program in PHPOften developers write programs, often in the design or well-conceived operational logic, directly translated in the programming language. The program can be compiled smoothly, it is very gratifying. If the running time of the program is acceptable, you will be immersed in the sense of accomplishment o
About the author
Wang Dandan, a software engineer at IBM China Systems and Technology Center, has been working on WEB system design and development since 2006, and has five years of experience in designing and developing PHP applications.
Often developers write programs, often in the design or well-conceived operational logic, directly translated in the programming language. The program can be compiled smoothly, it is very gratifying. If the running time
Time Complexity: if the scale of a problem is N, the time required for an algorithm to solve the problem is T (N). It is a function of N, T (n) is called the "time complexity" of this algorithm ". Gradual time
the definition of time complexity in general, the number of times the basic operations in the algorithm are repeatedly executed is a function of the problem scale N, expressed in T (N), if there is an auxiliary function f (n), So that when n is approaching infinity, the limit value of T (n)/f (n) is a constant that is not equal to zero, then it is said that f (n) is the same order of magnitude function
;
The accumulation of the second method:
In ①, int sun = 0 is executed once.
② Int I = 0 is executed once, I
③ Sum = sum + I + J is executed 50 times
Therefore, the total number of times is 1 + 1 + 2*50 + 50 = 152;
Obviously, if the execution time of each command is the same, does the accumulation of method 2 save a lot of time than that of method 1.
Here we introduce the concept of
I. Concept: Time Complexity is the one that is most affected by the change in the total number of operands in the expression (without coefficients) For example: General total number of operations the expression is similar to this: a*2^n+b*n^3+c*n^2+d* N*LG (n) +e*n+f A. When =0, the time complexity is O (2^n); a=
This article is reproduced, will modify the place that you feel wrong;One: ConceptUnder normal circumstances, the number of iterations of the basic operation of the algorithm is a function of the problem size n, denoted by T (n), if there is an auxiliary function f (n), so that when n approaches infinity, the limit value of T (n)/f (n) is not equal to zero constant, then f (n) is the same order of magnitude function of t As T (n) =o (f (n)), called O (f (n)) is the progressive
Definition: If the scale of a problem is n, the time required for an algorithm to solve this problem is T (n), which is a function of n (n) called the "time complexity" of the algorithm.When the input n gradually increases, the limit of time complexity is called the asymptot
In general, the number of repeated executions of the basic operation in an algorithm is a function with the problem scale N.F (N)Algorithm Time MeasurementT (n) = O (f (n ))He indicates the algorithm execution time growth andF (N)With the same growth rate.Progressive time complexity(Asymptotic
What is the complexity of time?As a slag in the learning path, was baffled by a time complexity problem, then I thought about what is the time complexity. Although learning the algorithm in school courses, but carefully think abou
Time complexity is a major factor used by developers to measure the merits of an application's algorithms. Objectively speaking, the advantages and disadvantages of the algorithm in addition to the complexity of time, but also closely related to spatial complexity. With the
The specific steps to solve the time complexity of the algorithm are: ⑴ find out the basic statements in the algorithm; The most frequently executed statement in the algorithm is the basic statement, usually the loop body of the most inner loop. ⑵ the order of the number of executions of the base statement;Simply calculate the order of magnitude of the base statement execution, which means that all coeff
Time Complexity time limit: +Ms | Memory Limit:65535KB Difficulty:3
Describe
in the ACM inside, computational complexity is a very important thing, and common complexity formats are three kinds:
O (N)
O (LG (N))
Algorithm time complexity calculation definition:In general, the time complexity of the algorithm is the number of times the basic operation of the algorithm executes repeatedly.Calculation method:First, we find out the basic operation of the algorithm, then calculate their execution times, ignoring the constants, the
With the continuous improvement of hardware configuration, the space complexity of the algorithm is much looser for small and medium-sized applications. However, in today's Web2.0 era, there is a higher requirement for the time complexity of applications.
What is the time complexi
Algorithm analysisThe same problem can be solved by different algorithms, and the quality of an algorithm will affect the efficiency of the algorithm and even the program. The purpose of algorithm analysis is to select the appropriate algorithm and improve the algorithm. The evaluation of an algorithm is mainly considered from time complexity and space complexity
I. Definition
(1) If the scale of a problem is n, the time required to solve an algorithm of this problem is T (n), and it is a function t (n) of n that is called the "time complexity" of this algorithm. We often use big O notation to denote time complexity, called Big O no
As the hardware configuration of devices continues to improve
Program For example
Algorithm The requirements for space complexity are also quite relaxed. However, in today's web era, the time complexity of applications has higher requirements.
What is the time complexity
An example of time complexity calculationThe levels that represent the complexity of time are:O (1): Constant time order O (n): linear time OrderO (㏒N): Logarithmic time order O (N㏒N):
From: http://blog.csdn.net/flyyyri/article/details/5154618
1. algorithm complexity is divided into time complexity and space complexity.Purpose: time complexity refers to the duration of Algorithm Execution, while space complexity
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.