Skip to content

Commit 42e2dec

Browse files
committed
updated comment
1 parent 3181b52 commit 42e2dec

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app/lib/search/heap.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ class _Heap<T> {
5454

5555
/// Builds a sorted list of the top-k items using the provided comparator.
5656
///
57-
/// The algorithm uses min-heap to select the top-k items, and then builds
58-
/// a max-heap and uses heap sort to return the items in descending order.
57+
/// The algorithm collects all items, builds a max-heap in O(N) steps, and
58+
/// then selects the top-k items by removing the largest item from the heap
59+
/// and restoring the heap property again in O(k * log(N)) steps.
5960
class TopKSortedListBuilder<T> {
6061
final int _k;
6162
final _Heap<T> _heap;

0 commit comments

Comments
 (0)