|
@@ 244-254 (lines=11) @@
|
| 241 |
|
* @param DataStructures\Trees\Nodes\BinaryNodeInterface $node the start point. |
| 242 |
|
* @return DataStructures\Trees\Nodes\BinaryNodeInterface|null the minimum node. |
| 243 |
|
*/ |
| 244 |
|
protected function getMinNode(BinaryNodeInterface $node = null) { |
| 245 |
|
if($node === null) { |
| 246 |
|
return null; |
| 247 |
|
} |
| 248 |
|
|
| 249 |
|
while($node->left !== null) { |
| 250 |
|
$node = $node->left; |
| 251 |
|
} |
| 252 |
|
|
| 253 |
|
return $node; |
| 254 |
|
} |
| 255 |
|
|
| 256 |
|
/** |
| 257 |
|
* Returns the maximum node from a given node in position X. |
|
@@ 262-272 (lines=11) @@
|
| 259 |
|
* @param DataStructures\Trees\Nodes\BinaryNodeInterface $node the start point. |
| 260 |
|
* @return DataStructures\Trees\Nodes\BinaryNodeInterface|null the maximum node. |
| 261 |
|
*/ |
| 262 |
|
protected function getMaxNode(BinaryNodeInterface $node = null) { |
| 263 |
|
if($node === null) { |
| 264 |
|
return null; |
| 265 |
|
} |
| 266 |
|
|
| 267 |
|
while($node->right !== null) { |
| 268 |
|
$node = $node->right; |
| 269 |
|
} |
| 270 |
|
|
| 271 |
|
return $node; |
| 272 |
|
} |
| 273 |
|
|
| 274 |
|
/** |
| 275 |
|
* Deletes the node with the minimum key and returns it. The most left and more bottom. |