Abstract data type of data structure

Introduction:
In C language, according to different values, data types can be divided into two categories:

  • Atomic type: It
    is a basic type that cannot be decomposed, including integer, real, character, etc.
  • Structure type: It is composed of several types and can be decomposed. For example, an integer array is composed of several integer data.
    For example, the variable declaration int a, b in C language means that the value range of int cannot be exceeded when assigning values ​​to variables a and b, and the operations between variables a and b can only be allowed by the int type Operation.

Because different computers have different hardware systems, this requires that the programming language is finally converted into a low-level language through a compiler or interpreter, such as assembly language or even through machine language data types. But in fact, no matter what computer the final program runs on, a high-level language programmer’s purpose is to achieve the calculation of two integer numbers, such as a+b, ab, a×b, and a/b. I don't care about how integers are represented inside the computer, and I don't want to know how many switching operations the CPU performs to achieve 1+2. How these operations are implemented is not important to high-level language developers. So we will consider that no matter what computer or computer language, most will face operations such as integer arithmetic, real number arithmetic, and character arithmetic. We can consider abstracting them all.

Abstraction refers to extracting the universal essence of things. It extracts the characteristics of the problem and ignores the non-essential details. It is a generalization of specific things. Abstraction is a way of thinking about problems. It hides complicated details and only retains the information necessary to achieve the goal.

Definition: When
we abstract the existing data types, we have abstract data types.

Abstract Data Type (ADT) : Refers to a mathematical model and a set of operations defined on the model. The definition of an abstract data type only depends on its set of logical characteristics, and has nothing to do with how it is represented and implemented inside the computer.

For example, every computer, whether it is a mainframe, a minicomputer, a PC, a tablet, a PDA, or even a smart phone, has an "integer" type and requires operations between integers. Then the integer type is actually an abstract data type, even though it is in The above-mentioned implementation methods may be different in different computers, but due to the same mathematical properties of their definitions, in the eyes of computer programmers, they are all the same. Therefore, the meaning of "abstraction" lies in the mathematical abstraction of data types.

Moreover, abstract data types not only refer to data types that have been defined and implemented, but also data types defined by computer programmers when designing software programs. For example, when we write software systems on computer graphics or maps, we often use them. To the coordinates. In other words, there are always x and y appearing in pairs, and z appearing in 3D systems. Since these three integer numbers always appear together, we define an abstract data type called point, which has x, y, z are three integer variables, so that we can easily manipulate a point data variable to know the coordinates of this point.

In fact, the abstract data type embodies the characteristics of problem decomposition, abstraction and information hiding in program design. The abstract data type decomposes the problems in real life into multiple small-scale and easy-to-handle problems, and then establishes a data model that can be processed by a computer, and regards the implementation details of each functional module as an independent unit, so as to realize the concrete realization The process is hidden.

In order to facilitate the standardized description of abstract data types, a standard format for describing abstract data types is given:

ADT 
    抽象数据类型名
Data
    数据元素之间逻辑关系的定义
Operation
    操作1
        初始条件
        操作结果描述
    操作2
        ......
    操作n
        ......
endADT

Guess you like

Origin blog.csdn.net/xun08042/article/details/112845938