|
@@ 212-219 (lines=8) @@
|
| 209 |
|
* @return DataStructures\Trees\Nodes\BSTNode|null the minimum node or |
| 210 |
|
* null if the tree is empty. |
| 211 |
|
*/ |
| 212 |
|
public function deleteMin(BinaryNodeInterface $node = null) { |
| 213 |
|
$node = $this->getMinNode($node ?? $this->root); |
| 214 |
|
if($node !== null) { |
| 215 |
|
$this->_delete($node); |
| 216 |
|
} |
| 217 |
|
|
| 218 |
|
return $node; |
| 219 |
|
} |
| 220 |
|
|
| 221 |
|
/** |
| 222 |
|
* Deletes the node with the maximum key and returns it. The most right and more bottom. |
|
@@ 228-235 (lines=8) @@
|
| 225 |
|
* @return DataStructures\Trees\Nodes\BSTNode|null the maximum node or |
| 226 |
|
* null if the tree is empty. |
| 227 |
|
*/ |
| 228 |
|
public function deleteMax(BinaryNodeInterface $node = null) { |
| 229 |
|
$node = $this->getMaxNode($node ?? $this->root); |
| 230 |
|
if($node !== null) { |
| 231 |
|
$this->_delete($node); |
| 232 |
|
} |
| 233 |
|
|
| 234 |
|
return $node; |
| 235 |
|
} |
| 236 |
|
|
| 237 |
|
/** |
| 238 |
|
* Deletes the selected node if is not null and returns the node |