当前位置:网站首页>顺序查找,折半查找,分块查找 ~
顺序查找,折半查找,分块查找 ~
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]; //定义索引表
边栏推荐
- [论文笔记] 面向网络语音隐写的抗分组丢失联合编码
- Jupiter notebook shortcut key
- 高分子物理试题库
- How students apply for free idea
- 102. (cesium chapter) cesium road streamer
- Development to testing: a six-year road to automation from scratch
- [personal summary] end of July 24, 2022
- Lamp architecture
- Redis publish subscription
- TZC 1283: simple sort - select sort
猜你喜欢

Is it really hopeless to choose electronic engineering and be discouraged?
![[STM32 series summary] blogger's way to quickly advance STM32 in actual combat (continuous update)](/img/20/bf7d2653aafd35e6588f819d110453.png)
[STM32 series summary] blogger's way to quickly advance STM32 in actual combat (continuous update)

No background, no education? Is it really hopeless for specialist testers to enter Internet factories?

Redis publish subscription

Application of canoe XML in test modules

leetcode-Array

Why can't lpddr completely replace DDR?

Hack the box - Web requests module detailed Chinese tutorial

The idea YML file code does not prompt the solution

Hack The Box -SQL Injection Fundamentals Module详细讲解中文教程
随机推荐
选电子工程被劝退,真的没前景了?
Rocbossphp free open source light community system
Do you really understand fiddler, a necessary tool for testing?
代码审计之百家cms
Attack and defense world -- easy_ web
Embedded general learning route arrangement
MongoDB 常用命令
如何查看Pod里容器名称
Application and value of IVR in VoIP telephone system
Redis persistence RDB
DOM operation -- operation node
102. (cesium chapter) cesium road streamer
How students apply for free idea
520 for what? DIY is a high-value RGB clock that girls want to watch
SIP账号注册的SIP软电话的使用和常见问题
No EGL Display 报错解决
SSH Remote Management
MongonDB API使用
Code audit CMS
How are masters refined?