Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Node demotion:
- * sink down a node to its correct position */
- private void sink(int k) {
- while (2*k <= length) { // 1
- int j = 2 * k; // 2
- if (j < length && less(j, j + 1)) { // 2
- j++; // 2
- }
- if (!less(k, j)) { // 3
- break; // 3
- }
- swap(k, j); // 4
- k = j; // 5
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment