-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtree.java
47 lines (30 loc) · 942 Bytes
/
tree.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import java.util.*;
public class tree {
public static int m;
node root;
public tree(int degree) {
m = degree;
root = new leafNode(degree);
}
public void insertVal(int key, Float val) {
indexNode aNode = root.insert(key, val);
if (aNode != null) {
aNode.children.add(0, root);
root = aNode;
}
}
public String search(int val1, int val2) {
ArrayList<Float> searchResult = root.search(val1, val2);
String resultStr = "Null";
if (searchResult.size() > 0) {
resultStr = "";
for (int i = 0; i < searchResult.size(); i++){
resultStr += Float.toString(searchResult.get(i));
if (i < searchResult.size() - 1){
resultStr += ",";
}
}
}
return resultStr;
}
}