Data
(Computer storage, organization data mode)
The data structure is the way that the computer stores and organizes it. A data structure is a collection of elements that have one or more specific relationships to each other. Typically, a well-chosen data structure can lead to higher operational or storage efficiency. Data structures are often associated with efficient retrieval algorithms and indexing techniques.Chinese nameDataExplainhow a computer stores and organizes dataSpecific pointsA elements for a particular relationshipAboutretrieval algorithms and indexing techniquesdefinition
noun definitions
Data_structure= (D,r)
Data structure refers to the relationship among the elements, including three components, logical structure of data, data storage structure and data operation structure.
Research objects
The logical structure of data: refers to the data structure that reflects the logical relationship between data elements, in which the logical relationship refers to the back-and-forth relationship between data elements, regardless of where they are stored in the computer. The logical structure includes:
-
Collection
There is no other relationship between the elements in the data structure except the relationship of the "same belonging to one set";
2. Linear structure
There is a one-to-one relationship between the elements in the data structure;
3. Tree-shaped structure
There is a one-to-many correlation between the elements in the data structure;
4. Graphic structure
There are many-to-many interrelationships between elements in a data structure.
Second, the physical structure of the data: refers to the logical structure of the data stored in the computer storage space form.
The physical structure of the data is the representation of the data structure in the computer (also called an image), which includes the in-machine representation of the elements and the in-machine representation of the relationship. Because the methods of implementation are sequential, link, index, hash and so on, a data structure can be represented as one or more storage structures.
In-machine representation of the data element (image method): The data element is represented by a bit string of bits (bit). This bit string is usually called node. When a data element consists of several data items, the substring corresponding to the data item in the bit string is called the data field. Therefore, the node is an in-machine representation (or an in-machine image) of the data element.
In-machine representations of relationships (image methods): In-machine representations of relationships between data elements can be divided into sequential and non-sequential images, often with two storage structures: sequential storage structures and chained storage structures. Sequential images represent the logical relationships between data elements by means of their relative positions in memory. A non-sequential image represents a logical relationship between data elements by means of a pointer (pointer) indicating where the element is stored.
Third, the computation of data structure.
Classification
A data structure is a relationship that exists between data elements in a class of the same element. The data structures are logical structure, storage structure (physical structure) and data operation respectively. The logical structure of data is a mathematical model abstracted from specific problems, which is the mathematical characteristic of describing data elements and their relationships, and sometimes the logical structure is abbreviated as data structure. The logical structure is an image in the computer store, defined as (K,r) (or (d,s)), where K is a finite set of data elements, and R is a finite set of relationships on K.
Depending on the characteristics of the relationship between the data elements, there are generally four basic types of structures:
⑴ the collection structure. The relationship between the data elements of the structure is "belong to the same collection". ⑵ linear structure. There is a one-to-one relationship between the data elements of the structure. ⑶ tree-type structure. There is a one-to-many relationship between the data elements of the structure. ⑷ graphic structure. There is a many-to-many relationship between the data elements of the structure, also known as the network structure. As you can see from the concept of the data structure described above, there are two elements in a data structure. One is a elements and the other is a collection of relationships. In form, data structures can usually be represented by a two-tuple.
The form of the data structure is defined as: The data structure is a two-tuple: data_structure= (d,r), where D is a finite set of data elements, and R is a finite set of relationships on D. The linear structure is characterized by a linear relationship between the data elements, and the data elements are arranged "one after another". The type of the data element in a linear table is the same, or the linear table is a linear structure consisting of data elements of the same type. Examples of linear tables in practical problems are many, such as student case information tables are a linear table: the types of data elements in a table are student types; A string is also a linear table: the type of the data element in the table is character type, and so on.
Linear tables are the simplest, most basic, and most commonly used linear structure. A linear table is a finite sequence of n (n>=0) data elements of the same data type, usually written as: (A1,a2, ... ai-1,ai,ai+1,...an), where n is the table length and n=0 is called an empty table. It has two storage methods: Sequential storage and chained storage, and its main basic operations are INSERT, delete, retrieve and so on.
The representation (image) of a data structure in a computer is called the physical (storage) structure of the database. It includes representations of data elements and representations of relationships. There are two different representations of the relationships between data elements: sequential mappings and non-sequential mappings, resulting in two different storage structures: sequential storage structures and chained storage structures.
Sequential Storage method: It is the logical adjacent nodes stored in the physical location adjacent to the storage unit, the logical relationship between nodes is represented by the adjacency relationship of the storage unit, the resulting storage representation is called sequential storage structure. Sequential storage structure is the most basic method of storage representation, which is usually realized by means of an array in the programming language.
Link Storage method: It does not require logically adjacent nodes to be adjacent to the physical location, and the logical relationship between nodes is represented by additional pointer fields. The resulting storage representation is called a chained storage structure, and the chain storage structure is usually implemented by means of a pointer type in the programming language.
Index Storage Method: In addition to establishing the storage node information, an additional index table is established to identify the address of the node.
Hash Storage method: The storage address of the node is calculated directly based on the keyword of the node.
In the data structure, logically (logical structure: the logical relation between data elements) can divide data structure into linear structure and nonlinear structure. Sequential storage structure of linear structure is a kind of sequential access storage structure, and the chain storage structure of linear table is a kind of random access storage structure. A linear table with a chained storage representation, the address of the storage unit between all nodes can be continuously discontinuous. The logical structure is independent of the form, content, relative position and number of nodes of the data element itself.
Structure algorithm
The design of the algorithm depends on the data (logical) structure, and the implementation of the algorithm relies on the storage structure adopted. The storage structure of data is essentially the implementation of its logical structure in computer memory, in order to comprehensively reflect the logical structure of a data, its image in memory includes two aspects, that is, the relationship between data elements and data elements. Different data structures have some corresponding operations. The operation of the data is the operational algorithm defined on the logical structure of the data, such as retrieval, inserting, deleting, updating and sorting.
The operation of data is an important aspect of structure, and it is necessary to discuss the data operation and its implementation algorithm in any structure.
The data structure is different from the data type and also differs from the data object, which not only describes the data object of the data type, but also describes the interrelationships between the elements of the data object.
A data type is a collection of values and a generic term that defines a set of operations on that set of values. Data types can be divided into two categories: atomic type, struct type. On the one hand, in a programming language, each data belongs to a data type. The type clearly or implicitly specifies the range of data, how it is stored, and what operations are allowed. It can be considered that the data type is the data structure that has been implemented in the program design. On the other hand, in the process of programming, when we need to introduce some new data structure, we always use the data type provided by the programming language to describe the storage structure of the data.
The smallest unit of data represented in a computer is a binary number, called a bit. We use a bit string formed by a number of bits to represent a data element, often called a string of elements or nodes. When a data element consists of several data items, the sub-string corresponding to each data item in the bit string is called the data field. An element or node can be viewed as an image of a data element in a computer.
A software system framework should be built on top of data, not on operations. A software module with an abstract data type should contain a definition, representation, and implementation of three parts.
For each data structure, there must be a set of operations closely related to it. If the type and number of operations are different, even if the logical structure is the same, the data structure can play a different role.
Different data structures have different sets of operations, but the following actions are essential:
1, the generation of structures;
2. Destruction of structures;
3, in the structure to find the data elements that meet the specified conditions;
4, inserting new data elements into the structure;
5. Delete data elements that already exist in the structure;
6, Traverse.
Abstract data types: A mathematical model and a set of operations defined on the model. The abstract data type is actually the definition of the structure. Because it defines the logical structure of a data and a set of algorithms on this structure. The abstract data type can be represented by the following ternary groups: (D,S,P). D is the data object, S is the set of relationships on D, and P is the basic set of operations on D. ADT is defined as:
ADT Abstract Data type name: {Data object: (data element collection), Data relation: (data relation two tuples combined), basic operation: (List of operation function)}; ADT abstract data type name; Abstract data type has two important features:
Data abstraction
When using ADT to describe an entity handled by a program, the emphasis is on its intrinsic characteristics, the functions it can perform, and its interface with external users (that is, how the outside world uses it).
Data encapsulation
Separates the external attributes of an entity from its internal implementation details, and hides its internal implementation details from external users.
Data is the carrier of information, which can be recognized, stored and processed by computer. It is the raw material for computer program processing, and the application handles a wide variety of data. In computer science, the so-called data is the computer processing object, it can be numerical data, can also be non-numerical data. Numerical data is a number of integers, real numbers or complex numbers, mainly used in engineering calculation, scientific calculation and business processing, etc. non-numeric data includes characters, text, graphics, images, speech, and so on. The data element is the basic unit of data. Under different conditions, data elements can also be called elements, nodes, vertices, records, and so on. For example, a student information retrieval system A record in the information table, etc., is called a data element.
Sometimes, a data element can consist of several data items, for example, each data element of the Student information table of the student enrollment management system is a student record. It includes student's number, name, gender, birthplace, date of birth, achievement and other data items. These data items can be divided into two kinds: one is called elementary items, such as students ' gender, place of origin, etc., these data items are the smallest units that can not be split in data processing, and the other is called combination items, such as students ' grades, which can be subdivided into smaller items such as mathematics, physics, chemistry, etc. In general, each student record is accessed and processed as a basic unit when solving practical application problems.
The data object, or data element class, is a elements of the same nature. In a specific problem, the data elements all have the same nature (element values are not necessarily equal), belong to the same data object (the Data element Class), and the data element is an instance of the data element class. For example, in a transport network, all vertices are a data element class, and vertex A and vertex B each represent a city, and are two instances of the data element class, with the values of A and B respectively. Data Structure refers to a collection of elements that have one or more relationships to each other. In any problem, the data elements are not isolated from each other, and there is one or the other relationship between them, and the relationship between the data elements is called a structure.
Common structure
Array
In the program design, in order to deal with the convenience, the same type of a number of variables organized in an orderly form. The collection of these ordered, homogeneous data elements is called an array. In the C language, an array is a constructed data type. An array can be decomposed into multiple array elements, which can be either basic data types or constructed types. Therefore, according to the type of array elements, the array can be divided into numerical array, character array, pointer array, array of structures and other categories.
Stack
is a special linear table that can only be inserted and deleted at one end. It stores the data according to the advanced principle, the first data is pressed into the bottom of the stack, the final data is at the top of the stack, and the data is read from the top of the stack (the last data is read first).
Queue
A special linear table that allows for deletion only at the front end of the table (front), and in the back end of the table (rear). The end of the insert operation is called the tail of the queue, and the end of the delete operation is called the team header. The queue organizes the data according to the principle of "FIFO" or "Backward out". When there are no elements in the queue, it is called an empty queue.
Linked list
is a non-sequential, non-sequential storage structure on a physical storage unit that can either represent a linear structure or represent a nonlinear structure, and the logical order of the data elements is achieved through the order of the pointers in the linked list. A linked list consists of a series of nodes (each element in the list is called a node) that can be dynamically generated at run time. Each node consists of two parts: one is the data field that stores the data element, and the other is the pointer field that stores the next node address.
Tree
is a poor set K containing n (n>0) nodes, and a relationship defined in K n,n satisfies the following conditions:
(1) There is only one node K0, he has no precursor to the relationship N, called K0 as the root node of the tree. Referred to as root (root). (2) In addition to K0, each node in K has and has only one precursor for the relationship N.
(3) The nodes in K can have M successors (m>=0) for the relationship N.
Figure
The graph is composed of set E of the node's poor set V and the edge. Among them, in order to distinguish with the tree structure, the nodes are often called vertices in the graph structure, the edges are the ordered pairs of vertices, if there is an edge between the two vertices, it means that the two vertices have neighboring relations.
Heap
In computer science, a heap is a special tree-shaped data structure that has a value for each node. Usually what we call a heap of data structures is a two fork heap. The heap is characterized by the minimum (or maximum) value of the root node, and the two subtrees of the root node are also a heap.
Hash table
If there is a record of the same keyword and K in the structure, it must be in the storage location of f (k). As a result, the records can be obtained directly without comparison. The corresponding relationship f is called the hash function, and the table created by this thought is a hash list.
Java data--data structure