进阶版入口
递归处理的核心算法(加入·deep是为理解算法):
import edu.princeton.cs.algs4.*;
public class Main{
public static int rank(int key,int[] a)
{
int deep = 0;
return rank(key,a,0,a.length - 1,deep);
}
public static int rank(int key,int[] a,int lo,int hi,int deep)
{
if(lo > hi) return -1;
int mid = lo + (hi - lo) / 2;
if(a[mid] > key)
{
StdOut.printf("deep: %d lo: %d hi: %d\n",deep,lo,hi);
++deep;
return rank(key,a,lo,mid - 1,deep);
}
else