java-Data Structure-Overview

Source: Internet
Author: User

Data

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.
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:
1. 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. [1]
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. [2]
Some concepts:
Data is the carrier of information, which can be stored and processed by computer to describe the information symbol of objective things. A set of symbols that can be entered into a computer and can be processed by a computer, which is the object of computer program processing. Objective things including numerical, character, sound, graphics, images, etc., they are not data in themselves, only by encoding into the computer can be recognized, stored and processed by the symbol form is the data.
Data elements are the basic unit of data and are generally considered as a whole in computer programs. A data element consists of several data items. The data item is the smallest unit discussed in the structure. There are two types of data elements: if the data elements can be re-divided, then each independent processing unit is a data item, the data element is a collection of data items, if the data elements are not re-divided, the data elements and data items are the same concept, such as: integer "5", the character "N" and so on. For example, a data element that describes a student's information can consist of the following 6 data items. The date of birth can be made up of three data items: "Year", "Month" and "Day", then the "date of birth" is a combination, and the other indivisible data items are atomic.
A keyword refers to a data item that identifies one or more data elements. It is called the "main" keyword if it can be uniquely identified, otherwise it is called the "secondary" keyword.
A data object is a collection of data elements of the same nature and is a subset of the data. Data objects can be finite or infinite.
Data processing refers to the operation of searching, inserting, deleting, merging, sorting, statistics and simple calculation. In the early days, computers were used primarily for scientific and engineering calculations, and after the 80 's, computers were used primarily for data processing. According to the relevant statistics, the computer data processing time ratio of more than 80%, with the passage of time and the further popularization of computer applications, the data processing time proportion of computers will be further increased.

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.
Based on the different characteristics of the relationship between data elements, there are generally four basic 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 collection of data 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 collection of data 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.

线性表队列(堆)栈递归算法串操作集合树二叉树图查找排序
Data structures in Java

Interface:
Collection
Sub-Interface:
Blockingdeque, Blockingqueue, Deque, List, Navigableset, Queue, Set, SortedSet
Implementation class:
Arrayblockingqueue, Arraydeque, ArrayList, Concurrentlinkedqueue, Concurrentskiplistset, Copyonwritearraylist, Copyonwritearrayset, Delayqueue, Enumset, HashSet, Linkedblockingdeque, Linkedblockingqueue, Linkedhashset, LinkedList, Priorityblockingqueue, Priorityqueue, Stack, Synchronousqueue, TreeSet, Vector

List
Implementation class:
ArrayList, Copyonwritearraylist, Linkedlist,stack, Vector

Queue
Sub-Interface:
Blockingdeque, Blockingqueue, Deque
Implementation class:
Arrayblockingqueue, Arraydeque, Concurrentlinkedqueue, Delayqueue, Linkedblockingdeque, LinkedBlockingQueue, LinkedList, Priorityblockingqueue, Priorityqueue, Synchronousqueue

Set
Sub-Interface:
Navigableset, SortedSet
Implementation class:
Concurrentskiplistset, Copyonwritearrayset, Enumset, HashSet, Linkedhashset, TreeSet

Map

Java-Data Structures-Overview

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.