Skip to content

Commit 11ef340

Browse files
authored
Merge pull request #10 from AfnanCSE98/patch-1
Add two missing cases in delMin BinomialHeaps.cpp
2 parents c9cb96c + 9b30dae commit 11ef340

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

data-structures/binomial-heaps/BinomialHeaps.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,10 @@ class BinomialHeap {
376376
prevMin->sibling = minPtr->sibling;
377377
} else if (prevMin != nullptr && minPtr->sibling == nullptr) {
378378
prevMin->sibling = nullptr;
379+
}else if(prevMin == nullptr and minPtr->sibling != nullptr) {
380+
head = minPtr->sibling;
381+
}else if(prevMin == nullptr and minPtr->sibling == nullptr) {
382+
head = nullptr;
379383
}
380384

381385
// remove parent reference from all its child
@@ -427,4 +431,4 @@ int main() {
427431
heap1.deleteMin();
428432
heap1.printHeap();
429433
return 0;
430-
}
434+
}

0 commit comments

Comments
 (0)