func (h *LeftistHeap) Init() *LeftistHeap {
h.root = &Node{} // <==== Item is nil here
return h
}
So when we first tried to insert an Item, the mergeNodes function was comparing the item of the new node with the item of the heap root wich was nil and then failed
$ go run example/leftist/leftist.go
was raising:because the Init function of leftist heap was:
So when we first tried to insert an Item, the
mergeNodes
function was comparing the item of the new node with the item of the heap root wich wasnil
and then failed