JAVA-25491 better variable naming AVL Tree insert method

This commit is contained in:
kasramp 2023-10-30 21:42:36 +01:00
parent e984098398
commit d5c1b161bb
1 changed files with 7 additions and 7 deletions

View File

@ -42,17 +42,17 @@ public class AVLTree {
return root == null ? -1 : root.height; return root == null ? -1 : root.height;
} }
private Node insert(Node node, int key) { private Node insert(Node root, int key) {
if (node == null) { if (root == null) {
return new Node(key); return new Node(key);
} else if (node.key > key) { } else if (root.key > key) {
node.left = insert(node.left, key); root.left = insert(root.left, key);
} else if (node.key < key) { } else if (root.key < key) {
node.right = insert(node.right, key); root.right = insert(root.right, key);
} else { } else {
throw new RuntimeException("duplicate Key!"); throw new RuntimeException("duplicate Key!");
} }
return rebalance(node); return rebalance(root);
} }
private Node delete(Node node, int key) { private Node delete(Node node, int key) {