From 46a8536ff8a043a33bef9216e5039585e9a83ec2 Mon Sep 17 00:00:00 2001 From: Terry Kwan Date: Fri, 19 Jan 2024 13:25:50 +0100 Subject: [PATCH] Terry: modi of methods --- TerryModi/RBTree.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/TerryModi/RBTree.java b/TerryModi/RBTree.java index ca05b67..8c4072f 100644 --- a/TerryModi/RBTree.java +++ b/TerryModi/RBTree.java @@ -29,7 +29,7 @@ class RBTree> { Node parent = null; // Traverse the tree to the left or right depending on the key, - // finding a correct postion for the insertion of nodes later + keep the structure of the tree + // finding a correct position for the insertion of nodes later + keep the structure of the tree while (node != null) { parent = node; if (key.compareTo(node.key) < 0) { // key < node.key @@ -165,9 +165,6 @@ class RBTree> { throw new IllegalStateException("Node is not a child of its parent"); } - if (rightChild != null) { - rightChild.parent = parent; - } RootBlack(); @@ -197,10 +194,6 @@ class RBTree> { throw new IllegalStateException("Node is not a child of its parent"); } - if (leftChild != null) { - leftChild.parent = parent; - } - RootBlack(); return leftChild;