# Data structure small Knowledge point finishing

Source: Internet
Author: User

1 Introduction

The data structure is mainly to study the logical structure of data structure, storage structure, and define the operation and operation of the structure in three aspects. "

1.1 Basic concepts and common terminology

data: Data is a set of values, characters, and various characters that can be entered into a machine and can be processed by the object.

U is the computed information.

data elements: Data elements are also known as nodes, which are the basic units of data, and are relatively independent units of the data as a whole.

field: A field is the smallest unit that constitutes data.

Data Objects: In data structures, a collection of data elements of the same nature is called a data object, which is a subset of the data.

Data structure: consists of a collection of elements and the relationships between all the data elements in the collection. Specifically, the data structure contains 3 aspects of the content, namely the logical structure, data storage structure and the operation of the logarithm.

according to the different characteristics of the structure relationship between elements in the data structure, the data structure is usually divided into the following four basic structures:

(1), collection structure (SET):: A finite combination of data elements.

U (2), linear structure, or sequence:: An orderly combination of data elements.

U (3), Tree:: Tree Hierarchy, a one-to-many relationship exists between data elements in the tree.

U (4), Graphic structure::: The relationship between the data elements in the graph is many-to-many.

1.2 Logical Structure

the logical relationship between nodes and nodes is called the logical structure of data. "

(1), linear structure. There is a one-to-one linear relationship between elements, the first element has no direct precursor, the last element has no direct successor, and the remaining elements have a direct precursor and a direct successor.

(2), nonlinear structure. Elements are one-to-many or many-to-many nonlinear relationships, and elements can have multiple direct precursors or multiple direct successors.

(3), set structure. There is no relationship between elements, and the ordering of elements is not in any order.

1.3 storage structure

the logical structure of the data is independent of the computer, it is not related to the storage of the data in the calculation, to the data processing,

You must store the data on your computer. The way data is stored in a computer is called the storage structure of the data. of the data

There are 4 main types of storage structures. " 2 Tree" a couple of many "

tree structure is the most important non-linear data structure in computer algorithm, in which the tree and the two-fork tree are most commonly used, it can describe the object with branch relation and hierarchical characteristic well, and it is also the representation of hierarchical relational data in the computer to provide a natural representation method. "

2.1 Basic concepts of trees

A tree is a finite set of nodes consisting of N (n>=0). The n=0 tree is called the empty tree, and the n>0 tree is any non-empty tree.

The logical representation method of 2.1.1 Tree

(1), Direct notation

(2), nested set notation

(3), recessed notation < like document catalog >

(4), Generalized table notation

Basic terms of the 2.1.2 Tree

(1), node degree (degree)-----------refers to the number of subtrees in the node.

(2), the degree--------------of the tree refers to the maximum value of the degree of each node in the tree. The maximum value of the node's degree

(3), node hierarchy (level)---the root node in the tree at the level of 1, the remaining nodes of any node is equal to the level of their parent nodes plus 1.

(4), the depth of the tree (depth)------The maximum level of the nodes in the tree is called the depth of the tree, also known as the height.

2.2 Two fork tree concept and properties 2.2.1 definition

a two-fork tree is an ordered tree with a maximum degree of 2. It is one of the simplest and most important trees,

computer field has a wide range of applications.

2.2. The nature of the 22-fork Tree

Property 1: On the layer I of a non-empty two-fork tree, there are up to 2^i-1 nodes (i>=0).

Property 2: A two-fork tree with a depth of K, with a maximum of 2^k-1 nodes (k>=1).

Property 3: For any non-empty binary tree, if its terminal node number is n0, the degree of 2 of the node is N2, then n0=n2+1.

full two fork tree: a two-fork tree with a depth of K and a 2^k-1 node is called a full two-fork tree.

Complete binary tree: A two-tree with a depth of n nodes, numbering the nodes in the tree from top to bottom, left to right, if the node numbered I (1<=i<=n) is the same as the node numbered I in the full two-tree, the binary tree is called a complete binary tree.

Property 4: The depth of a complete binary tree with n nodes is |log2n|+1.

Property 5: If the nodes of a complete binary tree with n nodes (its depth is |log2n|+1) are numbered hierarchically (from the first layer to the |LOG2N|+1 layer, each layer from left to), then any node I (1<=I<=N) has the following properties:

(1)

3 Chart "Many-to-many" 3.1 Definition of the diagram

graph is a finite set of-----edges (or arcs) by a non-empty vertex collection and a relationship that describes the vertices

a data structure that is composed of

3.2 related terms of graphs

| No map: No direction.

| directed graph: With direction, Ray.

| No Direction full picture: There are N (n-1)/2 edges of Figure <n for vertex number >.

| to full graph: There are N (n-1) edges of the figure <n for vertex number >.

