title: binary quicksort
body: <p>I want to implement the Binary Quicksort algorithm from [Robert Sedgewick's book][1].  It looks like this:</p>
  
  <pre><code>    public class quickb{
  public static final int bitsword=32;
  
  public static void quicksortB(int a[],int l,int r,int d){
   int i=l;
  int j=r;
  if (r&lt;=l || d&gt;bitsword) return ;
  
   while (j!=i)
  {
  
    while (digit(a[i],d)==0 &amp;&amp; (i&lt;j)) i++;
  while (digit(a[j],d)==1 &amp;&amp; (j&gt;i)) j--;
     int t=a[i];
  a[i]=a[j];
  a[j]=t;
  }
        if (digit(a[r],d)== 0) j--;
  
    quicksortB(a,l,j-1,d+1);
   quicksortB(a,j,r,d+1);
  
  
  
  
  }
  
  public static void main(String[]args){
     int a[]=new int[]{4,7,3,9,8,2};
  
  
   quicksortB(a,0,a.length-1,0);
  
   for (int i=0;i&lt;a.length;i++){
    System.out.println(a[i]);
  }
  
  
  
  }
  
   public static int digit(int m,int d){
  
  
      return (m&gt;&gt;d)&amp;1;
  
  
  
  }
  }
  </code></pre>
  
  <p>i have changed   it compiles but result is
  4
  8
  9
  3
  7
  2
   maybe code is in correct in book can anybody help me to solve this problem?</p>