MCPcopy
hub / github.com/TheAlgorithms/Go / heapifyUp

Method heapifyUp

sort/heapsort.go:84–94  ·  view source on GitHub ↗
(i int)

Source from the content-addressed store, hash-verified

82}
83
84func (h MaxHeap) heapifyUp(i int) {
85 if i == 0 {
86 return
87 }
88 p := i / 2
89
90 if h.slice[i].More(h.slice[p]) {
91 h.swap(i, p)
92 h.heapifyUp(p)
93 }
94}
95
96func (h MaxHeap) heapifyDown(i int) {
97 heapifyDown(h.slice, h.heapSize, i, h.more, h.swap)

Callers 2

PushMethod · 0.95
UpdateMethod · 0.95

Calls 2

swapMethod · 0.95
MoreMethod · 0.65

Tested by

no test coverage detected