Basic concepts
The scope of data structure discussion, algorithm, data structure concept, algorithm and algorithm measurement
The scope of the algorithm discussion
Algorithms: Strategies for dealing with problems.
Data structure: The mathematical model of the problem (non-numerical calculation) and the representation and implementation of the operation on the computer. Numerical calculations use computational mathematics.
Data
Algorithms: Strategies for dealing with problems.
Data structure: A collection of structured elements.
Data
A collection of symbols that can be entered into the computer and processed by the computer.
Data elements
An individual in the data, the basic unit of the structure discussed.
Data item
The smallest unit discussed in the data structure. A data element is a collection of data items.
Logical Structure of data
Linear structure, tree structure, graph structure, set structure
Data structure form definition
Data structure = (d,s), D is a finite set of elements, and S is a finite set of relationships on D.
Storage structure of data
The image of the logical structure in memory.
Image methods for data elements
Bit string.
Image method of the relationship
Sequential Image: The successor relationship is represented by the adjacent (or a fixed interval) of the storage location. The entire storage structure contains only the information of the data element itself.
Chained Image: The storage location is indeterminate, with the attachment information (the pointer) representing the successor relationship.
Data type
is a collection of values and defines a collective name for a set of operations on this collection, or a data structure.
Abstract data type (ADT)
A mathematical model and a set of operations defined on this mathematical model.
Feature Data abstraction
Emphasis is placed on the nature of the entity, the functions that can be accomplished, and the interface with external users (the way the outside world uses it).
Data encapsulation
Separates entity external attributes from internal implementations and hides internal implementation details from external users.
Description method
(d,s,p), D is the data object, S is the set of relationships on D, and P is the basic operation of D.
Algorithms and algorithms for measuring algorithms
A finite long sequence of operations determined to solve a problem.
Characteristics
Poor: For any set of valid input values, after the execution of a poor step, it will be able to end. That is, each step can be completed within a limited time.
Certainty: There are definite rules in the algorithm for the actions to be performed in each case, so that the performer or reader of the algorithm can define its meaning and how it is executed. And under any conditions, the algorithm has only one execution path.
Feasibility: All the steps in the algorithm must be basic enough to be implemented with a finite number of basic operations.
There is input: the object that the algorithm processes can be entered during the execution of the algorithm, or it can be implied in the algorithm.
Have output: is a set of "input" has a definite relationship with the measure, is the algorithm after the information processing results, this determines the relationship is the function of the algorithm.
Correctness of algorithm design principles
First, the algorithm should meet the requirements given in a specific "specification" approach. , and then the understanding of whether the algorithm is "correct" has the following four levels, usually C as a criterion to measure the algorithm eligibility.
A. The program does not contain grammatical errors.
B. The program can produce results that meet the requirements for several sets of inputs.
C. For carefully selected, typical, harsh, and difficult to set the number of input data, can be reached to meet the requirements of the results.
D. The results of satisfying demand can be obtained for all legitimate inputs.
Readability
Easy to understand and debug.
Robustness
When the input data is illegal, the algorithm should be properly reflected or handled appropriately, rather than producing inexplicable results. Also, the way to handle an "error" should not be to interrupt the program, but rather to return a result that represents an error or an incorrect nature so that the upper call is processed.
High efficiency and low storage requirements
Efficiency refers to the execution time of the algorithm, and the storage requirements refer to the maximum amount of storage space required during execution, both of which are related to the problem size.
Measurement of algorithmic efficiency and the post-mortem statistics of the criteria
Cons: 1-programs must be executed. 2-Other factors mask the nature of the algorithm.
Pre-analysis of estimated time-related factors
1-Algorithm selection strategy
2-scale of the problem
3-writing the language of the program
4-quality of the compiled machine code
5-Speed of computer execution instructions
Algorithm execution time growth rate is the same as f (n) growth rate (n workload).
T (n) =o (f (n)), T (N) is the time-progressive complexity of the algorithm.
Algorithm = control Structure + original operation (operation of the intrinsic data type).
The execution time of the algorithm =σ the execution times of the original operation * The execution time of the original operation. The execution time of the algorithm is proportional to the sum of the execution times of the original operation.
The spatial complexity of the algorithm, S (n) =o (g (n)), as the problem size increases, the algorithm needs to store the same growth rate as g (n).
The space occupied by the input data.
The space occupied by the program itself.
The space occupied by the auxiliary variable.
This article is from the Java Technology Stack notes blog, so be sure to keep this source http://stroll.blog.51cto.com/11038467/1866234
Data structure and algorithm (i) Basic concepts