Skip to content

Commit 1266ede

Browse files
William FisetWilliam Fiset
William Fiset
authored and
William Fiset
committed
2 parents f5fee70 + 028d6be commit 1266ede

File tree

1 file changed

+0
-7
lines changed

1 file changed

+0
-7
lines changed

src/main/java/com/williamfiset/algorithms/datastructures/balancedtree/AVLTreeRecursive.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ public boolean contains(T value) {
7676

7777
// Recursive contains helper method.
7878
private boolean contains(Node node, T value) {
79-
8079
if (node == null) return false;
8180

8281
// Compare current value to the value in the node.
@@ -105,7 +104,6 @@ public boolean insert(T value) {
105104

106105
// Inserts a value inside the AVL tree.
107106
private Node insert(Node node, T value) {
108-
109107
// Base case.
110108
if (node == null) return new Node(value);
111109

@@ -115,7 +113,6 @@ private Node insert(Node node, T value) {
115113
// Insert node in left subtree.
116114
if (cmp < 0) {
117115
node.left = insert(node.left, value);
118-
;
119116

120117
// Insert node in right subtree.
121118
} else {
@@ -131,7 +128,6 @@ private Node insert(Node node, T value) {
131128

132129
// Update a node's height and balance factor.
133130
private void update(Node node) {
134-
135131
int leftNodeHeight = (node.left == null) ? -1 : node.left.height;
136132
int rightNodeHeight = (node.right == null) ? -1 : node.right.height;
137133

@@ -144,7 +140,6 @@ private void update(Node node) {
144140

145141
// Re-balance a node if its balance factor is +2 or -2.
146142
private Node balance(Node node) {
147-
148143
// Left heavy subtree.
149144
if (node.bf == -2) {
150145

@@ -212,7 +207,6 @@ private Node rightRotation(Node node) {
212207

213208
// Remove a value from this binary tree if it exists, O(log(n))
214209
public boolean remove(T elem) {
215-
216210
if (elem == null) return false;
217211

218212
if (contains(root, elem)) {
@@ -226,7 +220,6 @@ public boolean remove(T elem) {
226220

227221
// Removes a value from the AVL tree.
228222
private Node remove(Node node, T elem) {
229-
230223
if (node == null) return null;
231224

232225
int cmp = elem.compareTo(node.value);

0 commit comments

Comments
 (0)