diff --git a/src/main/java/com/thealgorithms/datastructures/heaps/FibonacciHeap.java b/src/main/java/com/thealgorithms/datastructures/heaps/FibonacciHeap.java index 4734483b..d248bc33 100644 --- a/src/main/java/com/thealgorithms/datastructures/heaps/FibonacciHeap.java +++ b/src/main/java/com/thealgorithms/datastructures/heaps/FibonacciHeap.java @@ -8,7 +8,7 @@ public class FibonacciHeap { private static int totalCuts = 0; private int numOfTrees = 0; private int numOfHeapNodes = 0; - private int markedHeapNoodesCounter = 0; + private int markedHeapNodesCounter = 0; /* * a constructor for an empty Heap @@ -190,7 +190,7 @@ public class FibonacciHeap { * Potential = #trees + 2*#markedNodes */ public int potential() { - return numOfTrees + (2 * markedHeapNoodesCounter); + return numOfTrees + (2 * markedHeapNodesCounter); } /** @@ -232,7 +232,7 @@ public class FibonacciHeap { if (!curr.isMarked()) { // stop the recursion curr.mark(); if (!curr.isRoot()) { - this.markedHeapNoodesCounter++; + this.markedHeapNodesCounter++; } } else { if (curr.isRoot()) { @@ -252,7 +252,7 @@ public class FibonacciHeap { private void cut(HeapNode curr) { curr.parent.rank--; if (curr.marked) { - this.markedHeapNoodesCounter--; + this.markedHeapNodesCounter--; curr.marked = false; } if (curr.parent.child == curr) { // we should change the parent's child diff --git a/src/main/java/com/thealgorithms/datastructures/heaps/MaxHeap.java b/src/main/java/com/thealgorithms/datastructures/heaps/MaxHeap.java index 067aae73..9010aae4 100644 --- a/src/main/java/com/thealgorithms/datastructures/heaps/MaxHeap.java +++ b/src/main/java/com/thealgorithms/datastructures/heaps/MaxHeap.java @@ -22,7 +22,7 @@ public class MaxHeap implements Heap { System.out.println("Null element. Not added to heap"); } } - if (maxHeap.size() == 0) { + if (maxHeap.isEmpty()) { System.out.println("No element has been added, empty heap."); } } diff --git a/src/main/java/com/thealgorithms/datastructures/heaps/MinHeap.java b/src/main/java/com/thealgorithms/datastructures/heaps/MinHeap.java index 6e972205..46864fba 100644 --- a/src/main/java/com/thealgorithms/datastructures/heaps/MinHeap.java +++ b/src/main/java/com/thealgorithms/datastructures/heaps/MinHeap.java @@ -22,7 +22,7 @@ public class MinHeap implements Heap { System.out.println("Null element. Not added to heap"); } } - if (minHeap.size() == 0) { + if (minHeap.isEmpty()) { System.out.println("No element has been added, empty heap."); } } diff --git a/src/main/java/com/thealgorithms/datastructures/heaps/MinPriorityQueue.java b/src/main/java/com/thealgorithms/datastructures/heaps/MinPriorityQueue.java index 2ad4ed53..9d19e9aa 100644 --- a/src/main/java/com/thealgorithms/datastructures/heaps/MinPriorityQueue.java +++ b/src/main/java/com/thealgorithms/datastructures/heaps/MinPriorityQueue.java @@ -14,11 +14,11 @@ package com.thealgorithms.datastructures.heaps; */ public class MinPriorityQueue { - private int[] heap; - private int capacity; + private final int[] heap; + private final int capacity; private int size; - // calss the constructor and initializes the capacity + // class the constructor and initializes the capacity MinPriorityQueue(int c) { this.capacity = c; this.size = 0;