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) {
39
39
* @param index
40
40
*/
41
41
public void minHeapify (int index ) {
42
- int smallest = index ;
42
+ int minIndex = index ;
43
43
int leftIndex = 2 * index + 1 ;
44
44
int rightIndex = 2 * index + 2 ;
45
45
46
46
if (leftIndex < size && heap [index ] > heap [leftIndex ]) {
47
- smallest = leftIndex ;
47
+ minIndex = leftIndex ;
48
48
}
49
- if (rightIndex < size && heap [smallest ] > heap [rightIndex ]) {
50
- smallest = rightIndex ;
49
+ if (rightIndex < size && heap [minIndex ] > heap [rightIndex ]) {
50
+ minIndex = rightIndex ;
51
51
}
52
52
53
- if (smallest != index ) {
54
- swap (index , smallest );
55
- minHeapify (smallest );
53
+ if (minIndex != index ) {
54
+ swap (index , minIndex );
55
+ minHeapify (minIndex );
56
56
}
57
57
}
58
58
You can’t perform that action at this time.
0 commit comments