First, before introducing the data structure, we should understand the function of data structure. With the expansion of computer application and the development of hardware and software, the problem of non-numerical computing is becoming more and more important, which requires the program designer to design a suitable data structure. The research of data structure is mainly about various logical structure, storage structure and various operations.
Ii. basic terminology of data structure
1. Data
Data is the carrier of information, is a symbol describing objective things, can be computer recognition, storage and processing. In computer science, data can be numeric data or non-numeric data. Numeric data is a number of integers, real numbers, or complex numbers, and non-numeric data includes characters, text, graphics, and speech. The data must have two prerequisites:
① can be entered into the computer
② can be processed by computer programs
2. Data elements
Data element is the basic unit of data, under different conditions, the data element can also be called element, record and so on. In a specific problem, the data elements have the same nature, belonging to the same data object, such as: cats, rabbits, etc. are called animal data elements.
3. Data item
So-called data items are the smallest unit of data, and several data items can form a data element. For example, in the student management system, each student information is a data element, and the student name, gender, school number, etc. are called data items. Although data items are the smallest unit of data, data elements are the focus of research by default when studying data structures.
4. Data Objects
A data object is a elements of the same nature and a subset of the data. The so-called nature of the same refers to the data elements have the same number and type of data items, such as student table each student information has a name, gender, school number and other data items, these student information together constitute a student information table. Since the data object is a subset of the data, in order to not cause confusion in the actual application, we all use the data object abbreviation data.
5. Data structure
Structure: Any thing is more or less there is a certain connection, of course, different data elements are not independent, there is one or more relationships, we call these relationships structure.
Data structure: According to the concept of the above structure, the data structure is a collection of one or more relationships between each other.
Third, the logical structure and physical structure of data
Logical Structure
The relationship between data elements is often different, according to different data relations, can be divided into 4 types of basic structure
1. Set structure
There is no other relationship between the data elements of the collection structure, just the same as within a set, and each data element is equal.
2. Linear structure
In this structure, there is a one-to-many relationship between the data elements, which is a certain linear order.
3. Tree-like structure
There is a one-to-many relationship between data elements in a tree structure, for example, there are two classes in a grade, each class is shift by a class teacher, each class is grouped according to the dormitory, each dorm has a dorm length, and there are other dorm members in each dorm.
4. Graphic structure
In the graphic structure, there are many-to-many relationships between data elements, such as China's road transport network, each node has a certain connection with a number of nodes.
Physical Structure
The so-called physical structure refers to the representation of a data structure in a computer (also known as an image), which is the form of its storage. The storage format is divided into the following types of storage structures:
1. Sequential storage structure
A sequential storage structure is one of the most basic storage representations for storing logically contiguous elements in a contiguous storage unit in a physical location, as in the C language.
2. Chain-type storage structure
Chained storage means that logically adjacent elements are not required to be stored in a physical location adjacent to each other, and the logical relationship between elements is represented by a pointer field attached, such as a linked list in the C language.
Iv. manipulation of data structures
Different data structures have different operation sets, but the following operations are essential:
Generation of ① structures
Destruction of ② structures
③ finding a data element that satisfies a condition in a structure
④ inserting new data elements into a structure
⑤ Delete data elements that already exist in the structure
⑥ traversal of all data elements in a structure