当前位置:网站首页>Sequential search, half search, block search~
Sequential search, half search, block search~
2022-07-26 05:44:00 【[email protected]】
In order to find
int Search(int a[],int n,int key){
for(int i=0;i<n;i++)
if(a[i]==key)
return i;
return 0;
}
Binary search ( The linear table is required to be orderly ,eg: Increasing , Decline )
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;
}
}
Search in blocks
// Index table definition
typedef struct{
int key; // Assume that the elements in the table are int type
int low,high; // Record the subscript of the first element and the last element in a block
}indexElem;
indexElem index[maxSize]; // Define index table
版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/207/202207260542336187.html
边栏推荐
- No EGL Display 报错解决
- 10. Regular expression matching
- [STM32 series summary] blogger's way to quickly advance STM32 in actual combat (continuous update)
- 软件测试面试题全网独家没有之一的资深测试工程师面试题集锦
- MongoDB 常用命令
- 高手是怎样炼成的?
- OD-Paper【2】:Fast R-CNN
- leetcode-aboutString
- Data warehouse construction -dim floor
- Hack The Box -SQL Injection Fundamentals Module详细讲解中文教程
猜你喜欢

Why can't lpddr completely replace DDR?

Yolov3 preparatory work

SSH Remote Management

软件测试面试题全网独家没有之一的资深测试工程师面试题集锦

Mongondb API usage

FPGA question brushing sequence detection

平衡二叉树(AVL) ~

Rocbossphp free open source light community system

MBA-day28 数的概念-练习题

NFT in the eyes of blackash: the platform is crying for slaughter, and users send money to the door
随机推荐
SQL injection
I also found excellent software and hardware projects, all open source
STL common template library
How to understand "array name is essentially an address" from the perspective of memory parsing?
The refurbishment and counterfeiting of chips have made people feel numb
Six sixths -- it's a little late and a little shallow
Mongodb tutorial Chapter 08 comparison operators
How to handle aggregate collection code
Redis持久化-AOF
如何从内存解析的角度理解“数组名实质是一个地址”?
中文文本纠错任务简介
Is it really hopeless to choose electronic engineering and be discouraged?
动态内存管理及柔性数组
解决Vagrant报错b:48:in `join‘: incompatible character encodings: GBK and UTF-8 (Encoding::Compatib
高分子物理知识点
金仓数据库 KingbaseES SQL 语言参考手册 (10. 查询和子查询)
ERROR: Could not open requirements file: [Errno 2] No such file or directory: ‘requirments.txt’
Redis publish subscription
Redis master-slave replication
二叉树的性质 ~