int bi_searchSq(SqList L, ElemType x)
{
int low = 0;
int high = L.len - 1;
int count = 0;
while (low <= high)
{
int mid = (low + high) / 2;
if (L.data[mid] == x)
{
count++;
return count;
}
else if (L.data[mid] < x)
{
count += 1;
low = mid + 1;
}
else
{
count += 1;
high = mid - 1;
}
}
return count;
}
6-3 统计二分查找比较的次数 分数 15
最新推荐文章于 2024-07-26 08:13:24 发布