I have to create an nary tree using a linked list. I have already implemented a nary tree, but not sure how to go about changing it to a linked list structure. Please help.
public class NaryTree extends AbstractTree
{
protected Object key;
protected int degree;
protected NaryTree[ ] subtree;
public NaryTree(int degree) {
key = null; this.degree = degree; subtree = null;
}
public NaryTree(int degree, Object key) {
this.key = key;
this.degree = degree;
subtree = new NaryTree[degree];
for(int i = 0; i < degree; i++)
subtree[i] = new NaryTree(degree);
}
That is a nary tree implementation.