public static int rank(int[] array, int k, int front, int rear)
{
if(front > rear)
return -1; int mid = front + (rear - front) / 2;
if(k == array[mid])
return mid;
else if(k > array[mid])
return rank(array, k, mid + 1, rear);
else
return rank(array, k, front, mid - 1);
}
相关文章
- Construct Binary Tree from Preorder and Inorder Traversal leetcode java
- 黑马程序员---Java基础---异常、File类和递归
- Leetcode: Convert sorted list to binary search tree (No. 109)
- LeetCode算法题-Prime Number of Set Bits in Binary Representation(Java实现)
- Java基础学习(六)-- 递归以及文件I/O流基础详解
- Java学习File之递归
- Java学习File之案例:递归求阶乘
- leetcode 108 Convert Sorted Array to Binary Search Tree ----- java
- 【LeetCode】108. Convert Sorted Array to Binary Search Tree 解题报告 (Java & Python)
- java中的递归方法