@@ 277-284 (lines=8) @@ | ||
274 | * @return DataStructures\Trees\Nodes\BSTNode|null the minimum node or |
|
275 | * null if the tree is empty. |
|
276 | */ |
|
277 | public function deleteMin(BinaryNodeInterface $node = null) { |
|
278 | $node = $this->getMinNode($node ?? $this->root); |
|
279 | if($node !== null) { |
|
280 | $this->_delete($node); |
|
281 | } |
|
282 | ||
283 | return $node; |
|
284 | } |
|
285 | ||
286 | /** |
|
287 | * Deletes the node with the maximum key and returns it. The most right and more bottom. |
|
@@ 293-300 (lines=8) @@ | ||
290 | * @return DataStructures\Trees\Nodes\BSTNode|null the maximum node or |
|
291 | * null if the tree is empty. |
|
292 | */ |
|
293 | public function deleteMax(BinaryNodeInterface $node = null) { |
|
294 | $node = $this->getMaxNode($node ?? $this->root); |
|
295 | if($node !== null) { |
|
296 | $this->_delete($node); |
|
297 | } |
|
298 | ||
299 | return $node; |
|
300 | } |
|
301 | ||
302 | /** |
|
303 | * Deletes the node with the maximum key and returns it. The most right and more bottom. |