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