Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. private void percolateDown(int hole)
  2.     {
  3.         int child;
  4.         T tmp = array[hole];
  5.  
  6.         for( ; d*(hole-1)+2 <= currentSize; hole = child )
  7.         {
  8.             child = d*(hole-1)+2;
  9.  
  10.             int smallest = 0;
  11.             for(int i = 1; i < d; i++)
  12.                 if(child != currentSize && array[child+i].compareTo(array[child]) < 0)
  13.                     smallest = i;
  14.                    
  15.             child += smallest;
  16.                
  17.             if(array[child].compareTo(tmp) < 0)
  18.                 array[hole] = array[child];
  19.             else
  20.                 break;
  21.         }
  22.         array[hole] = tmp;
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement