package Chapter01.Section01;

public class Exercise22
{
    public static void main(String[] args)
    {
        
    }

    public static int rank(int key, int[] a)
    {   return rank(key, a, 0, a.length - 1);   }

    public static int rank(int key, int[] a, int lo, int hi)
    {   // Index of key in a[], if present, is not smaller than lo
        //                                  and not larger than hi
        if (lo > hi) return -1;
        int mid = lo + (hi - lo) / 2;
        if      (key < a[mid]) return rank(key, a, lo, mid - 1);
        else if (key > a[mid]) return rank(key, a, mid + 1, hi);
        else                   return mid;
    }
}

@@ -106,16 +106,366 @@
         
+int%5B%5D array = initialize(10000);%0A        int key = 4653;%0A        System.out.println(%22Rank of %22 + key + %22 is %22 + rank(key, array));%0A    %7D%0A%0A    public static int%5B%5D initialize(int numValues)%0A    %7B%0A        int%5B%5D array = new int%5BnumValues%5D;%0A        for(int i = 0; i %3C array.length; i++)%0A        %7B%0A            array%5Bi%5D = i;%0A        %7D%0A%0A        return array;
 %0A    %7D%0A%0A
@@ -552,16 +552,19 @@
 ngth - 1
+, 0
 );   %7D%0A%0A
@@ -622,16 +622,27 @@
 , int hi
+, int depth
 )%0A    %7B 
@@ -769,16 +769,198 @@
 than hi%0A
+        String indents = %22%22;%0A        for(int i = 0; i %3C depth; i++)%0A        %7B%0A            indents = indents + %22  %22;%0A        %7D%0A%0A        System.out.println(indents + lo + %22 %22  + hi);%0A%0A
         
@@ -1081,16 +1081,27 @@
 o, mid -
+ 1, depth +
  1);%0A   
@@ -1159,16 +1159,27 @@
  + 1, hi
+, depth + 1
 );%0A     

Solved 1.1.22