Êý¾Ý½á¹¹Ð¡¿ÎÌã¨6.7½²Ê¦°æ£©

2026/1/27 12:31:49

45 45 40 22 48 80 22 40 48 80

78 ËÄ¡¢±à³ÌÌâ

1.¸ù¾Ýº¯ÊýµÄ¶¨Ò壬ÀûÓõݹéÍê³É¼ÆËã¶þ²æÊ÷´óСºÍ¸ß¶ÈµÄº¯Êý¡£ £¨1£©intBinaryTree :: Size ( constBinTreeNode *t ) const { if ( t == NULL ) return 0; else

return 1 + Size ( t¡úleftChild )

+ Size ( t¡úrightChild );

}

£¨2£©intBinaryTree :: Depth ( constBinTreeNode *t ) const { if ( t == NULL ) return -1;

else return 1 + Max ( Depth ( t¡úleftChild ),

Depth ( t¡úrightChild ) ); }

2.ʵÏÖÔÚÁ´±íÉϽøÐвåÈë²Ù×÷µÄ¹¦Äܺ¯Êý¡£ intList::Insert ( constintx, constinti ) {

// Insert a node with data equal to x after the i-1¡¯th ListNode*p = first; intk = 0; while ( p != NULL && k

{ p = p¡úlink; k++; } // Locate i-1¡¯th element if ( i<0 || p == NULL&&i!=0) { cout<< ¡°ÎÞЧµÄ²åÈëλÖÃ!\\n¡±; return 0; }

ListNode *newnode= new ListNode(x, NULL); // Allocate memory for the new node if (i == 0 ) { //Insert in the front of list newnode¡úlink = first; first = newnode; }

else { //else newnode¡úlink = p¡úlink; p¡úlink = newnode;

}

if(newnode->link==NULL) last=newnode; return 1; }

3.½èÖúÕ»£¬ÊµÏÖ¶þ²æÊ÷µÄÖÐÐò±éÀú¡£

template void BinaryTree :: InOrderTraverse () { stack S; BiTreeNode * p;

S.makeEmpty( ); p = root; //³õʼ»¯ do{

while ( p ) { S.push(p); p = p¡úleftChild; }

if ( !S.empty( ) ) { //Õ»·Ç¿Õ

p = S.top( ); S.pop( ); //ÍËÕ» cout<

p = p¡úrightChild; //ÏòÓÒÁ´×ß }

} while ( p || !S.empty( ) ); }


Êý¾Ý½á¹¹Ð¡¿ÎÌã¨6.7½²Ê¦°æ£©.doc ½«±¾ÎĵÄWordÎĵµÏÂÔØµ½µçÄÔ
ËÑË÷¸ü¶à¹ØÓÚ£º Êý¾Ý½á¹¹Ð¡¿ÎÌã¨6.7½²Ê¦°æ£© µÄÎĵµ
Ïà¹ØÍÆ¼ö
Ïà¹ØÔĶÁ
¡Á ÓοͿì½ÝÏÂÔØÍ¨µÀ£¨ÏÂÔØºó¿ÉÒÔ×ÔÓɸ´ÖƺÍÅŰ棩

ÏÂÔØ±¾ÎĵµÐèÒªÖ§¸¶ 10 Ôª

Ö§¸¶·½Ê½£º

¿ªÍ¨VIP°üÔ»áÔ± ÌØ¼Û£º29Ôª/ÔÂ

×¢£ºÏÂÔØÎĵµÓпÉÄÜ¡°Ö»ÓÐĿ¼»òÕßÄÚÈݲ»È«¡±µÈÇé¿ö£¬ÇëÏÂÔØÖ®Ç°×¢Òâ±æ±ð£¬Èç¹ûÄúÒѸ¶·ÑÇÒÎÞ·¨ÏÂÔØ»òÄÚÈÝÓÐÎÊÌ⣬ÇëÁªÏµÎÒÃÇЭÖúÄã´¦Àí¡£
΢ÐÅ£ºxuecool-com QQ£º370150219