11package com .thealgorithms .datastructures .trees ;
22
33import java .util .ArrayList ;
4- import java .util .Arrays ;
54
65public class BTree {
76 static class BTreeNode {
@@ -36,8 +35,8 @@ BTreeNode search(int key) {
3635 while (i < n && key > keys [i ]) {
3736 i ++;
3837 }
39- if (i < n && keys [i ] == key ) return this ;
40- if (leaf ) return null ;
38+ if (i < n && keys [i ] == key ) { return this ;}
39+ if (leaf ) { return null ;}
4140 return children [i ].search (key );
4241 }
4342
@@ -115,7 +114,7 @@ void remove(int key) {
115114
116115 private int findKey (int key ) {
117116 int idx = 0 ;
118- while (idx < n && keys [idx ] < key ) ++idx ;
117+ while (idx < n && keys [idx ] < key ) { ++idx ;}
119118 return idx ;
120119 }
121120
@@ -262,7 +261,7 @@ public BTree(int t) {
262261 }
263262
264263 public void traverse (ArrayList <Integer > result ) {
265- if (root != null ) root .traverse (result );
264+ if (root != null ) { root .traverse (result );}
266265 }
267266
268267 public boolean search (int key ) {
@@ -280,7 +279,7 @@ public void insert(int key) {
280279 s .children [0 ] = root ;
281280 s .splitChild (0 , root );
282281 int i = 0 ;
283- if (s .keys [0 ] < key ) i ++;
282+ if (s .keys [0 ] < key ) { i ++;}
284283 s .children [i ].insertNonFull (key );
285284 root = s ;
286285 } else {
@@ -290,7 +289,7 @@ public void insert(int key) {
290289 }
291290
292291 public void delete (int key ) {
293- if (root == null ) return ;
292+ if (root == null ) { return ;}
294293 root .remove (key );
295294 if (root .n == 0 ) {
296295 root = root .leaf ? null : root .children [0 ];
0 commit comments