I'm learning the Heap data structure and found this link
I'm expecting the output of heapq.heapify([5, 7, 9, 1, 3])
to be
[1, 3, 9, 5, 7]
However, I saw it returns this:
[1, 3, 9, 7, 5]
As some suggested that the order on the same level does not matter, then I guess I just feel confused that how does the [5,7]
in the original sequence swapped position since the order in the same level does not matter.
Could someone explain why it is like this?