Skip to content

Commit f9a5dae

Browse files
committed
init heap in bulk via contructor
1 parent 35b90b5 commit f9a5dae

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/Advanced.Algorithms/Sorting/HeapSort.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ public class HeapSort<T> where T : IComparable
1414
public static T[] Sort(T[] array)
1515
{
1616
//heapify
17-
var heap = new BMinHeap<T>();
18-
foreach (var item in array)
19-
{
20-
heap.Insert(item);
21-
}
17+
var heap = new BMinHeap<T>(array);
2218

2319
//now extract min until empty and return them as sorted array
2420
var sortedArray = new T[array.Length];

0 commit comments

Comments
 (0)