Chapter VII Summary (Find)

A chapter study summary

(A) concepts and terminology are looking for:

1, the lookup table: is a set consisting of data elements of the same type (or records), such as linear lists, trees, hash tables, and the like.

2, keyword: value of a data item is a data element (or record) is used to identify a data element (or record). ① primary key: uniquely identifies a record key; ② Keywords: can identify a number of record keywords.

3. Find: given a value according to the determined recording or a data element which is equal to a given key value in a lookup table. Search is successful return result information may be the entire record, in a lookup table or the position of the recording; search is unsuccessful given an "empty" record or "null" pointer.

4, static and dynamic lookup table lookup table: If the table to make modification operations (such as insert, delete, etc.), known as dynamic lookup table, otherwise known as static lookup table while looking for.

5, average length: determining the recording location in the lookup table, for an expected value and for comparing the number of keywords (average) setpoint.

(B) the number of lookup table lookup algorithm

1, linear table lookup

① sequential search:

A no sentinel, the following algorithm (based on an int type key):

Set B Sentinel

 B of A algorithm has been improved, which set up sentry, eliminating the need for each step in the search process to detect whether the entire table lookup is completed. In order to find a traditional, one cycle is determined to compare two times (once determined the value of i is reasonable, another comparison is performed with key), and only has to compare the improved algorithm 1, when a large amount of data, can improve efficiency by reducing a certain time.

Time complexity: O (n), the spatial complexity: O (1); average length: (1 + 2 + ... + n) / n = (n + 1) / 2

Advantages: relatively simple algorithms, both for the order structure also applies to the chain structure, regardless of whether the record can be ordered by Keyword application;

Disadvantages: When a large amount of data to find low efficiency

② binary search (binary search)

Each binary search to find the comparisons to find that the range by half, compared with the sequence table lookup, to find improved efficiency, but requires a binary linear table must sequential storage structure , and the elements in the table by a keyword ordered .

Time complexity: O (log2n); find success average length of (n + 1) / n * log2 (n + 1) -1

Advantages: relatively low frequency and high search efficiency;

Disadvantages: only an ordered table stored sequentially.

③ block search (index sequential search)

Index table: Composition of index entry (index entries: based on each sub-table (or block) is established, including a key item (which is a sub-table within the largest key) and item pointer (indicative of the first sub-table a recording position in the table))

Lookup block can be used to determine a sequential search, binary search can also be used, and the block is recorded in the disordered, only search order.

Advantages: the insertion and deletion of data elements in a table, as long as the element corresponding to the block to find, insert and delete can be performed within the block operation.

Disadvantages: To increase the storage space of an index table and the index table to sort operations.

2, tree lookup table

① binary sort tree (binary search tree): very useful for sorting and searching special binary tree

Binary sort tree binary list stored in the type definition similar to a tree, in addition, binary sort tree lookup, insert, creating other operations may be implemented recursively, delete operation is more complicated, to sub-cases: ① deleted junction point is a leaf node (the first node to find the stored value, the pointer points to the node and its parent, it is determined whether the leaf nodes). ② deleted node only the left subtree or only a right subtree. ③ deleted node has left subtree and right subtree.

The binary search sequence of length n, the number of decision tables are unique, but containing a binary tree of n nodes not unique. Thus, the average length and the shape of the tree nodes with n binary sort tree concerned. The preferred case, the time complexity is O (log2n), the worst case is a single binary sort tree branch tree, time complexity is O (n).

② balanced binary tree: to ensure that the number of searches approximation log2n;

Limitations solve balanced binary tree (when n is large, highly significant) of: ③B- tree

④B + tree: According to the interval division, achieved interval to find.

3. hash table lookup

① basic concepts and terminology

a, a hash function and hash address: determining a correspondence relationship between the H position p stored records whose key and key, is p = H (key), H: a hash function, p: hash address ;

B, hash table: a continuous address space is limited to the data record stored in the corresponding hash address obtained by the hash function calculation.

c, conflict and synonyms: Conflict: different keywords to obtain the same hash address; Synonyms: a function value of the same key

② constructor hash function:

a, digital analysis

b, square reindeer method

c, folding process

d, I stay addition: simple calculation, wide application range, is the most commonly used hash function construction method, not only directly modulo keywords, may be sub-folded, taking middle squared modulus operation, it can guarantee hashing address must fall within the address space in the hash table.

③ A method of handling conflicts

a, open address method (method comprising linear probing, the second detection method, the detection method pseudorandom)

B, link address method: drawing will be required, it is possible to find the average length of the search is successful according to requirements and the like FIG.

Second, the last goal to achieve this target and the circumstances

1, the case reached the last goal: by learning courseware related exercises and homework problems, and try to draw their own understanding of the relevant algorithms, to promote their own search based on the depth and breadth of understanding and the search for further study spanning tree minimum spanning tree of P Karim algorithm and Dijkstra's algorithm for finding the shortest path.

2. The goal: to understand in-depth binary sort tree related algorithms, especially the delete operation and further learn about the B- and B + tree tree; at the same time, but also to understand and construct a hash function and methods of dealing with conflict are well known.

Guess you like

Origin www.cnblogs.com/F254236/p/10963101.html
Recommended