| sparse and dense graphs: the number of edges raised by vertices is judged.

| The degree of the vertex, "in degrees, out of relative to the directed graph": The number of segments raised by the degree----of the vertex of the non-directed graph

The degree <TD>----of the vertex of the graph (<id>+) = degrees of penetration <OD>

| Right and Net: weights, edges or arcs with the right value of the graph become net.

| Path and path length: The path----a sequence of edges formed by vertices and adjacent vertex pairs

The path length------The weights of the tracks that connect the vertices.

| Loop: A closed ring formed from a vertex to a vertex.

| Sub-graph: The part of the diagram.

| Connected graphs and connected components: connected graphs: Graphs that each vertex can connect to the rest of the vertices. Connected components: Splitting a non-connected diagram into multiple sub-connected graphs.

| Strong connected graphs and strong connected components: "Strong connected graph"---directional graph, two-way connection graph "strong connected component": The non-strong connected graph is split into multiple sub-strong connected graphs.

| Spanning tree: it must contain and contain only n-1 edges of G. More one: The formation of a loop; one less: non-connected

| build the forest.

storage structure of 3.3 graphs 3.3.1 adjacency matrix storage structure

form: a[i][j]=@1:1------represents two vertex existence side

=@2:0----represents two vertices without edges

1: Non-connecting matrix diagram

Features: Symmetrical distribution

the degree of vertex: the number of non-0 points in the row.

2: The connected matrix diagram

features: Generally not symmetrical distribution, only when it is fully symmetrical to the graph.

number of points not 0: the number of non-0 points in the row represents the degree.

the number of non-0 points in the column represents the entry level

3: Non-connecting matrix network

with a weighted graph, 1 of the matrix is replaced with a weight value, and 0 is replaced with an infinite value.

4: The Connected matrix network

with a weighted graph, 1 of the matrix is replaced with a weight value, and 0 is replaced with an infinite value. 3.3.2 adjacency table storage structure

In contrast to sparse graphs, it is to conserve storage space and introduce pointers.

convert the segments connected by each vertex to a single linked list. "

the degree of vertex is: number of segments .< nodes >

Matrix Size: n^2

convert the segments connected by each vertex to a single linked list. Only care about the degree. "

If you want to be concerned about the introduction: Inverse adjacency table of graphs

3: Extension

extension: For a graph with n vertices and e edges, if an adjacency table is taken, the size of the table head vector is: N, and the total number of nodes in all adjacency tables is: 2e

4.4 Stacks and queues

1: Stack definition "advanced out"------is a linear table that restricts insertions and deletions only at one end of the table. (Stack top < allow insertion and deletion of one end, bottom < not allow insertion and deletion of one end >).
"Divided into: sequential stacks and chain stacks."

2:*** sequence stack, the definition, initialization, into the stack, out of the stack, take the top element of the stack operation, judge the empty operation, the stack empty operation.

3: Multi < dual > stack sharing (contiguous space)

4: Link stacks < related pointers;: Stacks can also be expressed as chain-like storage structures, which are referred to as chain stacks.
Operation of the chain stack---@1: allocating node space
@2: Data field
@3: Pointer field
@3: Top pointer node pointing "

5: Queue---"FIFO, on its operation: Team tail insert, head delete." : is a limited linear table that allows you to insert an element at one end of the table and delete the data at the other end of the table.
Queue divided into: Sequential Queue and chain queue

6: Sequential queue: The sequential storage structure of the queue is called the sequential queue, and the sequential queue is actually a sequential table with limited operations, and the sequential queue must also use a vector space to hold the elements in the current queue.
Since the position of the head and tail of the queue is changed, two pointers front and rear are set, respectively, to indicate the position of the head element and the tail element in the vector space.
(Special note: Both pointer front and rear initialization should be set to 0; In a non-empty queue, the head pointer always points to the first element, while the pointer always points to the next position of the tail element)
In order to prevent "false overflow phenomenon" introduced-------loop queue.
------the Loop queue (in the case of front==rear) is empty or the queue is full: two methods--:

Method One: Sacrifice storage space. The condition for determining the queue "full" is (rear+1) Maxsize=front.
Method Two: A method for setting a flag variable. (The flag tag=0 indicates that the last operation is the team, tag=1 indicates that the last operation was queued)---judging the team empty conditions are: front==rear && tag==0
The conditions for judging the full team are: Front==rear && tag==1.

7: Chain Queue-the chain storage structure of a queue is simply a chain queue, which is a single linked list that restricts only the header deletions and footer insertions. It is clear that only the head pointers of single-linked lists do not facilitate insert operations at the end of the table.
Add one for this pointer, pointing to the last node on the list. As a result, a chain queue is uniquely determined by a head pointer and a tail pointer.

Related Keywords:

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.