Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the data structure?

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what is the data structure". The content of the explanation is simple and clear, and it is easy to learn and understand. now please follow the editor's train of thought to study and learn "what is the data structure"?

Preface

Data structure, to put it simply, is to study the way data is stored. The storage of data in computer storage space is by no means random. Study a good way to store data, which is also the core content of the data structure.

Data structure

The data structure consists of the following storage structures:

1. Linear tables, which can also be subdivided into sequential tables, linked lists, stacks, and queues

The data stored in the linear table structure can often be arranged in turn, just like a group of people holding hands, with only one person holding hands with each other in front and behind. Data with this "one-to-one" relationship can be stored using linear tables.

For example, when you store data such as {1Pert 2rec 3je 4je 5}, the elements are arranged in turn, and each element is preceded and followed by only one and only one element (except the first and last elements), so you can use linear table storage.

Linear table is not a specific storage structure, it contains sequential storage structure and linked storage structure, which is the general name of sequential list and linked list.

To put it simply, a sequence table is a commonly used array with a different name. For example, a sequence table is used to store {1magentin. 5pm, 7je. 9}, as shown in the following figure:

Note: because the underlying implementation of the sequential table structure relies on arrays, for beginners, sequential tables can be completely equivalent to arrays, but this is not the case. Data structure is a subject that studies the way of data storage, which includes all kinds of storage structures, while array is only the basic data type in various programming languages and does not belong to the category of data structure.

When the linked list stores data, it is on demand, so the storage location of the data is separate from each other, in other words, the storage location of the data is random.

The linked list adds a pointer to each data block to establish a "sequential" relationship for each data block. The pointer of each data block points to the next data block (the pointer of the last data block points to NULL). The seemingly unrelated data blocks establish a "sequential" relationship, which forms a linked list, as shown in the following figure:

Stacks and queues belong to linear tables and are special linear tables because they have clear requirements for the entry and exit of elements in the linear table.

The elements in the stack can only go in and out from one end of the linear table (sealed at the other end), and follow the principle of "first in and then out", that is, the elements of the advanced stack come out of the stack.

Like a barrel, the stack contains three elements, A, B and C. from the state in the stack, you can see that An is the most advanced stack, then B enters the stack, and finally C enters the stack. According to the principle of "first in and then out", the order of the three elements should be: C first out of the stack, then B out of the stack, and finally An out of the stack.

two。 Tree structure, including ordinary tree, binary tree, cue binary tree, etc.

The tree storage structure is suitable for storing data with an one-to-many relationship. As shown below:

The root node is unique and there cannot be multiple root nodes. The tree in the data structure has only one root node.

3. Graph storage structure

The graph storage structure is suitable for storing data with many-to-many relationships. As shown below:

Thank you for your reading, the above is the content of "what is the data structure", after the study of this article, I believe you have a deeper understanding of what is the data structure, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 237

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report