Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void updateHeap(int i) {
- int left = 2 * i+1;
- int right = 2 * i + 2;
- int max = i;
- if (left < size && vector[left] > vector[i]) {
- max = left;
- }
- if (right < size && vector[right] > vector[max]) {
- max = right;
- }
- if (max != i) {
- swap(vector, i, max);
- updateHeap(max);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement