作者qazwsxee (小尧)
看板Grad-ProbAsk
标题Re: [理工] [资结]-98政大资科
时间Fri Feb 12 19:49:08 2010
※ 引述《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
1F:推 gn00618777:~"~递回好难 乾脆把它背下来好了 02/12 20:34
2F:推 FRAXIS:c=0那行应该是return 0吧.. 02/12 23:19
3F:推 abc73021:其实基本上就是计算一颗二元数的方法而已 02/18 22:12