Aldin-SXR

swim()

May 5th, 2020
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.18 KB | None | 0 0
  1. /* Node promotion:
  2.  * swim up a node to its correct position */
  3. private void swim(int k) {
  4.     while (k > 1 && less(k/2, k)) {     // 1
  5.         swap(k, k/2);                   // 2
  6.         k = k/2;                        // 3
  7.     }
  8. }
Advertisement
Add Comment
Please, Sign In to add comment