数组折半查找
来源:互联网 发布:胖熊数据库微博 编辑:程序博客网 时间:2024/06/08 02:44
折半查找必须是已经排序好的数组
public static void main(String[] args) {
int[] aa = {1,2,3,4};int num = 6;
int start = 0;
int end = aa.length - 1;
int middel = (start+end)/2;
while(end >= start){
if(num == aa[middel]){
System.out.println(middel);
return;
}else if(num > aa[middel]){
start = middel + 1;
}else if(num < aa[middel]){
end = middel -1;
}
middel = (start+end)/2;
}
System.out.println("查无次数");
//系统自动的查找方法
int ww = Arrays.binarySearch(aa, 1);
} 2 0
- 数组的折半查找
- 数组--折半查找
- 数组折半查找
- 有序数组的折半查找
- 字符串数组的折半查找
- [JAVA]数组的折半查找
- java数组(折半查找)
- 无序数组的“折半查找”
- 数组的折半查找操作
- 数组(七)--折半查找
- 数组元素的查找(折半查找)
- 数组中普通查找和折半查找
- 数组的排序,反转,折半查找,插入
- 有序数组---折半查找(2012.2.16)
- java数组操作2.折半查找
- 折半法查找数组中的一个数
- [源码]排序数组二分法(折半)查找
- 数组_例题:折半查找法
- JSTL表达式取整,<fmt:formatNumber>标签
- HDU 1242 Rescue(dfs)
- TwoSum解题
- 计算机网络学习笔记day2
- 树莓派Pi3+Qt5.3.2安装PyQt5
- 数组折半查找
- Android Studio error: Cannot start internal HTTP server && Gradle sync failed
- 划分数组问题
- linux 下nginx php 配置
- Android Loading Dialiog
- 【Unity&JSON】datapath和persistentDataPath文件路径的两种路径地址
- 欢迎使用CSDN-markdown编辑器
- android--设置TextView部分文字的颜色和背景(高亮显示)
- 华为SD-DC²架构, 聚焦数据中心云化