Hello I am struggling with the implementing part of my assignment that requires me to Create Functions for the BtreeNode class and Btree class and I am unsure of how my implementation of the insert is supposed to work.
public class BTreeNode<T extends Comparable<T>> {
public Comparable<T>[] nodeData;
public BTreeNode<T>[] nodeChildren;
public BTreeNode<T> parent;
public int size;
@SuppressWarnings("unchecked")
public BTreeNode(int size) {
this.size = size;
nodeData = new Comparable[size];
nodeChildren = new BTreeNode[size + 1];
//nodeData and NodeChildren are set to 1 more than the size of the node to allow for overflow
this.parent = null;
}
public Comparable<T> getIndex(int i) {
if (i < 0 || i >= size) {
return null;
}
return nodeData[i];
}
public BTreeNode<T> ascend() {
return parent;
}
public BTreeNode<T> descend(int i) {
//return nodeChildren[i];
if (i < 0 || i >= size + 1) {
return null;
}
return nodeChildren[i];
}
/* -------------------------------------------------------------------------- */
/* Helpers */
/* -------------------------------------------------------------------------- */
public String toString() {
String out = "|";
for (int i = 0; i < nodeData.length; i++) {
if (nodeData[i] == null) {
out += "null|";
} else {
out += nodeData[i].toString() + "|";
}
}
return out;
}
}
above is my current implementation of the BTreeNode class