We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents c9cb96c + 9b30dae commit 11ef340Copy full SHA for 11ef340
1 file changed
data-structures/binomial-heaps/BinomialHeaps.cpp
@@ -376,6 +376,10 @@ class BinomialHeap {
376
prevMin->sibling = minPtr->sibling;
377
} else if (prevMin != nullptr && minPtr->sibling == nullptr) {
378
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;
383
}
384
385
// remove parent reference from all its child
@@ -427,4 +431,4 @@ int main() {
427
431
heap1.deleteMin();
428
432
heap1.printHeap();
429
433
return 0;
430
-}
434
+}
0 commit comments