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);
}
相关文章
- 07-1985. Insert Node in a Binary Search Tree【easy】
- 07-19Convert Sorted Array to Binary Search Tree
- 07-191382. Balance a Binary Search Tree
- 07-19704. Binary Search
- 07-19【LeetCode】704. Binary Search 解题报告(Python)
- 07-19leetcode 704. Binary Search 、35. Search Insert Position 、278. First Bad Version
- 07-19[LeetCode&Python] Problem 704. Binary Search
- 07-19【Leetcode_easy】704. Binary Search
- 07-19Binary Search 的递归与迭代实现及STL中的搜索相关内容
- 07-19【LeetCode】109. Convert Sorted List to Binary Search Tree 解题报告(Python)