用二叉鏈表求二叉樹的結點數(shù) 以二叉鏈表為存儲結構?
以二叉鏈表為存儲結構?int CountNode (BTNode *t) //節(jié)點總數(shù) { int num if (t == NULL) num = 0 else num = 1 CountNod
以二叉鏈表為存儲結構?
int CountNode (BTNode *t) //節(jié)點總數(shù) { int num if (t == NULL) num = 0 else num = 1 CountNode (t->lch) CountNode (t->rch) return (num) } void CountLeaf (BTNode *t) //葉子節(jié)點總數(shù) { if (t != NULL) { if (t->lch == NULL && t->rch == NULL) count // 全局變量 CountLeaf (t->lch) CountLeaf (t->rch) } }
以二叉鏈表作為二叉樹的儲存結構,在具有n個結點的二叉鏈表中n(n>0),空鏈域的個數(shù)為()?
n個結點的二叉樹二叉鏈表中有n 1個空鏈域,三叉鏈表中有n個(多了一個根結點中的空鏈域)