Data structure and algorithm-introduction

Data structure
Data: All conformable sets that can be input into the computer and recognized and processed by the computer program are
divided into two categories:
1. Numerical data such as integers and real numbers

2. Non-numerical data of text, sound, graphics and images

Data element: It is the basic unit of data, which is usually considered and processed as a whole in computer programs

Data item: The smallest unit that constitutes a data element is called a data item, usually data elements have the same number and type of data items

Data structure: refers to a collection of data elements that have a certain relationship with each other

The logical structure of the data: refers to the logical relationship executed by the data element at the first level

Linear structure
1. Set: Data elements are "belonging to the same set", other than that, there is no relationship

2. Table structure: there is a one-to-one linear relationship between data elements

Non-linear structure
1. Tree structure: There is a one-to-many hierarchical relationship between data elements

2. Graph structure: There is a many-to-many arbitrary relationship between data elements

Abstract data type : a general term for a data model and a set of operations defined on the model
1. Data type: a general term for a set of values ​​and a set of operations defined on this set of values

2. Abstraction: extracting the essential characteristics of the problem and ignoring the non-essential difference
algorithm. It
is a description of the specific problem solving step, which is expressed as a finite sequence of instructions in the computer, and each instruction represents
the basic characteristics of one or more operating algorithms
Finiteness: The algorithm must end after executing finite steps, and each step can be completed in a finite time

Certainty: Each execution in the algorithm must have a precise meaning, there is no ambiguity (the same input must have the same output)

Feasibility: An algorithm is feasible, and the operation can be realized through the basics that have been implemented, and the operation can be executed a limited number of times

Input: An algorithm has zero or more inputs, which are taken from a specific set of objects

Output:
the characteristics of one or more output algorithms.
Requirements for algorithm design
1. Correctness: The algorithm can meet the needs of specific problems, that is, for any legal input, the algorithm will get the correct result

2. Robustness: the ability of the algorithm to resist illegal input, that is, the algorithm should be able to identify and deal with the wrong input, instead of generating wrong actions or being paralyzed

3. Comprehensibility: The algorithm is easy to understand and implement, and the algorithm is first for human reading and communication

4. Abstract classification: once the algorithm is created, someone must read, understand, use and modify

5. Efficiency: The efficiency of the algorithm includes
the description of the time efficiency and space efficiency .
Natural language:
easy to understand, but not rigorous, prone to ambiguity

Flow chart:
intuitive image, easy to understand, but troublesome to modify, not good at data organization structure

High-level programming language:
accurate and rigorous, but there are too many details to be considered and more cumbersome

Pseudo code:
Between natural language and computer language, it adopts the basic sentence format of a certain high-level language, excluding trivial grammatical details, compact format, easy to write, understand and modify, and it is also convenient to transfer
the relationship between algorithm and program to the program:
The program is the concrete realization of the algorithm in the computer system. The
algorithm is the abstraction and description of the essence of the calculation process in the program. It is the analysis and measurement of the calculation method in the abstract calculation model.

Post-statistics:
Collect statistics on the actual execution time or actual space occupied by the algorithm.
Pre-analysis and estimation:
According to a certain method, estimate the limit function of the algorithm’s execution time or space requirements

The method and strategy used by the algorithm,
the scale of the problem,
the language in which the
program is written , the quality of the machine code generated by the compiler
, the speed at which the machine executes instructions

Time complexity:
The number of repeated executions of the basic operation in the algorithm is a certain function f(n) of the problem size n, and the time metric of the algorithm is recorded as
T(n)=O(f(n)), which
means that the problem size n increases Large, the growth rate of the algorithm execution time is the same as the growth rate of f(n), which is called the progressive time complexity of the algorithm

Space complexity:
Similar to the time complexity of the algorithm, the space complexity is used as a measure of the virtual storage space of the algorithm.
Recorded as: S(n)=O(f(n))
n is the size of the problem

The storage space occupied by an algorithm:
the storage space occupied by the algorithm itself, the storage space occupied by
input instructions, constants, and variables . The storage space occupied by input\output data. The storage space
temporarily occupied during the operation of the algorithm

Guess you like

Origin blog.csdn.net/weixin_45743004/article/details/104183933