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