1

我必须使用链表创建一棵二叉树。我已经实现了一棵二叉树,但不确定如何将其更改为链表结构。请帮忙。

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);
    }

那是一个二叉树实现。

4

0 回答 0