Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Heap::repairDown(int index){
- int leftChildIndex = 2 * index + 1;
- int rightChildIndex = 2 * index + 2;
- if (leftChildIndex >= total) // koniec drzewa. Parametr index opisuje liΕΔ
- return;
- int minIndex = index;
- if (data[index] < data[leftChildIndex])
- {
- minIndex = leftChildIndex;
- }
- if ((rightChildIndex < total) && (data[minIndex] < data[rightChildIndex]))
- {
- minIndex = rightChildIndex;
- }
- if (minIndex != index)
- {
- swap(minIndex, index);
- repairDown(minIndex);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement