1. Sequential search:
From the end of the table, scan the linear table sequentially and compare the node keywords scanned with the given value K.
Under equi probability conditions, the average length of... search is ASL = (n +... + 2 + 1)/n = (n + 1)/2;
2. Binary Search:
The premise is that a linear table is an ordered table. Assume that the data is sorted in ascending order. For the given value X, the comparison starts from the intermediate position of the sequence. If the current position value is equal to X, the query is successful. If X is less than the current position value, search in the first half of the series; if X is greater than the current position value, continue searching in the second half of the series until it is found.
Under the equi probability condition... average search length: ASL = log2 (n + 1)-1 = log2 (n + 1)
Reason: the binary tree is used to describe the relationship between the height D of the tree and the node tree: d ^ 2-1 = N; so d = log2 (n + 1 ), each layer only needs to be compared once. Therefore, log2 (n + 1) can be compared at most.
3. multipart search:
It is also called index ordered search, which is ordered by blocks (the keywords in each block are not necessarily ordered, but the maximum keywords in the previous block must be smaller than the minimum keywords in the next one, that is, the Segmented Order .) Linear table and index table. For example, the R [1... n] is divided into B blocks, then the number of B-1 block nodes is S = [N/B], the last part is allowed to be less than or equal to S. An index is an incremental ordered table.
The average search length is divided into two parts: Index Table search + intra-block search. (The index table can be searched by binary method and sequence. The block is unordered, so it can only be searched by sequence)
If the block is determined by binary search, ASL = log2 (B + 1)-1 + (S + 1)/2 = log2 (N/S + 1) + S/2;
If the block is determined by searching in order, ASL = (B + 1)/2 + (S + 1)/2 = (s ^ 2 + 2 S + n) /(2 S ).