Hallo,
versuche gerade die inneren Knoten eines B+Baumes zu erstellen, jedoch scheitere ich an der Umsetzung. Was ich bisher habe:
Bin mir aber ziemlich sicher das es so nicht funktionieren kann. Vielleicht muss es rekursiv umgesetzt werden?
LG
versuche gerade die inneren Knoten eines B+Baumes zu erstellen, jedoch scheitere ich an der Umsetzung. Was ich bisher habe:
Code:
/**
* Builds a valid inner level of this B+ tree with the minimal number of inner
* nodes for the specified list of child nodes. This method returns a sorted
* list of the inner nodes created in the process (sorted with respect to the
* keys in the nodes). The children in an inner node are supposed to point
* to the respective child nodes.
*
* @param children a sorted list of child nodes for which the next inner level
* is built
*
* @return a sorted list of all inner nodes created in the process, or
* <tt>null</tt> if there are no children to connect
*/
private List<BPNode<Key>> buildInnerLevel (final List<BPNode<Key>> children) {
// deal with trivial cases
if ((children == null) || children.isEmpty()) {
return null;
}
List<BPNode<Key>> currentLevel = new ArrayList<BPNode<Key>>();
BPNode<Key> temp = new BPNode<Key>(degree());
for(int i = 1; i < children.size(); i++) {
temp.addKey(children.get(i).key(0));
if(temp.keys().size() > (degree() - 1)) {
}
}
currentLevel.add(temp);
System.out.println(currentLevel.get(0).key(0));
return currentLevel;
}
Bin mir aber ziemlich sicher das es so nicht funktionieren kann. Vielleicht muss es rekursiv umgesetzt werden?
LG