File tree Expand file tree Collapse file tree 1 file changed +18
-6
lines changed
src/main/java/com/thealgorithms/datastructures/trees Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -35,8 +35,12 @@ BTreeNode search(int key) {
35
35
while (i < n && key > keys [i ]) {
36
36
i ++;
37
37
}
38
- if (i < n && keys [i ] == key ) {return this ;}
39
- if (leaf ) {return null ;}
38
+ if (i < n && keys [i ] == key ) {
39
+ return this ;
40
+ }
41
+ if (leaf ) {
42
+ return null ;
43
+ }
40
44
return children [i ].search (key );
41
45
}
42
46
@@ -114,7 +118,9 @@ void remove(int key) {
114
118
115
119
private int findKey (int key ) {
116
120
int idx = 0 ;
117
- while (idx < n && keys [idx ] < key ) {++idx ;}
121
+ while (idx < n && keys [idx ] < key ) {
122
+ ++idx ;
123
+ }
118
124
return idx ;
119
125
}
120
126
@@ -261,7 +267,9 @@ public BTree(int t) {
261
267
}
262
268
263
269
public void traverse (ArrayList <Integer > result ) {
264
- if (root != null ) {root .traverse (result );}
270
+ if (root != null ) {
271
+ root .traverse (result );
272
+ }
265
273
}
266
274
267
275
public boolean search (int key ) {
@@ -279,7 +287,9 @@ public void insert(int key) {
279
287
s .children [0 ] = root ;
280
288
s .splitChild (0 , root );
281
289
int i = 0 ;
282
- if (s .keys [0 ] < key ) {i ++;}
290
+ if (s .keys [0 ] < key ) {
291
+ i ++;
292
+ }
283
293
s .children [i ].insertNonFull (key );
284
294
root = s ;
285
295
} else {
@@ -289,7 +299,9 @@ public void insert(int key) {
289
299
}
290
300
291
301
public void delete (int key ) {
292
- if (root == null ) {return ;}
302
+ if (root == null ) {
303
+ return ;
304
+ }
293
305
root .remove (key );
294
306
if (root .n == 0 ) {
295
307
root = root .leaf ? null : root .children [0 ];
You can’t perform that action at this time.
0 commit comments