Data Structures and Algorithms (Introduction)

basic concept

Data :

The numbers, characters and all kinds of symbols that are input into the computer and can be received by the computer are collectively referred to to describe the objective things. It is a symbolic representation of information and is the processing object of a computer program. Not only include integer, real and other numerical types, but also include characters, sound, image, video, etc.

The data has two conditions:

1. Can be entered into the computer

2. Can be processed by a computer program

Data element:

A set of data representing a set of things is called an array element, which is a basic unit of data and has a certain meaning (atomicity, indivisible, or can be composed of multiple data items), and is usually processed as a whole in a computer , also known as records.

For example, in human beings, people are the data elements. In school, students are data elements

data item:

It is the smallest indivisible sign unit with independent meaning in the data element (an integer, a character is a person's ears, nose, eyes and mouth, a student's name, age, student number)

A data item is the smallest unit. But when we really discuss the problem, the data element is the focus of the data model in the data structure. (When watching a movie, we discuss the "data elements" of the movie's characters, not the character's name or age "data items" to study).

Data object:

A collection of data elements with the same properties is a subset of data.

  The same nature means that the data elements have the same number and type of data items, for example, people have the same data items such as name, birthday, gender, etc.

  Students have the same data items as student numbers, classes, etc., then students and people can be called data objects.

 

data structure

A data structure is the relationship that exists between data elements . A data structure consists of N (N>=0) data elements. The simple understanding is the relationship. Molecular structure, for example, is the arrangement of atoms that make up a molecule. Strictly speaking, structure refers to the way that various components are matched and arranged with each other. In the display world, different data elements are not independent, but there are specific relationships, which we call structure.

Data structure: is a collection of data elements that have one or more specific relationships with each other . A data element is a collection of data that is inherently related. One or more specific relationships that exist between data elements, that is, how the data is organized.

The logical relationship between data elements is represented by a collection of data elements and several relationships defined on this collection, referred to as a data structure.
 

Data structure is divided into logical structure and storage structure

The difference between linear structure and nonlinear structure of data structure

Logical structure : The interrelationships between data elements in a data object.

There are four logical structures:

1. Collection structure

The data elements in the collection structure do not have any other relationship between them except that they belong to the same collection. Each data element is "equal", and their common attributes belong to the same set. The set relationship of the data structure is similar to the set in mathematics.

       

2. Linear structure

The relationship between data elements in a linear structure is one-to-one. There is a linear relationship between data elements.

Linear structures have a unique first element (the first element)

Linear structures have a unique tail element (the last element)

Except for the first element, all elements have a unique "predecessor"

All elements except the tail element have a unique "successor"

There is a "one-to-one" relationship between data elements

For example: array A1,A2,A3,........An, the first element is A1, and the last element is An

 

3. Tree structure

Tree structure: There is a one-to-many hierarchical relationship between the data elements in the tree structure. Such as: binary tree. 

The data elements in the tree are usually called nodes. The hierarchical relationship of the tree structure means that the root (topmost) node has no predecessor node (parent node), and other nodes except the root have one and only one parent node. . All nodes may have zero or more successor nodes (child nodes)

4. Graphical structure

Graph structure: data elements are in a many-to-many relationship

Each data element may have multiple predecessors and successors.

The logical structure is for specific problems, in order to solve a certain problem, on the basis of understanding the problem, select a suitable data structure to represent the logical relationship between data elements.

Physical structure (storage structure)

Storage structure: refers to the storage form of the logical structure of data in the computer.

Data is a collection of data elements. According to the definition of physical structure, it is actually how to store data elements in the computer's memory. Mainly for memory, the data organization of external storage such as hard disk, floppy disk, optical disk, etc. is usually described by file structure.

The data storage structure should correctly reflect the logical relationship between data elements.

There are two types of storage structures: sequential storage and chained storage.

1. Sequential storage structure

It is to store data elements in storage units with consecutive addresses, and the logical relationship and storage relationship of the data are consistent. That is, each element is adjacent to the storage location of the predecessor and successor elements. (like an array).

2. Chain storage structure

Chained storage structure: It stores data elements in any storage unit . This group of storage units can be continuous or discontinuous. Data elements are stored using several memory cells with scattered addresses, and logically adjacent data elements are not necessarily adjacent in physical location. Use a pointer to record the storage address of the predecessor or successor element. A node composed of a data field and an address field represents a data element, and the directly related nodes are linked through the address field, and the connection relationship between the nodes reflects the logical relationship between the data elements.

 

Data Types and Abstract Data Types

Type: A set of values ​​that have the same logical meaning.

data type :

Refers to a type and the set of operations defined on that type. The data type defines the nature of the data, the range of values, and the various operations that the data can perform.

Data types are divided by value.

Each data in the program belongs to a data type, which determines the type of the data and determines the nature of the data and the operations and operations on the data memory. Data is also protected by type.

Constructed data types are more complex ones organized according to certain grammatical rules using existing basic data types and defined constructed data types.

Basic data types (such as byte short char int long double float boolean, etc.)

Constructing Data Types: Arrays, Classes, and Interfaces

 

abstract data type

An abstract data type refers to a mathematical model and a set of operations defined on that model.

The definition of an abstract data type depends on its set of logical characteristics, independent of how it is represented and implemented inside a computer.

Data abstraction:

Abstract data type and data type are essentially a concept, and both represent the abstract characteristics of data. Data abstraction refers to the separation of definition and implementation, that is, the logical meaning of data and operations on a type and the specific implementation are separated.

In practical applications, these abstract data types must be implemented before they can be used. The realization of these abstract data types depends on the data storage structure.

Reference: Dahua Data Structure

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325819397&siteId=291194637