Re: [理工] [資結]-政大98-資科

看板Grad-ProbAsk作者 (小堯)時間14年前 (2010/02/12 19:49), 編輯推噓3(300)
留言3則, 3人參與, 最新討論串2/3 (看更多)
※ 引述《gn00618777 (123)》之銘言: : 題目給你一些定義 : 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 == NULL) c=0; return c = 1 + count(root->left) + count(root->right); } 這樣就可以了 -- 學長學長!那邊有飆車族 學長學長!那邊剛好像有女生 學長學長!那邊有人紅燈右轉 砍人 被壓上車 ψQSWEET 鴿 鴿 鴿 鴿 鴿他媽的 鴿 ◎ ◎ 喔~~ ︶ ︶ ◎ ◎ 喔~~ ︶ ︶ ◎ ◎ 攔下來呀! ⊙◥ 3╯ξ 沒王法了 (哈欠) (煙~) 是不是?!( ) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.137.190.25

02/12 20:34, , 1F
~"~遞迴好難 乾脆把它背下來好了
02/12 20:34, 1F

02/12 23:19, , 2F
c=0那行應該是return 0吧..
02/12 23:19, 2F

02/18 22:12, , 3F
其實基本上就是計算一顆二元數的方法而已
02/18 22:12, 3F
文章代碼(AID): #1BTK0xpw (Grad-ProbAsk)
文章代碼(AID): #1BTK0xpw (Grad-ProbAsk)