Recently, we have been learning data structures. It is worthwhile. If you have a boss, the investment is successful.
At the beginning, I decided to buy a book "data structure (C Language)". I believe everyone has read it. It was written by teacher Yan Weimin. It was really amazing. Unfortunately, my C language is not good. The most important thing is to learn the design ideas in it. Haha.
Then I thought I was not addicted. I bought another book "data structure (C # language description)", which is Chen Guang (I don't know ). But you can. There is a video supporting teaching in it. I personally think it is good for me, but if I pass through the C language, I 'd like to check the data structure of teacher Yan Weimin. After all, this is a classic.
Today, I decided to record my learning history of the data structure in my blog. It is also the motivation for me to continue learning.
Today is an introduction ^ boring, all theoretical.
However, everything is hard at the beginning. Although I have already read the theory of binary tree, I have decided to implement the theory from now on ......
OK. Go ^
Why learning the Data Structure
In the early stages of computer development, people mainly used computers to solve numerical computing problems.
When we use computers to solve a specific problem, we generally need to take the following steps: first, we need to abstract an appropriate mathematical model from the specific problem,
Then design or select a Mathematical ModelAlgorithm,
Finally, compile the program for debugging and testing until the final answer is obtained. For example, the linear equations for solving the mathematical model of stress in the girder structure can be solved using iterative algorithms.
Since the computing objects involved at that time were simple integer, real-type, or boolean data, the main focus of programmers was to focus on programming techniques, rather than focusing on data structures.
With the expansion of the computer application field and the development of software and hardware, non-numerical computing is becoming more and more important. According to statistics, today's processing of non-numerical computing problems takes more than 90% of the machine time.
The data structure involved in such problems is more complex, and the relationship between data elements cannot be described by mathematical equations.
Therefore, the key to solving such problems is no longer the mathematical analysis and calculation methods, but the appropriate data structure should be designed to effectively solve the problem.
The following lists specific issues of this type.
What are data, data elements, data objects, and data structures?
Before systematically learning the knowledge about data structures, you must give a definite meaning to some basic concepts and terms. Data is the carrier of information. It can be recognized, stored, and processed by computers. It is the raw material for computer program processing, and applications process a variety of data.
In computer science, the so-called data is the object of computer processing. It can be numerical data or non-numerical data. Numeric data is an integer, real number, or plural number,
It is mainly used for engineering computation, scientific computation, and business processing. non-numerical data includes characters, texts, figures, images, and speech. Data element is the basic unit of data. Under different conditions, data elements are also called elements, nodes, vertices, and records.
For example, a record in the student information table in the student information retrieval system, a state of the Status tree in the eight queens problem, and a vertex in the teaching plan arrangement problem are all called a data element. Sometimes, a data element can be composed of several data items. For example, each data element in the student information table of the student information table in the student status management system is a student record.
It includes the student's student ID, name, gender, nationality, date of birth, score, and other data items. These data items can be divided into two types: a primary item,
For example, the gender and nationality of a student. These data items are the smallest units that cannot be separated during data processing. The other is a combination item,
For example, a student's score can be further divided into smaller items such as mathematics, physics, and chemistry. Generally, when solving practical application problems, each student record is accessed and processed as a basic unit. A data object or data element class is a collection of data elements of the same nature.
In a specific problem, data elements all share the same nature (element values are not necessarily equal) and belong to the same data object (Data Element class ),
A data element is an instance of the data element class. For example, in the traffic consultation system, all vertices are a Data Element class, and vertices A and B respectively represent a city,
Is the two instances in the data element class, whose data element values are A and B respectively. Data structure refers to a set of data elements with one or more relationships between each other. In any issue,
Data elements are not isolated, and there is one or another relationship between them. The relationship between these data elements is called structure.
According to the different characteristics of the relationship between data elements, there are usually four basic structures: (1) set structure. In the set structure, the relationship between data elements is "belong to the same set ". A set is a structure with extremely loose element relationships. (2) linear structure. There is a one-to-one relationship between the data elements of this structure. (3) tree structure. There is a one-to-many relationship between the data elements of this structure. (4) Graphical structure. There is a many-to-many relationship between the data elements of this structure. The graphic structure is also called a mesh structure.
Logical Structure of data: Set, linear set, tree structure, graph structure, or mesh structure
Data Storage Structure: sequential storage structure, chain storage structure, index storage method, hash storage method,
Data type.
The time complexity of an algorithm: A simple one can be understood as the efficiency of an algorithm, which is an important basis for measuring whether an algorithm will become a classic.