- 浏览: 84879 次
文章分类
最新评论
-
bailangfei3344:
自我介绍 -
regionwar:
你好,转化为人为:1、不该加锁的不要加锁:局部变量,单线程占用 ...
关于java锁机制的优化 -
danni505:
希望能交流:
msn:danni-505#hotmail.co ...
关于java锁机制的优化 -
ouspec:
收藏的东西不错。
TOP500 -
willpower:
The idea behind is e-sync IO do ...
Rethink the sync
java 代码
- public class BinarySearch {
- public static int search(int element, int[] sortedArray) {
- int length = sortedArray.length;
- int left = 0;
- int right = length - 1;
- while (left <= right) {
- int mid = (left + right) / 2;
- if (sortedArray[mid]==element) {
- return mid;
- } else if (sortedArray[mid] > element) {
- right = mid - 1;
- } else {
- left = mid + 1;
- }
- }
- return -1;
- }
- public static void main(String[] args) {
- int[] array = {1, 2, 3, 4, 5, 6, 7};
- System.out.println(search(2, array));
- }
- }
发表评论
-
字符编码笔记:ASCII,Unicode和UTF-8 (引用)
2009-01-07 10:39 924字符编码笔记:ASCII,Unicode和UTF-8 阮一峰 ... -
How to set up a simple LRU cache using LinkedHash
2008-11-03 18:05 1278How to set up a simple LRU cach ... -
Scalability?
2008-10-07 14:07 825严格上讲,scalability还没有正式定义, 甚至有人觉得 ... -
Cray Reminiscences
2007-08-29 15:54 790Kirk Pepperdine's attendence of ... -
lock-free
2007-06-18 22:06 9891. http://www.ibm.com/developer ... -
解决java.lang.OutOfMemoryError: PermGen space(转帖)
2007-06-05 18:07 3159解决方案就是:在启动服务器时加上指定PermGen区域的内存大 ... -
Performance...
2007-06-05 15:11 978« I used to work for... | Mai ... -
数据仓库
2007-04-18 10:38 1116... -
Expressions Transform
2007-04-13 11:13 1385Expressions, Conversion and Eva ... -
Java cleanup code
2007-04-03 12:20 1291Java shutdown hook guarantee th ... -
Java performance tunning
2007-04-03 11:37 936http://www.javaperformancetunin ... -
Running IE from command line
2007-04-03 10:58 1109Here's a simple way you can ru ... -
Unicode and UTF8
2007-04-03 10:27 907What is Unicode? Unicode provid ... -
Daemon Thread Notes
2007-04-03 09:16 26491. 只要程式中的non-Daemon thread都結束了. ... -
How to know the main class of a jar file?
2007-04-02 15:18 1027Easy. Here is an implementation ... -
The best chinese BAT tutorial(from www.boofee.net/bigfee/)
2007-03-27 11:58 1329如何创建批处理文件? 不要听了批处理文件就感到很神气 ... -
MergeSort
2007-03-23 17:26 835MergeSort is a sample solutio ... -
Graph data structure
2007-03-23 12:04 8721. adjacent matrix good for bor ... -
Functional Programming For The Rest of Us
2007-03-23 10:39 1284I like connect beautiful artic ... -
Functional Programming For The Rest of Us
2007-03-23 10:24 1062I like connect beautiful artic ...
相关推荐
算法与数据结构-综合提升 C++版 资源列表: 00-0pening 01-Why-Algorithms 02-Sorting-Basic ...05-Binary-Search-Tree 06-Union-Find 07-Graph-Basics08-Minimum-Span-Trees 09-Shortest-Path 10-Ending
- Binary Search(二分查找) - Math(数学算法) - Greatest Common Divisor(最大公约数) - Prime(质数检测) - Knapsack(背包问题) - Probability(概率问题) - **Basics Misc**(其他基础知识) - ...
17. Binary Search 18. Interpolation Search 19. Hash Table SORTING TECHNIQUES 20. Sorting Algorithm 21. Bubble Sort Algorithm 22. Insertion Sort 23. Selection Sort 24. Merge Sort Algorithm 25. Shell ...
Recursion -> Linked list -> Stack -> Queue -> Two pointers -> Sliding-window -> hashing -> sorting -> binary search -> trees -> BST -> Heaps -> Graph basics -> BFS -> DFS -> backtracking -> greedy -> ...
12.4 Randomly built binary search trees 299 13 Red-Black Trees 308 13.1 Properties of red-black trees 308 13.2 Rotations 312 13.3 Insertion 315 13.4 Deletion 323 14 Augmenting Data Structures 339 14.1...
Finally, we will round off by learning how to differentiate between various searching and sorting algorithms such as sequential search, binary search, quick sort, bubble sort, and so on, and how to ...
Use binary search, sorting, and efficient sorting—quicksort and merge sort Work with the important concept of trees and list all nodes of the tree, traversal of tree, search trees, and balanced ...
Debugging and Optimization Code Reviews Serial Debugging Going Through the Output Interactive Debuggers Debugging a Binary Search Interactive Debugging Tips and Tricks Runtime Errors Optimization How...
- **二分搜索(Binary Search)**: 在有序数组中查找特定元素的搜索算法。 #### 数学基础 - **数学(Math)**: 研究数和数量、空间以及它们之间的关系。 - **质数(Prime)**: 只有1和它本身两个正因数的大于1的自然数。 ...
Make use of functional data structures such as semigroup, monoid, binary search tree, linked list, stack, and lazy list Understand the importance of immutability, copy constructors, and lenses Develop...
Make use of functional data structures such as semigroup, monoid, binary search tree, linked list, stack, and lazy list Understand the importance of immutability, copy constructors, and lenses Develop...
- 二分搜索(Binary Search):在有序数组中查找目标值。 3. 数据结构 - 并查集(Disjoint Set Union):用于处理一些不相交集合的合并及查询问题。 - 最小生成树(Prim):一种用来寻找图的最小生成树的算法。 - ...
- **二叉搜索树与平衡树**(Binary Search Tree and Balanced Trees):第5.Bst章节深入探讨了二叉搜索树(Binary Search Tree, BST)以及几种常见的平衡树(Balanced Tree),例如AVL树、伸展树(Splay Tree)、B树、红黑...
Follow the instructions on this page: http://developer.android.com/training/basics/firstapp/ Copy all the JAR files into the app/libs subdirectory. Navigate to File > Project Structure > app > ...
Users must have msxml.dll version 2.0 for binary compatibility.<END><br>46 , CustEditXML.zip Complete VB application that retrieves customer information from an XML script, allows you to make ...
- **Binary and Text Files**: Discussion of binary and text file formats and their implications on file I/O operations. **Programming Project 17.10**: This project likely involves reading from and ...
3.3 Binary search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 4 Data structures 35 4.1 Dynamic arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 4.2 Set ...