1

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.

David Ferenczy Rogožan
  • 18,863
  • 8
  • 68
  • 65
PaliKid
  • 11
  • 1
  • So do you just want to store the child nodes of each node in LinkedList instead of NaryTree[]? If not, then try to be more specific about what you mean in your question. – moreON Oct 09 '15 at 01:03

0 Answers0