Data structure - string array / matrix / table Generalized
A. String
Linear string is a special table that particular type of data elements can be embodied in a plurality of characters
1. Pattern Matching
Two strings p and q, q seeking a position first appears in the p
2.KMP match
Text string of length n, the pattern string length m, the string matching the time complexity of the algorithm is KMP 0 (m + n)
3.next,nextval
(1) next: 0 as the first two, the third from the beginning, next is the same before and after the character string preceding the longest substring match length +
(2) nextval (0 is the first):
i = 1 → ...
pattern string P [I] aaabcaa
Next to ki 0 1? ? ? ? ?
nextval (i) 0? ? ? ? ? ?
nextval [i] values:
the p-[ki] and p [i] compares
① equal with the old val [ki], ② not equal with k
equal with you, rob you people are not equal
II. Array
III. Matrix
1. Matrix
The first element (upper left corner) matrix a₀₀
Special and sparse matrices
purpose for some special uses compressed storage matrix primarily to reduce unnecessary overhead storage space
Special matrix 2-1
① symmetrical
only symmetric matrix storage element includes a main diagonal of the triangular portion including the lower (or upper) to
② Triangle
③ diagonal
shall be stowed in the diagonal matrix elements can be zero
2-2 sparse matrix
The vast majority of matrix elements are zero (irregular distribution)
Test sites
1: sparse compressed storage, will lose random access function.
Because the matrix, irregular distribution of non-zero elements.
Store the compressed value of each non-zero element and its row and column number stored together as a node.
Such linear form consisting of nodes called triple table.
It is not simply vector, elements of the matrix can not be accessed directly by the subscript.
2-2-1 sequential storage - triples
Triplet (i, j, a)
triple the length of a data structure is n, each element in the table represent the row index, column labels, element values
There are three components (values, the row / column index) linear form
trimat [k] .val; represents taking the k-th non-zero element values
Triple table with rows:
RowTab i represents all the non-zero element rows before the i-th row.
The first row (RowTab [0]) because it is the first row, until there is no non-zero elements, it corresponds to 0;
02335 row table as a matrix representing
the first row there are two elements 1 (since there are two elements before the row 2);
the second row one element;
line 3 without elements;
line 4 has two elements
Test sites:
1: triplet (i, j, a) is transposed (j, i, a)
2-2-1 is sequentially stored - Method Pseudo Address
The relative position of elements stored in a matrix according to the row-or column-major
Pseudo Address: priority row or a column element according to the relative position stored in the priority matrix
2-2-2 chain store
(1) adjacent to the table
Non-zero elements in each row into a list of series
(2) Cross list
Each row, a column is represented as a linked list node lead
3. General List
Extended table elements may be of a linear structure or a generalized table atoms table
1. Concept
(1) the length of
the number of table elements in the uppermost
(2) the depth of
the maximum number of layers in the table brackets
(3) header, footer
first element (non-empty) table of the header generalized
remaining elements of the table is a generalized table footer
Empty table (): length of 0, a depth of 1
Elemental
Table (()): a length of 1, 2 to a depth of
one element (the empty list), the element points to NULL
decomposed to give its header, footer table are empty
Atoms: depth 0
2. storage structure
2-1 craniocaudal list (textbook page 109)
(1) coerced element (the same layer)
(2) point elements
① atoms pointing directly (e.g., A →)
② ⇒ execution table (1)
= A ()
⇒A = NULL (no elements, no coerced)
D (())
⇒D = [1, NULL, *] (element, element points to NULL)
See 2002 papers
(2) extended linear list
① coerced header elements (there must be)
(one layer) ② point table header element (may not), point to other elements
= A ()
⇒A = [. 1, NULL, *] (coerced header, no header element, pointing NULL)