Skip to content

making code more clean and readable #5251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -190,7 +190,7 @@ private void decreaseKey(HeapNode x, int delta) {
* Potential = #trees + 2*#markedNodes
*/
public int potential() {
return numOfTrees + (2 * markedHeapNoodesCounter);
return numOfTrees + (2 * markedHeapNodesCounter);
}

/**
Expand Down Expand Up @@ -232,7 +232,7 @@ private void cascadingCuts(HeapNode curr) {
if (!curr.isMarked()) { // stop the recursion
curr.mark();
if (!curr.isRoot()) {
this.markedHeapNoodesCounter++;
this.markedHeapNodesCounter++;
}
} else {
if (curr.isRoot()) {
Expand All @@ -252,7 +252,7 @@ private void cascadingCuts(HeapNode curr) {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public MaxHeap(List<HeapElement> listElements) {
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.");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public MinHeap(List<HeapElement> listElements) {
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.");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
*/
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;
Expand Down