From 8b1de9300b5e48245502894f9aea1217b822abc5 Mon Sep 17 00:00:00 2001 From: TINO Date: Mon, 23 Dec 2019 18:11:22 +0300 Subject: [PATCH] BAEL - 3482 --- .../com/baeldung/algorithms/minheapmerge/MinHeap.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/minheapmerge/MinHeap.java b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/minheapmerge/MinHeap.java index 94b3abfbd6..cd6847e2bb 100644 --- a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/minheapmerge/MinHeap.java +++ b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/minheapmerge/MinHeap.java @@ -21,12 +21,12 @@ public class MinHeap { int leftNodeIndex = getLeftNodeIndex(index); int rightNodeIndex = getRightNodeIndex(index); int smallestElementIndex = index; - if (leftNodeIndex < heapNodes.length && heapNodes[leftNodeIndex].element < heapNodes[index].element) + if (leftNodeIndex < heapNodes.length && heapNodes[leftNodeIndex].element < heapNodes[index].element) { smallestElementIndex = leftNodeIndex; - - if (rightNodeIndex < heapNodes.length && heapNodes[rightNodeIndex].element < heapNodes[smallestElementIndex].element) + } + if (rightNodeIndex < heapNodes.length && heapNodes[rightNodeIndex].element < heapNodes[smallestElementIndex].element) { smallestElementIndex = rightNodeIndex; - + } if (smallestElementIndex != index) { swap(index, smallestElementIndex); heapify(smallestElementIndex);