From 490c23bc4cdb7bbc014b85a9f81895436788efab Mon Sep 17 00:00:00 2001 From: Leo Date: Thu, 23 Apr 2026 13:54:03 +0800 Subject: [PATCH] fix: Incorrect size calculation in the Put function of the binary heap. --- trees/binaryheap/binaryheap.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trees/binaryheap/binaryheap.go b/trees/binaryheap/binaryheap.go index 9f1605cd..f1c440f2 100644 --- a/trees/binaryheap/binaryheap.go +++ b/trees/binaryheap/binaryheap.go @@ -50,7 +50,7 @@ func (heap *Heap[T]) Push(values ...T) { for _, value := range values { heap.list.Add(value) } - size := heap.list.Size()/2 + 1 + size := heap.list.Size()/2 - 1 for i := size; i >= 0; i-- { heap.bubbleDownIndex(i) }