[Python] Does python have a built in min-heap data structure?

Discussão em 'Python' iniciado por Stack, Novembro 27, 2024.

  1. Stack

    Stack Membro Participativo

    Does python have a built in min-heap data structure in 2.7.3?

    I don't want to import code.

    I want something like

    myheap = minheap(key=lambda x: x[1])
    myheap.add(obj)
    o = myheap.pop()


    Is this possible?

    Continue reading...

Compartilhe esta Página