二分查找
来源:互联网 发布:用友u8数据库修复工具 编辑:程序博客网 时间:2024/05/16 02:02
public class binarySearch {public int find(long searchKey) {int [] a = {9,8,7,6,5,4,3,2,1};int nElems = 9;int lowerBound = 0;int upperBound = nElems - 1;int curIn;while(true) {curIn = (lowerBound + upperBound);if (a[curIn] == searchKey) {return curIn;}else if (lowerBound > upperBound) {return -1;} else {if (a[curIn] > searchKey)curIn = lowerBound + 1;elsecurIn = upperBound - 1;}}}}
0 0
- 二分查找
- 二分查找
- 二分查找
- 二分查找
- 二分查找
- 二分查找
- 二分查找
- 二分查找
- 二分查找
- 二分查找
- 二分查找
- 二分查找
- 二分查找
- 二分查找
- 二分查找
- 二分查找
- 二分查找
- 二分查找
- ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]
- android开发中关于PendingIntent的知识点
- Linux -Qt 开发环境搭建
- 解读Unity中的CG编写Shader系列1——初识CG
- handler底层是如何将消息从子线程发送到主线程
- 二分查找
- Xcode6中添加pch文件
- BaseService.java(Service业务层基类)
- 数据库性能之索引
- c语言正则表达式应用
- c++中vector的用法
- IBM 地板负载计算
- Maven实战 第2章 Maven的安装和配置gai
- Python函数模块创建、发布和使用