1.1 The basic concept of data structure (logical structure and physical structure)

1. Basic Concepts and Terminology

Use this table to help understand the basic concepts
image.png

1.1 Data

Data is the carrier of information, which is a collection of numbers, characters and all symbols that can be input into the computer and recognized and processed by the program that describe the attributes of objective things.

For example: Zhang San's math score is 54, and 54 is the student's score data

1.2. Data Elements

A data element is the basic unit of data and is usually considered and processed as a whole. A data element can be composed of several data items, and a data item is an indivisible smallest unit that constitutes a data element.

For example: Zhang San's grade sheet is a data element, which consists of student number, name, language, mathematics, C language and other data items

1.3. Data Objects

A data object is a collection of data elements with identical values, a subset of data.

For example: this entire score sheet is a data object, which consists of the score sheets (data elements) of each classmate

1.4. Data Types

A data type is a collection of values ​​and an umbrella term that defines a set of operations on this collection.

Atomic Type: A data type whose value is indivisible. Such as bool and int types.
Structure type: A data type whose value can be further decomposed into several components (components).
Abstract Data Types: Abstract data organization and operations related to it.

1.5. Data Structures

A data structure is a collection of data elements that have one or more specific relationships to each other.

In simple terms, the data is stored on the disk, but when the program is run, the data will be loaded into the memory. The data structure research is the storage of the data in the memory.

2. Three elements of data structure

The logical structure is friendly to people, referring to the relationship between data, which is easy for people to understand and is abstract. The
storage structure is friendly to the computer. Designation is the representation of data in memory, and it is concrete.

2.1 Logical structure of data

The logical structure refers to the logical relationship between data elements, that is, the data is described from the logical relationship.

The logical structure includes:

Set structure (no relationship): There is no other relationship between the data elements in the structure except "belonging to the same set".
Linear structure (one-to-one): There is only a one-to-one relationship between data elements in the structure. Except for the first element, all elements have a unique predecessor; except for the last element, all elements have a unique successor.
Tree structure (one-to-many): There is a one-to-many relationship between data elements in the structure.
Graph structure (many-to-many): There is a many-to-many relationship between data elements.

image.png

2.2 Data storage structure (physical structure)

The storage structure refers to the representation (also known as the image) of the data structure in the computer, also known as the physical structure.

Storage structures include:

Sequential storage: logically adjacent elements are stored in storage units that are also physically adjacent, and the relationship between elements is reflected by the adjacency relationship of storage units.
Chained storage: Logically adjacent elements may not be adjacent in physical position, and the logical relationship between elements is represented by a pointer indicating the storage address of the element.
Index storage: while storing element information, an additional index table is also established. Each item in the index table is called an index item. The general form of an index item is (keyword, address)
hash storage: directly according to the keyword of the element Calculate the storage address of the element, also known as Hash storage.

Index storage and hash storage are further implementations of the first two storages. The bottom layer is sequential storage and chained storage ​Comparison of the advantages and disadvantages of
sequential Fragmentation: unused, but occupied memory space

image.png

For example: apply for an int [10], but only store 8 integer data, there are 8 bytes of memory fragmentation

2.3 Operation of data

Operations performed on data include the definition and implementation of operations. The definition of the operation is for the logical structure, and the function of the operation is pointed out; the realization of the operation is for the storage structure, and the specific operation steps of the operation are pointed out.

Guess you like

Origin blog.csdn.net/m0_50991874/article/details/123292625