From 592e82818cd939389f8efe63761ab9d35b99cfd8 Mon Sep 17 00:00:00 2001 From: Yudong Jin Date: Mon, 16 Jan 2023 19:30:54 +0800 Subject: [PATCH] Update a comment in my_heap. --- codes/go/chapter_heap/my_heap.go | 2 +- codes/java/chapter_heap/my_heap.java | 2 +- docs/chapter_heap/heap.md | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/codes/go/chapter_heap/my_heap.go b/codes/go/chapter_heap/my_heap.go index cd3015f66..ab870eec0 100644 --- a/codes/go/chapter_heap/my_heap.go +++ b/codes/go/chapter_heap/my_heap.go @@ -24,7 +24,7 @@ func newHeap() *maxHeap { /* 构造函数,根据切片建堆 */ func newMaxHeap(nums []any) *maxHeap { - // 所有元素入堆 + // 将列表元素原封不动添加进堆 h := &maxHeap{data: nums} for i := len(h.data) - 1; i >= 0; i-- { // 堆化除叶结点以外的其他所有结点 diff --git a/codes/java/chapter_heap/my_heap.java b/codes/java/chapter_heap/my_heap.java index b80ce6d08..f823824e6 100644 --- a/codes/java/chapter_heap/my_heap.java +++ b/codes/java/chapter_heap/my_heap.java @@ -20,7 +20,7 @@ class MaxHeap { /* 构造函数,根据输入列表建堆 */ public MaxHeap(List nums) { - // 所有元素入堆 + // 将列表元素原封不动添加进堆 maxHeap = new ArrayList<>(nums); // 堆化除叶结点以外的其他所有结点 for (int i = parent(size() - 1); i >= 0; i--) { diff --git a/docs/chapter_heap/heap.md b/docs/chapter_heap/heap.md index e1d29fe36..21f7f533c 100644 --- a/docs/chapter_heap/heap.md +++ b/docs/chapter_heap/heap.md @@ -710,10 +710,10 @@ comments: true ```go title="my_heap.go" /* 构造函数,根据切片建堆 */ func newMaxHeap(nums []any) *maxHeap { - // 所有元素入堆 + // 将列表元素原封不动添加进堆 h := &maxHeap{data: nums} + // 堆化除叶结点以外的其他所有结点 for i := len(h.data) - 1; i >= 0; i-- { - // 堆化除叶结点以外的其他所有结点 h.siftDown(i) } return h