| @@ 194-204 (lines=11) @@ | ||
| 191 | * @param DataStructures\Trees\Nodes\BSTNode $node the start point. | |
| 192 | * @return DataStructures\Trees\Nodes\BSTNode|null the minimum node. | |
| 193 | */ | |
| 194 |     private function getMinNode(BinaryNodeInterface $node = null) { | |
| 195 |         if($node === null) { | |
| 196 | return null; | |
| 197 | } | |
| 198 | ||
| 199 |         while($node->left !== null) { | |
| 200 | $node = $node->left; | |
| 201 | } | |
| 202 | ||
| 203 | return $node; | |
| 204 | } | |
| 205 | ||
| 206 | /** | |
| 207 | * Returns the maximum node from a given node in position X. | |
| @@ 212-222 (lines=11) @@ | ||
| 209 | * @param DataStructures\Trees\Nodes\BSTNode $node the start point. | |
| 210 | * @return DataStructures\Trees\Nodes\BSTNode|null the maximum node. | |
| 211 | */ | |
| 212 |     private function getMaxNode(BinaryNodeInterface $node = null) { | |
| 213 |         if($node === null) { | |
| 214 | return null; | |
| 215 | } | |
| 216 | ||
| 217 |         while($node->right !== null) { | |
| 218 | $node = $node->right; | |
| 219 | } | |
| 220 | ||
| 221 | return $node; | |
| 222 | } | |
| 223 | ||
| 224 | /** | |
| 225 | * Deletes the node with the minimum key and returns it. The most left and more bottom. | |