【发布时间】:2016-12-11 18:35:48
【问题描述】:
对于下面的树,
typedef struct SiblingTreeNode{
void *item;
struct SiblingTreeNode *parent;
struct SiblingTreeNode *firstChild;
struct SiblingTreeNode *nextSibling;
}SibTreeNode;
typedef struct Tree{
SibTreeNode *root;
int size; // number of nodes in tree
}Tree;
1)
假设一棵树的深度很大,为了避免堆栈溢出,我们可以不使用递归进行DFS吗?
2)
一般来说,一个树节点有n个子指针和数据指针(item),从对树的操作性能方面来说,维护兄弟节点(nextSibling)和第一个子节点(firstChild)有什么好处和父指针(parent)?
【问题讨论】:
-
This older question 解决您的第二个问题。
标签: c performance data-structures tree