Mengxin's first blog: the basics of algorithms

Mengxin's first blog: the basics of algorithms

The first is the definition of an
algorithm. An algorithm is any well-defined calculation process that takes a certain value or set as input and produces a certain value or set of values ​​as output

Algorithms are of course inseparable from data structure:
data structure:
data structure is a way to store and organize data to facilitate access and modification

But no single data structure is effective for all purposes

It is more important to know the advantages and limitations of various data structures.

Loop Invariant
Loop invariants are predicates that are true before and after each execution of the loop body. It embodies the changing law of loop variables in loop programs.

Three properties must be proved:
1. Initialization: It is true before the first iteration of the loop.
2. Keep: If it is true before a certain iteration of the loop, it is still true.
3. Termination: When the loop terminates, the invariant provides us with a useful property that helps us prove that the algorithm is correct.

Guess you like

Origin blog.csdn.net/lspdd/article/details/113051916