作者gn00618777 (123)
看板Grad-ProbAsk
標題[理工] [資結]-98政大資科
時間Fri Feb 12 17:44:23 2010
題目給你一些定義
typedef int DATA
struct node{
DATA element;
struct node *left;
struct node *right;
int height;
};
typedef struct node AVLNODE;
typedef AVLNODE *AVLTree;
題目要求利用int count(AVLtree noot) function來計算
AVL tree的noode數
我的想法是用中序式,來計算個數
int count(AVLTree root){
int c=0;
if(root->left!=NULL)
count(root->left);
c=c+1;
if(root->right!=NULL)
count(root->right);
return c;
}
感覺我的c好像會被蓋掉,對遞迴概念不是很熟~"~
如果有錯請問要怎麼修改?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.138.110.105
推 joe760414:你的count沒有東西去接他??那他return的C..沒人接收 02/12 18:01
→ gn00618777:喔喔 02/12 19:17
→ gn00618777:我的c是要給外面的人接收阿= = 02/12 19:39