当前位置:网站首页>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
边栏推荐
- ERROR: Could not open requirements file: [Errno 2] No such file or directory: ‘requirments.txt’
- Unity Profiler
- Three graduates, three years of experience in embedded software
- Mongodb common commands
- 数仓搭建-DIM层
- Two auxiliary functions of integral Mall for business user operation
- Knowledge points of Polymer Physics
- YOLOV3预备工作
- Use of feign (Part 2)
- Hack The Box - Web Requests Module详细讲解中文教程
猜你喜欢
![[论文笔记] 面向网络语音隐写的抗分组丢失联合编码](/img/ca/95476b6d4b5765f5fde82cbeda577e.png)
[论文笔记] 面向网络语音隐写的抗分组丢失联合编码

我又发现了超赞的软硬件项目,全部开源
![[MySQL must know and know] time function number function string function condition judgment](/img/b2/aa15bf4cd78a3742704f6bd5ecb9c6.png)
[MySQL must know and know] time function number function string function condition judgment

Hack The Box - Introduction to Networking Module详细讲解中文教程

IVR在voip电话系统的应用与价值

Mba-day28 concept of number - exercise questions

LNMP architecture

Qt编写物联网管理平台47-通用数据库设置

满二叉树 / 真二叉树 / 完全二叉树 ~

Lemon class automatic learning after all
随机推荐
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)
10. Regular expression matching
Autumn move - Preparation Plan
高频电子线路复习考试题及答案
Jupiter notebook shortcut key
选电子工程被劝退,真的没前景了?
Redis 官方可视化工具,高颜值,功能真心强大!
MongoDB 常用命令
FTP实验及概述
Efficient, reliable and safe open source solution for serial communication
Circular structure practice
CANoe-XML在Test Modules中的应用
I also found excellent software and hardware projects, all open source
动态内存管理及柔性数组
Use of feign (Part 2)
SQL injection
MBA-day29 算术-绝对值初步认识
又一开源神器,值得收藏学习!
高分子物理试题库