Guest User

Untitled

a guest
Jan 13th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. int *heap = new int[size];
  2. heap[0] = index[0];
  3. for(int i = 1; i < size; i++)
  4. {
  5. heap[i] = index[i];
  6. // Compare to the parent
  7. for (int j = i; j > 0; j >>= 1)
  8. if (customers[heap[(j - 1) >> 1]] < customers[heap[j]])
  9. { // Swap
  10. /*
  11. heap[j] ^= heap[(j - 1) >> 1];
  12. heap[(j - 1) >> 1] ^= heap[j];
  13. heap[j] ^= heap[(j - 1) >> 1];
  14. */
  15. int temp = heap[(j - 1) >> 1];
  16. heap[(j - 1) >> 1] = heap[j];
  17. heap[j] = temp;
  18. }
  19. else
  20. break;
  21. }
Add Comment
Please, Sign In to add comment