File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
src/main/java/com/rampatra/common Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -39,20 +39,20 @@ public MinHeap(int[] heap) {
3939 * @param index
4040 */
4141 public void minHeapify (int index ) {
42- int smallest = index ;
42+ int minIndex = index ;
4343 int leftIndex = 2 * index + 1 ;
4444 int rightIndex = 2 * index + 2 ;
4545
4646 if (leftIndex < size && heap [index ] > heap [leftIndex ]) {
47- smallest = leftIndex ;
47+ minIndex = leftIndex ;
4848 }
49- if (rightIndex < size && heap [smallest ] > heap [rightIndex ]) {
50- smallest = rightIndex ;
49+ if (rightIndex < size && heap [minIndex ] > heap [rightIndex ]) {
50+ minIndex = rightIndex ;
5151 }
5252
53- if (smallest != index ) {
54- swap (index , smallest );
55- minHeapify (smallest );
53+ if (minIndex != index ) {
54+ swap (index , minIndex );
55+ minHeapify (minIndex );
5656 }
5757 }
5858
You can’t perform that action at this time.
0 commit comments