当前位置:网站首页>Half search method
Half search method
2022-06-23 03:44:00 【@Landscape post yuan】
Binary search
The split search depends on the sequential table structure , In short, it's an array .
• Binary search is for ordered data .
• The amount of data is too small for binary search .
• Too much data is not suitable for binary search .
/* fold And a half check look for */
int Binary_Search (int *a, int n, int key ){
int low , high , mid ;
/* set The righteous most low Next mark by remember record The first position */
low = 1;
/* set The righteous most high Next mark by remember record At the end of the position */
high = n;
while (low <= high ) {
/* fold And a half */
mid = ( low + high ) / 2;
/* if check look for value Than in value Small */
if (key < a[mid ])
/* most high Next mark transfer whole To in position Next mark Small One position */
high = mid - 1;
/* if check look for value Than in value Big */
else if (key > a[mid ])
/* most low Next mark transfer whole To in position Next mark Big One position */
low = mid + 1;
else
/* if phase etc. be say bright mid namely by check look for To Of position Set up */
return mid ;
}
return 0;
}边栏推荐
- 【二分】leetcode1011. Capacity To Ship Packages Within D Days
- mysql常用指令
- Frequent actions to expand the scale of new energy industry Guangzhou plans to invest 1.4 billion in photovoltaic power generation projects
- pyspark,有偿询问数据清洗和上传到数据库的问题
- Parsing the implementation of easygbs compatible token as parameter passing
- 【曾书格激光SLAM笔记】Gmapping基于滤波器的SLAM
- What if the self incrementing IDs of online MySQL are exhausted?
- Postman calls relevant interfaces of CLS API 3.0
- Form submit onclick and onsubmit
- 新版kali切换最高账户
猜你喜欢

Analysis on the development of China's satellite navigation industry chain in 2021: satellite navigation is fully integrated into production and life, and the satellite navigation industry is also boo

Svn local computer storage configuration

【贪心】leetcode991. Broken Calculator

Analysis on the development of China's graphene industry chain in 2021: with the support of energy conservation and environmental protection policies, the scale of graphene industry will continue to e

【机器学习】 吴恩达机器学习作业 ex2逻辑回归 Matlab实现

mysql 数据恢复 (.ibdata1, bin log)
![[machine learning] wuenda's machine learning assignment ex2 logistic regression matlab implementation](/img/eb/0d4caf0babbe14f51f4dbf1b9ae65d.png)
[machine learning] wuenda's machine learning assignment ex2 logistic regression matlab implementation
![Analysis of China's integrated circuit industry chain in 2021: huge downstream market demand [figure]](/img/de/d73805aaf4345ca3d2a7baf85aab8d.jpg)
Analysis of China's integrated circuit industry chain in 2021: huge downstream market demand [figure]
![[quick view] Analysis on the development status and future development trend of the global and Chinese diamond cultivation industry in 2021 [figure]](/img/f1/972a760459a6d599b5681aa634df09.jpg)
[quick view] Analysis on the development status and future development trend of the global and Chinese diamond cultivation industry in 2021 [figure]

Insert sort directly
随机推荐
新版kali切换最高账户
Customization of openfeign
Apicloud native module, H5 module and multi terminal component tutorial
Troubleshooting and resolution of asydss virtual live broadcast status synchronization and service downtime
[OWT] OWT client native P2P E2E test vs2017 build 3: no test unit comparison, manually generate vs projects
【二分】leetcode1011. Capacity To Ship Packages Within D Days
[burning] Tencent cloud high tech computing platform HTPC cloud elastic cluster release!
【LeetCode】179. Maximum number
What is the difference between ArrayList and array?
Analysis on the development of China's satellite navigation industry chain in 2021: satellite navigation is fully integrated into production and life, and the satellite navigation industry is also boo
How to share small programs released by wechat
【LeetCode】23. 合并K个升序链表
Analysis on the development prospect of China's brain computer interface industry in 2021: wide application prospect, sustained and rapid growth of market scale [figure]
Nezha panel modifies logo, small icon and other information
mysql常用指令
Analysis of China's integrated circuit industry chain in 2021: huge downstream market demand [figure]
Goframe framework: quick creation of static file download web service
Regeorg actual attack and defense
JS remove first character of string
【owt】owt-client-native-p2p-e2e-test vs2017构建 3 : 无 测试单元对比, 手动生成vs项目