diff --git a/java/28_sorts/HeapSort.java b/java/28_sorts/HeapSort.java index 27840493..f25b6f29 100644 --- a/java/28_sorts/HeapSort.java +++ b/java/28_sorts/HeapSort.java @@ -71,4 +71,10 @@ private static void heapify(int[] arr, int n, int i) { } } + private static void swap(int[] arr, int i, int maxPos) { + int tmp = arr[i]; + arr[i] = arr[maxPos]; + arr[maxPos] = tmp; + } + } \ No newline at end of file