Sfoglia il codice sorgente

initial foray into fixing Delete

Natalie Pueyo 8 anni fa
parent
commit
01de7a1e06
1 ha cambiato i file con 2 aggiunte e 1 eliminazioni
  1. 2 1
      program3/AVLCommands.cpp

+ 2 - 1
program3/AVLCommands.cpp

@@ -285,13 +285,14 @@ bool AVLCommands::Delete(int key) {
 				parent->ReplaceChild(currentNode, currentNode->left_);
 				size_--; assert(size_ >= 0);
 			} else {
-				currentNode->key_ = DeleteMin(currentNode);
+				currentNode->key_ = DeleteMin(currentNode->right_);
 			}
 		}
 		currentNode = (key < currentNode->key_) ?
 			currentNode->left_ : currentNode->right_;
 	}
 
+	//std::cout << "hi" << std::endl;
 	height(root_);
 	balance(currentNode);