Class notes: basic concepts of algorithms

An algorithm is a description of the steps to solve a particular problem and is a finite sequence of instructions.
The characteristics of the algorithm:
1. Poorness: An algorithm must be able to end after executing a finite step, and each step can be completed in a finite time.
2. Determinism: Each instruction in the algorithm must have an exact meaning, not ambiguous.
3. Feasibility: The operations described in the algorithm can be implemented by the basic operations that have been implemented a limited number of times.
The algorithm has zero or more inputs (that is, the algorithm can have no input), but the algorithm must have an output, and there is a certain relationship between the output and the input.
Algorithm description method: natural language, flow chart, programming language, pseudo-code.
Algorithm analysis:
The time required for the algorithm to run is called time complexity.
The auxiliary space required for the operation of the algorithm is called space complexity.
Post hoc statistical method-program running test: inserting time function time () in certain parts of the algorithm to determine the time it takes the algorithm to complete a certain function.
The basic sentence execution times are used to measure the time complexity of the algorithm.
The time complexity is only related to the sentences (basic sentences) with the most frequent sentences in the algorithm, and the time of other sentences can be ignored.
The space complexity of the algorithm refers to the amount of auxiliary space required during the execution of the algorithm. The auxiliary space is the storage space temporarily opened by the algorithm except the space occupied by the algorithm itself and the input and output data.

Published 48 original articles · Like 25 · Visit 2453

Guess you like

Origin blog.csdn.net/qq_43628959/article/details/100937437