Download the small turtle's algorithm and data structure video from the Internet, and intend to finish the series with the video. To achieve a preliminary understanding of the algorithm
An algorithm is a description of the solution steps for a particular problem, represented as a finite sequence of instructions in the computer, and each of the bars represents one or more operations. (In short, the algorithm is the skill and the way to do all kinds of things)
Remember the primary school, the teacher for everyone told the German big data of Gauss's story, content is Gauss's teacher asked the class from 1 to 100 to find out and. When everyone is immersed in the bitter calculation, Gauss takes a short time to get the result. Gauss uses the method is 1+100,2+99,3+98 ... all get 101, then from 1 to 100 and 50 to 101. 50x101=5050 This is far more than from 1 to 100 faster, this is the efficiency of the algorithm. The following program demonstrates:
1 Private Static intSUANFA1 (intN) {2 intSum=0;3 for(inti = 1; I <=n; i++) {4sum+=i;5 }6 returnsum;7 }8 9 Private Static intSUANFA2 (intN) {Ten intSum=0; Onesum= (1+n) * (N/2); A returnsum; -}
View Code
The algorithm of the Small turtle Learning Algorithm first experience (1)