What is the search algorithm used for ordered lists?
The search algorithm used for ordered lists is "halve search".
Related introduction:
Binary search is also called binary search (Binary Search), which is a more efficient search method. However, binary search requires that the linear table must adopt a sequential storage structure, and the elements in the table must be arranged in order by keywords.
Search process
First, assuming that the elements in the table are arranged in ascending order, compare the keyword recorded in the middle of the table with the search keyword. If the two are equal, the search is successful; otherwise, use The middle position record divides the table into two sub-tables, the front and the last. If the keyword of the middle position record is greater than the search keyword, the previous sub-table will be searched further, otherwise the latter sub-table will be searched further. Repeat the above process until a record that meets the conditions is found, making the search successful, or until the subtable does not exist, in which case the search fails.
The above is the detailed content of What search algorithm is used for ordered lists?. For more information, please follow other related articles on the PHP Chinese website!