- 浏览: 80824 次
文章分类
最新评论
-
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 875字符编码笔记:ASCII,Unicode和UTF-8 阮一峰 ... -
How to set up a simple LRU cache using LinkedHash
2008-11-03 18:05 1231How to set up a simple LRU cach ... -
Scalability?
2008-10-07 14:07 761严格上讲,scalability还没有正式定义, 甚至有人觉得 ... -
Cray Reminiscences
2007-08-29 15:54 744Kirk Pepperdine's attendence of ... -
lock-free
2007-06-18 22:06 9501. http://www.ibm.com/developer ... -
解决java.lang.OutOfMemoryError: PermGen space(转帖)
2007-06-05 18:07 3105解决方案就是:在启动服务器时加上指定PermGen区域的内存大 ... -
Performance...
2007-06-05 15:11 914« I used to work for... | Mai ... -
数据仓库
2007-04-18 10:38 1051... -
Expressions Transform
2007-04-13 11:13 1325Expressions, Conversion and Eva ... -
Java cleanup code
2007-04-03 12:20 1252Java shutdown hook guarantee th ... -
Java performance tunning
2007-04-03 11:37 882http://www.javaperformancetunin ... -
Running IE from command line
2007-04-03 10:58 1058Here's a simple way you can ru ... -
Unicode and UTF8
2007-04-03 10:27 871What is Unicode? Unicode provid ... -
Daemon Thread Notes
2007-04-03 09:16 26111. 只要程式中的non-Daemon thread都結束了. ... -
How to know the main class of a jar file?
2007-04-02 15:18 965Easy. Here is an implementation ... -
The best chinese BAT tutorial(from www.boofee.net/bigfee/)
2007-03-27 11:58 1269如何创建批处理文件? 不要听了批处理文件就感到很神气 ... -
MergeSort
2007-03-23 17:26 761MergeSort is a sample solutio ... -
Graph data structure
2007-03-23 12:04 8281. adjacent matrix good for bor ... -
Functional Programming For The Rest of Us
2007-03-23 10:39 901I like connect beautiful artic ... -
Functional Programming For The Rest of Us
2007-03-23 10:24 780I like connect beautiful artic ...
相关推荐
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 -> ...
15.3 Elements of dynamic programming 378 15.4 Longest common subsequence 390 15.5 Optimal binary search trees 397 16 Greedy Algorithms 414 16.1 An activity-selection problem 16.2 Elements of the ...
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 ...
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...
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 ...
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...
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...
Functional data structures such as Semigroup, Monoid, Binary Search Tree, Linked List, Stack, and Lazy List Immutability, copy constructors, and lenses Combining FP paradigms with OOP, FRP, and POP in...
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 ...
3.3 Binary search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 4 Data structures 35 4.1 Dynamic arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 4.2 Set ...
5.2. Search order for the configuration file 5.3. The configuration interface 'textconfig' 5.3.1. The start menu 5.3.2. The Bochs headerbar 5.3.3. The runtime configuration 5.4. Pre-defined CPU models...
I Basics 1 1 Introduction 3 1.1 Uncertainty in Robotics 3 1.2 Probabilistic Robotics 4 1.3 Implications 9 1.4 Road Map 10 1.5 Teaching Probabilistic Robotics 11 1.6 Bibliographical Remarks 11 2 ...