当前位置:网站首页>Binarysearch basic binary search
Binarysearch basic binary search
2022-07-25 19:35:00 【_ Doris___】



ac Implementation code :
Position BinarySearch( List L, ElementType X )
{
int left=1,right=L->Last,mid=(left+right)/2;
while(left<=right)
{
if(L->Data[mid]>X)
{
right=mid-1;
}
else if(L->Data[mid]<X)
{
left=mid+1;
}
else if(L->Data[mid]==X)
{
return mid;
}
mid=(left+right)/2;
}
return NotFound;
}details :
left<=right Cannot be less than , Otherwise, even number , After finding it in the middle , Unable to enter the loop , Leakage .
边栏推荐
猜你喜欢

Concept of IP address

AAAI 2022 | GAN的结构有“指纹”吗?从伪造图像溯源生成网络结构

安全基础4 ---正则表达式

二叉树可视化

Dynamic implementation of wechat applet 27 progress bar and static construction of search box and hot search list

高效生成接口文档好方法

前夕 - 0day威胁情报

蓝桥杯基础练习——矩阵的回形取数(C语言)

Mobile phone touch picture slider rotation plug-in photoswipe.js

Code sharing of social chat platform developed by dating website (III)
随机推荐
加州大学|用于未指定环境的可行对抗鲁棒强化学习
A high efficiency 0-delay 0-copy QT player scheme based on Hisilicon 3559
NPM semantic version control, solution console prop being mutated: "placement" error
How to analyze qiime2 after obtaining picrust2 results
SDL text display
虹科分享|如何解决勒索软件安全漏洞
How to be a self disciplined person?
919. Complete binary tree inserter
[server data recovery] a data recovery case of a brand ProLiant server raid paralysis, database file loss, and database file backup damage
网络数据包多层传输演示
AAAI 2022 | GAN的结构有“指纹”吗?从伪造图像溯源生成网络结构
[wp]ctfshow-web入门-爆破
[Detr for 3D object detection] 3detr: an end to end transformer model for 3D object detection
Basic practice of Blue Bridge Cup - shape retrieval of matrix (C language)
C# 合并集合
Talk about 11 tips for interface performance optimization
An idea of solving div adapting to screen
Flutter 小技巧之优化你使用的 BuildContext
阿姆利塔工程学院|用于情感分析的方面术语提取中优化采样的强化主动学习方法
Old wine in new bottles -- sample analysis of recent apt32 (sea Lotus) organizational attacks