Skip to content

Commit 5b10103

Browse files
committed
minor typo error fixed in Heap
1 parent 247719d commit 5b10103

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Heaps/Heap.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public Heap() {
1616
}
1717

1818
// Default as maxheap
19-
// pass Comparator for min Heap
19+
// pass Comparator for min Heap
2020
// pass Comparator.reverseOrder() for min heap
2121
public Heap(Comparator<T> comparator) {
2222
this.comparator = comparator;
@@ -27,6 +27,7 @@ public Heap(Comparator<T> comparator) {
2727
public boolean add(T val) {
2828
return offer(val);
2929
}
30+
3031
private Comparator<T> comparator = (o1, o2) -> {
3132
return o1.compareTo(o2);
3233
};
@@ -59,7 +60,7 @@ public T poll() {
5960
list.set(1, t);
6061
int i = 1;
6162
while (i < index) {
62-
int maxIndex = i, left = 28, right = (2 * i) + 1;
63+
int maxIndex = i, left = 2 * i, right = (2 * i) + 1;
6364
if (left < index && comparator.compare(list.get(i), list.get(left)) > 0) {
6465
maxIndex = left;
6566
}

0 commit comments

Comments
 (0)