Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 41d09a3

Browse files
committed
Minor refactoring
1 parent 7a6d155 commit 41d09a3

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/main/java/com/rampatra/common/MinHeap.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)