Description: The book in the following refers to the "data structure and algorithm (Java language edition)" Version Zhou Peng, some of the content has been modified in accordance with the content of the search engine.
In the implementation of the data structure, we can well match some basic concepts in the data structure with some concepts in the Java language .
< Span style= "FONT-FAMILY:TIMESNEWROMANPSMT; font-size:11pt; Color: #000000; Font-style:normal; Font-variant:normal; " > data elements can be mapped to classes , whose data item is the member variable of the class, a specific data element It can be stored and represented by the member variables of the class, and the operation of the abstract data type is implemented using the method of the class.
Data structure is divided into: logical structure, storage structure.
The logical structure is divided into: set, linear structure, tree structure, graphic structure.
--linear tables, stacks, queues, trees, graphs and other logical structures.
--linear tables, stacks, and queues are linear structures, and trees and graphs are nonlinear structures.
The logical structure can be described in two ways: two tuples, graphs.
--Two tuple representation: DS = (D, S) "Data Structure"
where D is a collection of data elements, S is a collection of relationships between the data elements in D, and the relationships between the data elements are expressed using a sequential pair. The sequence is a two-tuple of two elements x and y arranged in a certain order, as <x, Y> x is its first element and y is its second element.
--When using graphs to represent data structures, the points in the graph are used to represent the elements of the element, and the arcs in the graph represent the relationships between the data elements. If there is a relationship between the data element x and y <x, Y>, then there is an arc in the drawing from the point representing X to the point representing Y.
Now, the other data structure of the two-tuple form is: DS = (D, S), then:
- If D = is null, and S = = NULL, then the data structure is a collection structure.
- If D = {05},s, n, a, n, n, c = {<02,04>, <03,05>, <05,02>, <01,03>}, the data structure is a linear structure.
In these data elements, there is aTo be called "the first one"data element; There's another one that can be called "the last one."data element, except for the first element, each data element has and has only one direct precursor element, and each data element except the last element has and has only one direct successor element. This data structure is characterized by a 1-to-1 connection between the elements of the element , the linear relationship.
- D = {01, 02, 03, 04, 05, 06}
S = {<01,02>, <01,03>, <02,04>, <02,05>, <03,06>}
In addition to a data element (element01), there is only one direct precursor element for each data element, but there can be more than one direct successor element. This data structure is characterized by a 1-to-N relationship between the elements of a database , the tree structure.
- D = {01, 02, 03, 04, 05}
S = {<01,02>, <01,05>, <02,01>, <02,03>, <02,04>, <03,02>,<04,02>, <04,05 <05,01>, <05,04>}:
each data element can have more than one direct precursor element, or it can have more than one direct successor element. This data structure is characterized by the M-N relation between the elements of the element , i.e. the graph structure.
Storage structure is divided into: sequential storage structure, chain storage structure.
An algorithm ( algorithm) is a collection of instructions, a series of operations that are prescribed to address a particular problem.
In the computer resources, the most important thing is time and space. Evaluating the performance of an algorithm is actually the problem of the resource occupancy of the price evaluation algorithm.
algorithm run time indeed The problem is called with the upper bound of time complexity!
< Span style= "FONT-FAMILY:SIMSUN; font-size:11pt; Color: #000000; Font-style:normal; Font-variant:normal; " >
in general ,
calculate the number of cycles, Analyze the basic operation of the highest frequency, the best worst and average situation analysis, and the averaging analysis.
Basic knowledge of data structure (i.)