|
@@ 262-269 (lines=8) @@
|
| 259 |
|
* @return DataStructures\Trees\Nodes\BSTNode|null the minimum node or |
| 260 |
|
* null if the tree is empty. |
| 261 |
|
*/ |
| 262 |
|
public function deleteMin(Node $node = null) { |
| 263 |
|
$node = $this->getMinNode($node ?? $this->root); |
| 264 |
|
if($node !== null) { |
| 265 |
|
$this->_delete($node); |
| 266 |
|
} |
| 267 |
|
|
| 268 |
|
return $node; |
| 269 |
|
} |
| 270 |
|
|
| 271 |
|
/** |
| 272 |
|
* Deletes the node with the maximum key and returns it. The most right and more bottom. |
|
@@ 278-285 (lines=8) @@
|
| 275 |
|
* @return DataStructures\Trees\Nodes\BSTNode|null the maximum node or |
| 276 |
|
* null if the tree is empty. |
| 277 |
|
*/ |
| 278 |
|
public function deleteMax(Node $node = null) { |
| 279 |
|
$node = $this->getMaxNode($node ?? $this->root); |
| 280 |
|
if($node !== null) { |
| 281 |
|
$this->_delete($node); |
| 282 |
|
} |
| 283 |
|
|
| 284 |
|
return $node; |
| 285 |
|
} |
| 286 |
|
|
| 287 |
|
/** |
| 288 |
|
* Deletes the node with the maximum key and returns it. The most right and more bottom. |