Skip to content

Commit 954fc39

Browse files
Fixing empty and root delete (#10)
#4
1 parent a2d8912 commit 954fc39

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

remove.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void BPTree::removeKey(int x) {
4848

4949
auto itr = lower_bound(cursor->keys.begin(), cursor->keys.end(), x);
5050

51-
if (itr == cursor->keys.end()) {
51+
if (found == false) {
5252
cout << "Key Not Found in the Tree" << endl;
5353
return;
5454
}
@@ -83,7 +83,7 @@ void BPTree::removeKey(int x) {
8383
}
8484

8585
cout << "Deleted " << x << " From Leaf Node successfully" << endl;
86-
if (cursor->keys.size() >= (getMaxLeafNodeLimit()+1) / 2) {
86+
if ((cursor->keys.size() >= (getMaxLeafNodeLimit() + 1) / 2) || (cursor == root)) {
8787
//Sufficient Node available for invariant to hold
8888
return;
8989
}

0 commit comments

Comments
 (0)