File tree Expand file tree Collapse file tree
src/main/java/com/thealgorithms/datastructures/trees Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,8 +35,12 @@ BTreeNode search(int key) {
3535 while (i < n && key > keys [i ]) {
3636 i ++;
3737 }
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+ }
4044 return children [i ].search (key );
4145 }
4246
@@ -114,7 +118,9 @@ void remove(int key) {
114118
115119 private int findKey (int key ) {
116120 int idx = 0 ;
117- while (idx < n && keys [idx ] < key ) {++idx ;}
121+ while (idx < n && keys [idx ] < key ) {
122+ ++idx ;
123+ }
118124 return idx ;
119125 }
120126
@@ -261,7 +267,9 @@ public BTree(int t) {
261267 }
262268
263269 public void traverse (ArrayList <Integer > result ) {
264- if (root != null ) {root .traverse (result );}
270+ if (root != null ) {
271+ root .traverse (result );
272+ }
265273 }
266274
267275 public boolean search (int key ) {
@@ -279,7 +287,9 @@ public void insert(int key) {
279287 s .children [0 ] = root ;
280288 s .splitChild (0 , root );
281289 int i = 0 ;
282- if (s .keys [0 ] < key ) {i ++;}
290+ if (s .keys [0 ] < key ) {
291+ i ++;
292+ }
283293 s .children [i ].insertNonFull (key );
284294 root = s ;
285295 } else {
@@ -289,7 +299,9 @@ public void insert(int key) {
289299 }
290300
291301 public void delete (int key ) {
292- if (root == null ) {return ;}
302+ if (root == null ) {
303+ return ;
304+ }
293305 root .remove (key );
294306 if (root .n == 0 ) {
295307 root = root .leaf ? null : root .children [0 ];
You can’t perform that action at this time.
0 commit comments