Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 39be70c

Browse files
refactoring
1 parent e781e38 commit 39be70c

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

‎src/main/java/ir/sk/adt/datastructure/tree/binarytree/heaptree/MaxBinaryHeap.java‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,19 @@ public int extractMax() {
108108
public void heapifyDown(int index) {
109109
int left = getLeftChildIndex(index);
110110
int right = getRightChildIndex(index);
111-
int max;
111+
int maxIndex;
112112

113113
if (left <= size && array[left] > array[index])
114-
max = left;
114+
maxIndex = left;
115115
else
116-
max = index;
116+
maxIndex = index;
117117

118-
if (right <= size && array[right] > array[max])
119-
max = right;
118+
if (right <= size && array[right] > array[maxIndex])
119+
maxIndex = right;
120120

121-
if (max != index) {
122-
swap(index, max);
123-
heapifyDown(max);
121+
if (maxIndex != index) {
122+
swap(index, maxIndex);
123+
heapifyDown(maxIndex);
124124
}
125125
}
126126

1.55 MB
Loading[フレーム]
1.25 MB
Loading[フレーム]
1.56 MB
Loading[フレーム]
1.98 MB
Loading[フレーム]
1.92 MB
Loading[フレーム]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /