2012-05-05 111 views

回答

2

如果您将其构建为双链接,那么转到“父”属性。抽象示例:

struct node { 
    struct node *parent; // << this is the parent, just access it 
    struct node *rchild; 
    struct node *lchild; 
    int val; 
} 

否则,您需要在每次访问子节点时缓存上一个节点。

注意,一个双链接列表不一样的二进制(在列表中的每个项目都有一个孩子)。

相关问题