Class notes: basic concepts for finding

Basic concepts of search

List : A collection of data elements of the same type.
Key code : A data item in a data element, which can identify one or a group of data elements in the list.
Key value : the value of the key code.
Master key code : A key code that can uniquely identify a record.
Secondary key code : The key code of a record cannot be uniquely identified.
Find : Find the records that meet the given conditions in the set of records with the same type.
The result of the search : If a record matching the given value is found in the search set, the search is said to be successful; otherwise, the search is said to fail.
Static search : Searches that do not involve insert and delete operations.
Dynamic search : search involving insert and delete operations.
Static Look for : Look through a collection of production, only look for them, without insert, and delete operations; or look after a period of time, such as centralized manner insert and delete the operation;
dynamic Look for : Find Insert and delete operations are performed at the same stage, for example, when the search is successful, the found record is deleted, and when the search is not successful, the searched record is inserted.
Search structure : A data structure oriented to a search operation, that is, the data structure on which the search is based.
Linear table : suitable for static search, mainly using sequential search technology and half search technology.
Tree table : suitable for dynamic search, mainly using binary search tree search technology.
Hash table : Both static search and dynamic search are applicable, mainly using hash technology.

Finding algorithm performance

The time performance of the search algorithm is measured by the number of key comparisons .
What factors are related to the number of key comparisons?
(1) Algorithm; (
2) Problem size;
(3) The position of the key to be searched in the search set;
(4) Search frequency.

The search frequency is independent of the algorithm and depends on the specific application. It is generally assumed that pi is known.
With the same search set and the same search algorithm, what factors are related to the number of key comparisons?
The time complexity of the search algorithm is a function of the problem size n and the position k of the key to be searched in the search set, denoted as T (n, k).
Average search length : The mathematical expectation of the number of key comparisons performed by the search algorithm is defined as the average search length. The calculation formula is: ASL = ∑pici (i = 1-> n)
where: n: problem size, find the number of records in the set; pi: find the probability of the i-th record; ci: need to find the i-th record The number of comparisons of the key codes.
Conclusion: ci depends on the algorithm; pi has nothing to do with the algorithm and depends on the specific application. If pi is known, the average search length is only a function of the problem size.

Published 48 original articles · Like 25 · Visit 2453

Guess you like

Origin blog.csdn.net/qq_43628959/article/details/103357445