@@ -27,25 +27,21 @@ Node search(int number){
27
27
if (root .searchKeys (0 , root .keys .size () - 1 , number ) == true ){
28
28
System .out .println ("found the node" );
29
29
System .out .println ("root.leaf = " + root .leaf );
30
- System .out .println ("the currsent node is the node with keys " );
30
+ System .out .println ("the resulted node is the node with keys " );
31
31
for (Integer key : root .keys ){
32
32
System .out .print (key + " " );
33
33
}
34
- System .out .println ("" );
35
- System .out .println ("currentnode == null is " + (root == null ));
36
- System .out .println ("returning root " );
37
- for (Integer key : root .keys ){
38
- System .out .print (key + " " );
39
- }
40
- System .out .println ("" );
41
- return this .root ;
34
+ return root ;
42
35
}
43
36
44
37
if (root .children .size () > 0 ){
45
38
System .out .println ("searching the leaves" );
46
39
for (Node node : root .children ){
47
40
BTree bt = new BTree (node );
48
- bt .search (number );
41
+ Node node1 = bt .search (number );
42
+ if (node != null ){
43
+ return node1 ;
44
+ }
49
45
}
50
46
}
51
47
return null ;
@@ -77,8 +73,6 @@ public static void main(String[] args) {
77
73
}
78
74
System .out .println ("----------------------------------------" );
79
75
Node answer1 = bt .search (7 );
80
- System .out .println ("hi 7!!!!!!!" );
81
- System .out .println ("answer1 == null is " + (bt .search (7 ) == null ));
82
76
if (answer1 == null ){
83
77
System .out .println ("answer is null." );
84
78
}else {
0 commit comments