JAVA-25491 better variable naming AVL Tree insert method
This commit is contained in:
parent
e984098398
commit
d5c1b161bb
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue