python 中的堆 (heapq) 是否稳定?
Is heap (heapq) in python stable?
if heapify this [(10,'Mike'),(20,'Jack'),(10,'Bob')]
和return堆的最小值,能保证return(10,'Mike') and not (10,'Bob')
吗?
没有 heapq
不稳定。如 examples of the documentation
中所述
This is similar to sorted(iterable), but unlike sorted(), this
implementation is not stable.
if heapify this [(10,'Mike'),(20,'Jack'),(10,'Bob')]
和return堆的最小值,能保证return(10,'Mike') and not (10,'Bob')
吗?
没有 heapq
不稳定。如 examples of the documentation
This is similar to sorted(iterable), but unlike sorted(), this implementation is not stable.