当前位置:网站首页>顺序查找,折半查找,分块查找 ~
顺序查找,折半查找,分块查找 ~
2022-07-26 05:43:00 【柯基@】
顺序查找
int Search(int a[],int n,int key){
for(int i=0;i<n;i++)
if(a[i]==key)
return i;
return 0;
}
折半查找 (要求线性表有序,eg:递增,递减)
int Bsearch(int a[],int low,int high,int key){
int mid;
while(low<=high){
mid=(low+high)/2;
if(a[mid]==key)
return mid;
else if(a[mid]>key)
high=mid-1;
else
low=mid+1;
}
}
分块查找
//索引表定义
typedef struct{
int key; //假设表内元素为 int 类型
int low,high; //记录某块中第一个元素和最后一个元素的下标
}indexElem;
indexElem index[maxSize]; //定义索引表
边栏推荐
- OD-Paper【1】:Rich feature hierarchies for accurate object detection and semantic segmentation
- Introduction to Chinese text error correction task
- 嵌入式通用学习路线整理
- Redis 官方可视化工具,高颜值,功能真心强大!
- Motor control column summary
- Three implementation methods of thread and the usage of handler
- No background, no education? Is it really hopeless for specialist testers to enter Internet factories?
- Knowledge points of Polymer Physics
- Redis persistence RDB
- Hack the box -sql injection fundamentals module detailed Chinese tutorial
猜你喜欢

Code audit CMS

Redis persistence RDB
C language explanation series - understanding of functions (4) declaration and definition of functions, simple exercises

Application and value of IVR in VoIP telephone system
![[personal summary] end of July 24, 2022](/img/9e/dfc37c2684aa8849291817782c947b.png)
[personal summary] end of July 24, 2022

【STM32系列汇总】博主的STM32实战快速进阶之路(持续更新)

OD-Paper【1】:Rich feature hierarchies for accurate object detection and semantic segmentation

高分子物理试题库

Redis事务

leetcode-aboutString
随机推荐
Yolov3 preparatory work
Unity Profiler
leetcode-aboutString
Hack The Box -SQL Injection Fundamentals Module详细讲解中文教程
FTP实验及概述
SIP账号注册的SIP软电话的使用和常见问题
MySQL optimization
LAMP架构
TZC 1283: simple sort - Comparative sort
[cloud native] introduction and use of feign of microservices
高效,可靠,安全的串口通讯开源方案
No EGL display error resolution
Redis transaction
Development projects get twice the result with half the effort, a large collection of open source STM32 driver Libraries
虚拟偶像代言产品出问题谁负责? 且听律师分析
OD-Paper【2】:Fast R-CNN
ERROR: Could not open requirements file: [Errno 2] No such file or directory: ‘requirments.txt’
Jupiter notebook shortcut key
ES Cluster in Red status: what about write & delete operations?
LNMP架构