—60— 改进的二分法查找 王海涛,朱 洪 (复旦大学计算机科学与工程系,上海 200433) 摘 要:当前有很多的查找算法,其中在对有序数列的查找算法中二分法查找(binary search)是最常用的。利用二分法,在含有n个元素的有序数列中查找一个元素的最大比较次数为 log 1n +⎢⎥ ⎣⎦。在很多情况中,在查找之前有序数列分布的很多信息为已知,比如说如果知道了有序数列中每相邻两个元素之差的最大值的一个上界,就可以有比二分法更加有效的查找算法。文章给出了一个称之为改进的二分法查找算法。改进的二分法查找性能明显优于二分法查找,受数列分布的影响,其最坏情况下查找一个元素的最大比较次数在 1 和 log 1n +⎢⎥ ⎣⎦之间, 明显优于二分查找的 log 1n +⎢⎥ ⎣⎦。在实际应用中利用改进的二分法可以极大地提高查找效率。 关键词:查找;二分法;有序数列;算法 Modified Binary Search WANG Haitao, ZHU Hong (Department of Computer Science and Engineering, Fudan University, Shanghai 200433) 【Abstract】Consider the problem of determining whether a given elementx is in array. To solve the search problem, there are many algorithms. And binary search is the most common search algorithm if the array is sorted. The number of comparisons performed by binary search on a sorted array of size n is at most log 1n +⎢⎥ ⎣⎦. The time cost of binary search reaches the lower bound of the search problem. But in many circumstances, some information about the array before search is known. If the upper bound of the maximum difference between any adjacent elements in the array is known, one can design a preferable algorithm. It is referred as modified binary search. In the worst case, the maximum number of comparisons performed by modified binary search is between 1 and log 1n +⎢⎥ ⎣⎦, obviously better than binary search. 【Key words】Search; Binary search; Sorted array; Algorithm 计 算 机 工 程 Computer Engineering 第32卷 第10期 Vol.32 № 10 2006 年 5 月May 2006 ·软件技术与数据库· 文章编号:1000—3428(2
二分法查找是基于有序_改进的二分法查找
最新推荐文章于 2021-11-22 22:26:43 发布
本文介绍了一种在已知数列分布信息下,针对有序数列设计的改进二分法查找算法。它在最坏情况下比传统二分法表现更优,查找次数介于1和log(n)+1之间,显著提升查找效率。适用于需要利用额外信息优化搜索任务的场景。
摘要由CSDN通过智能技术生成