mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-08 05:18:40 +00:00
fix tests
This commit is contained in:
parent
ec49bf2dc1
commit
d22f0a6d18
|
|
@ -9,6 +9,7 @@
|
||||||
* @license OMS License 2.0
|
* @license OMS License 2.0
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
* @link https://jingga.app
|
* @link https://jingga.app
|
||||||
|
* @link https://github.com/PetarV-/Algorithms/blob/master/Data%20Structures/Binary%20Search%20Tree.cpp
|
||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
@ -229,19 +230,19 @@ class BinarySearchTree
|
||||||
public function delete(Node $node) : void
|
public function delete(Node $node) : void
|
||||||
{
|
{
|
||||||
if ($node->left === null && $node->right === null) {
|
if ($node->left === null && $node->right === null) {
|
||||||
if ($node->parent !== null) {
|
if ($node->parent === null) {
|
||||||
if ($node->parent->left !== null
|
return;
|
||||||
&& $node->parent->left->root?->compare($node->data) === 0
|
|
||||||
) {
|
|
||||||
$node->parent->left = null;
|
|
||||||
} elseif ($node->parent->right !== null
|
|
||||||
&& $node->parent->right->root?->compare($node->data) === 0
|
|
||||||
) {
|
|
||||||
$node->parent->right = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//$node = null;
|
if ($node->parent->left !== null
|
||||||
|
&& $node->parent->left->root?->compare($node->data) === 0
|
||||||
|
) {
|
||||||
|
$node->parent->left = null;
|
||||||
|
} elseif ($node->parent->right !== null
|
||||||
|
&& $node->parent->right->root?->compare($node->data) === 0
|
||||||
|
) {
|
||||||
|
$node->parent->right = null;
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user