Read data structure (C) (1)

Source: Internet
Author: User

Today, I began to carefully read the data structure of the Tsinghua edition, edited by Yan Weimin and Wu Weimin. Maybe you will wonder why I chose the data structure book described in C language. Doesn't the current data structure be described in object-oriented languages? In fact, this book is not selected by me, but a reference book specified by the machine trial I attended. However, I have my own opinions on the language used in this book. It is obviously inconvenient to describe in C language, but in a world where Oo is used to describe data structures, the idea of using C to view data structures is drawn from Oo, maybe you can better understand the nature of the data structure.

Now, let's get down to the truth. In the first article today, I will discuss the basic concepts of data structures. The author summarized the general steps for solving computer problems at the beginning: "First, we need to abstract an appropriate mathematical model from a specific problem, then design an algorithm for solving this mathematical model, and finally compile a program, perform testing and debugging until the final answer is obtained." I will further summarize it, that is, abstract mathematical models-design algorithms-programming. This idea is very important. Except for some very simple problems, all programming should follow these three basic steps. The common mistake we make when writing a program is to ignore the first or second step, or, even worse, the first two.

The concept of data structure is introduced in the process of designing a mathematical model. The definition given by the author in this book is: "In simple terms, data structure is a discipline that studies the computer operation objects and their relationships and operations in non-numerical computing programming problems." Chinese textbooks are often hard to understand for the sake of language rigor. Please note the following keywords in this sentence: 1)Non-Numerical CalculationThis shows the application scope of the data structure discipline. If you want to solve a linear equations, it is difficult to find a suitable data structure directly. 2)Operation object, That is, the data in the problem and its representation form; 3)Link(4) Relationship between data)OperationThat is, data operations.

Write the above definition using a formula, that is

Data_structure = (D, S)

D is the finite set of data elements, and s is the finite set of relations on D. Therefore, when designing a data structure, the first task is to find the data to be operated, and the second is to mine the relationship between data. After the two steps are completed, the logical structure of the data is settled. The data structures are as follows:

  1. Set, Which is consistent with the Set Concept in mathematics;
  2. Linear StructureThat is, the one-to-one relationship between data elements;
  3. Tree StructureThat is, the one-to-multiple relationship between data elements;
  4. Graph StructureOrMesh StructureThat is, the many-to-many relationship between data elements.

However, only the logical structure is not enough. To run a program, the logical structure of the data must be expressed in the computer, that is, the physical structure should be designed. Most advanced languages have good support for the physical structure of data, such as various data types. When explaining the concept of data types, the author said: "The purpose of introducing data types is to use hardware as a means to explain the meaning of information in computer memory, for users who use data types, the information is concealed, and all the details that users do not need to know are encapsulated in the type." This generalization is very incisive. It can be seen that OOP will only encapsulate and conceal information at a higher level.

To further expand data types, the author introduces the concept of abstract data types. ABSTRACT Data Type (ADT) refers to a mathematical model and a group of operations defined on the model. After the introduction of abstract data types, the logical structure is more independent, so that programmers can focus more on the design of the logical structure. The abstract data type is represented by a formula, that is

(D, S, P)

D is the data object, S is the relational set on D, and P is the basic operation set on D. If the computer must follow a general model for solving the problem, the above formula gives the answer.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.