Beispiel #1
0
func HeapSort(a []int) []int {
	h := heap.NewHeap()
	for i := 0; i < len(a); i++ {
		h.Insert(MyInt(a[i]))
	}
	i := 0
	for !h.IsEmpty() {
		a[i] = int(h.Extract().(MyInt))
		i++
	}
	return a
}
Beispiel #2
0
func NewPQ() *PQ {
	return &PQ{
		data: heap.NewHeap(),
	}
}