daily pastebin goal
47%
SHARE
TWEET

Untitled

a guest Oct 12th, 2017 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private void updateHeap(int i) {
  2.         int left = 2 * i+1;
  3.         int right = 2 * i + 2;
  4.         int max = i;
  5.         if (left < size && vector[left] > vector[i]) {
  6.             max = left;
  7.         }
  8.         if (right < size && vector[right] > vector[max]) {
  9.             max = right;
  10.         }
  11.         if (max != i) {
  12.             swap(vector, i, max);
  13.             updateHeap(max);
  14.         }
  15.     }
RAW Paste Data
Top