续写一个二叉树的完整实现――前序・中序・后序・测试

 比前一版本增加了构建方法

BinaryTree.h

 

  
  
  
  
  1. #pragma once 
  2. #include<iostream> 
  3. #include<queue> 
  4. #include<stack> 
  5. #include"BinaryTreeNote.h" 
  6. #include<string> 
  7. using namespace std; 
  8.  
  9. template<class T> 
  10. class BinaryTree{ 
  11.     BinaryTreeNote<T> *rt; 
  12.     //2011.11.12   删除num变量。 
  13. public
  14.     BinaryTree(); 
  15.     ~BinaryTree(); 
  16.     bool isEmpty( ) const
  17.     BinaryTreeNote<T>* getRoot()const;  //return root note 
  18.     BinaryTreeNote<T>* getParent(BinaryTreeNote<T>* current )const;   //return parent note 
  19.     BinaryTreeNote<T>* getLeftSibing(BinaryTreeNote<T>* current ) const;  //return left brother 
  20.     BinaryTreeNote<T>* getRightSibing(BinaryTreeNote<T>* current ) const;  //return right brother 
  21.     void breadFristOrder(BinaryTreeNote<T>* );  //广度优先遍历 
  22.     void preOrder(BinaryTreeNote<T>* );  //  前序 
  23.     void inOrder(BinaryTreeNote<T>* );  //中序 
  24.     void postOrder(BinaryTreeNote<T>* );   //后序 
  25.     void levelOrder(BinaryTreeNote<T>* );   // 
  26.     void deleteBinaryTree(BinaryTreeNote<T>* root);  //delete the tree which is the charge of root 
  27.     void build(BinaryTreeNote<T>** ); 
  28.     BinaryTreeNote<T>** getDRoot(){ 
  29.         return &rt; 
  30.     }  
  31.     void help_build_qz(T*,int,int,T*,int,int,BinaryTreeNote<T> *); 
  32.     void build_qz(); 
  33.     void help_build_zh(T*,int,int,T*,int,int,BinaryTreeNote<T> *); 
  34.     void build_zh(); 
  35.     //5.1 2 3 
  36.     int sta_deg(int,BinaryTreeNote<T>* root ); 
  37.     //5.4 
  38.     int high(BinaryTreeNote<T>*); 
  39.     //5.5 
  40.     int wide( ); 
  41.     //5.6 
  42.     int biggest(BinaryTreeNote<T>*,T); 
  43.     //5.7 
  44.     void swap(BinaryTreeNote<T>*);  
  45.     //5.8 
  46.     void del_leaf(BinaryTreeNote<T>*,BinaryTreeNote<T>*); 
  47.     //6 
  48.     bool isCom(); 
  49.     //7 
  50.     void build_clu();  //线索二叉树构建 
  51.     BinaryTreeNote<T>* clu_qx(BinaryTreeNote<T>* root); 
  52.     BinaryTreeNote<T>* clu_hj(BinaryTreeNote<T>* root); 
  53. }; 
  54. template<class T> 
  55. BinaryTree<T>::BinaryTree( ):rt(new BinaryTreeNote<T>){ 
  56. template<class T> 
  57. bool BinaryTree<T>::isEmpty( )const
  58.     return !rt; 
  59. template<class T> 
  60. BinaryTreeNote<T>* BinaryTree<T>::getRoot() const
  61.     return rt; 
  62. template<class T> 
  63. BinaryTreeNote<T>* BinaryTree<T>::getParent(BinaryTreeNote<T>* current ) const { 
  64.     queue<BinaryTreeNote<T>*> n; 
  65.     BinaryTreeNote<T>* cur; 
  66.     n.push(this->getRoot()); 
  67.     while(!n.empty() ){ 
  68.         cur=n.front(); 
  69.         n.pop(); 
  70.         if(cur->getLeftChild()==current ||cur->getRightChile()==current  ) 
  71.             return cur; 
  72.         if( cur->getLeftChild()!=0) 
  73.             n.push(cur->getLeftChild); 
  74.         else if(cur->getRightChile()) 
  75.             n.push(cur->getRightChile()); 
  76.     } 
  77. template<class T> 
  78. BinaryTreeNote<T>* BinaryTree<T>::getLeftSibing(BinaryTreeNote<T>* current ) const
  79.     ifthis->getParent()==NULL) 
  80.         return NULL; 
  81.     return this->getParent(current)->getLeftChild(); 
  82. template<class T> 
  83. BinaryTreeNote<T>* BinaryTree<T>::getRightSibing(BinaryTreeNote<T>* current ) const
  84.     ifthis->getParent()==NULL) 
  85.         return NULL; 
  86.     return this->getParent(current)->getRightChile(); 
  87. template<class T> 
  88. void  BinaryTree<T>::breadFristOrder( BinaryTreeNote<T>* root ){ 
  89.     queue<BinaryTreeNote<T>*> local; 
  90.     local.push(root ); 
  91.     BinaryTreeNote<T>* index=local.front(); 
  92.     while( !local.empty() ){ 
  93.         if( index ){ 
  94.             local.push(index->getLeftChild()); 
  95.             local.push(index->getRightChile()); 
  96.             cout<<index->getValue()<<" "
  97.         } 
  98.         local.pop(); 
  99.     } 
  100.     cout<<endl; 
  101. template<class T> 
  102. void  BinaryTree<T>::preOrder(BinaryTreeNote<T>* root) { 
  103.     BinaryTreeNote<T>* cur=root; 
  104.     stack<BinaryTreeNote<T>*> n; 
  105.     while( cur || !n.empty() ){ 
  106.         if( cur ){ 
  107.             cout<<cur->data<<" "
  108.             if(cur->getRightChile() ) 
  109.                 n.push(cur->getRightChile()); 
  110.             cur=cur->getLeftChild(); 
  111.         } 
  112.         else
  113.             cur=n.top(); 
  114.             n.pop(); 
  115.         } 
  116.     } 
  117.     cout<<endl; 
  118. template<class T> 
  119. void  BinaryTree<T>::inOrder(BinaryTreeNote<T>* root){ 
  120.     //关键部分就是把一个过程抽象成一步一步执行相同的过程! 
  121.     BinaryTreeNote<T>* cur=root; 
  122.     stack<BinaryTreeNote<T>* > n; 
  123.     while( !n.empty() || cur!=0  ){ 
  124.         if(cur ){ 
  125.             n.push(cur); 
  126.             cur=cur->getLeftChild(); 
  127.         } 
  128.         else
  129.             cur=n.top(); 
  130.             cout<<cur->getValue()<<" "
  131.             cur=cur->getRightChile(); 
  132.             n.pop(); 
  133.         } 
  134.     } 
  135.     cout<<endl; 
  136. template<class T> 
  137. void  BinaryTree<T>::postOrder(BinaryTreeNote<T>* root){ 
  138.     stack<BinaryTreeNote<T>* > n; 
  139.     BinaryTreeNote<T>* cur=root; 
  140.     BinaryTreeNote<T>* pre=root; 
  141.     while( cur ){ 
  142.         while( cur->getLeftChild() ){ 
  143.             n.push(cur); 
  144.             cur=cur->getLeftChild(); 
  145.         } 
  146.         while( cur &&( cur->getRightChile()==0 || cur->getRightChile()==pre ) ){ 
  147.             cout<<cur->getValue()<<" "
  148.             pre=cur; 
  149.             if(n.empty()) 
  150.                 return
  151.             cur=n.top(); 
  152.             n.pop(); 
  153.         } 
  154.         n.push(cur); 
  155.         cur=cur->getRightChile(); 
  156.     } 
  157.     cout<<endl; 
  158. template<class T> 
  159. void  BinaryTree<T>::levelOrder(BinaryTreeNote<T>* root){ 
  160.     if(!root) 
  161.         return ; 
  162.     queue<BinaryTreeNote<T>* > n; 
  163.     BinaryTreeNote<T>* cur; 
  164.     n.push(root); 
  165.     while(!n.empty() ){ 
  166.         cur=n.front(); 
  167.         n.pop(); 
  168.         cout<<cur->getValue()<<" "
  169.         if( cur->getLeftChild()!=0) 
  170.             n.push(cur->getLeftChild()); 
  171.         if(cur->getRightChile()!=0) 
  172.             n.push(cur->getRightChile()); 
  173.     } 
  174.     cout<<endl; 
  175. template<class T> 
  176. void  BinaryTree<T>::deleteBinaryTree(BinaryTreeNote<T>* root){ 
  177.     if(!root) 
  178.         return ; 
  179.     queue<BinaryTreeNote<T>* > n; 
  180.     BinaryTreeNote<T>* cur; 
  181.     n.push(rt); 
  182.     if(root==rt) 
  183.         rt=0; 
  184.     while(!n.empty() ){ 
  185.         cur=n.front(); 
  186.         n.pop(); 
  187.         if(cur->getLeftChild()==root ){ 
  188.             cur->left=0; 
  189.             break
  190.         } 
  191.         else if(cur->getRightChile()==root ){ 
  192.             cur->right=0; 
  193.             break
  194.         } 
  195.         if( cur->getLeftChild()!=0) 
  196.             n.push(cur->getLeftChild()); 
  197.         if(cur->getRightChile()!=0) 
  198.             n.push(cur->getRightChile()); 
  199.     } 
  200. template<class T> 
  201. BinaryTree<T>::~BinaryTree(){ 
  202.     this->deleteBinaryTree (this->rt); 
  203. //下面是一段2重的指针代码....... 
  204. //创建方法1 
  205. template<class T> 
  206. void BinaryTree<T>::build(BinaryTreeNote<T>** root){ 
  207.     T h; 
  208.     static int ll=0; 
  209.     if(ll++==0) 
  210.         cout<<"root:"
  211.     if(cin>>h){ 
  212.         *root=new BinaryTreeNote<T>; 
  213.         (*root)->data=h; 
  214.         cout<<h<<" left:";       
  215.         build(&((*root)->left)); 
  216.         cout<<h<<" right:"
  217.         build(&((*root)->right)); 
  218.     } 
  219.     else
  220.         cin.clear(); 
  221.         return ; 
  222.     } 
  223. template<class T> 
  224. //创建发放二 
  225. void BinaryTree<T>::build_qz(){ 
  226.     T n; 
  227.     cin>>n; 
  228.     int *a=new T [n];  //zhong 
  229.     int *b=new T [n]; 
  230.     cout<<"前序输入:"
  231.     forint i=0; i<n;i++ ) 
  232.         cin>>a[i]; 
  233.     cout<<"中序输入:"
  234.     forint i=0; i<n;i++ ) 
  235.         cin>>b[i]; 
  236.     this->help_build_qz(a,0,n-1,b,0,n-1,this->rt); 
  237. template<class T> 
  238. void BinaryTree<T>::help_build_qz( T* a,int num_af,int num_al,T* b,int num_bf,int num_bl,BinaryTreeNote<T>* root ){ 
  239.     //a前,b中    root 已经分备好的根节点 
  240.     root->data=a[num_af]; 
  241.     if(num_af==num_al) 
  242.         return ; 
  243.     int i=num_bf; 
  244.     while( b[i]!=a[num_af] ) i++; 
  245.     if(a[num_af]!=b[num_bf] ){ 
  246.         root->left=new BinaryTreeNote<T>; 
  247.         help_build_qz(a,num_af+1,num_af+i-num_bf,b,num_bf,i-1,root->getLeftChild() ); 
  248.     } 
  249.     if(a[num_af]!=b[num_bl] ){ 
  250.         root->right=new BinaryTreeNote<T>; 
  251.         help_build_qz(a,num_af+i-num_bf+1,num_al,b,i+1,num_bl,root->getRightChile() ); 
  252.     } 
  253. template<class T> 
  254. //创建方法3 
  255. void BinaryTree<T>::build_zh(){ 
  256.     T n; 
  257.     cin>>n; 
  258.     int *a=new T [n];  //zhong 
  259.     int *b=new T [n]; 
  260.     cout<<"后序输入:"
  261.     forint i=0; i<n;i++ ) 
  262.         cin>>a[i]; 
  263.     cout<<"中序输入:"
  264.     forint i=0; i<n;i++ ) 
  265.         cin>>b[i]; 
  266.     this->rt=new BinaryTreeNote<T>; 
  267.     this->help_build_zh(a,0,n-1,b,0,n-1,this->rt); 
  268.     int y; 
  269. template<class T> 
  270. void BinaryTree<T>::help_build_zh(T* a,int num_af,int num_al,T* b,int num_bf,int num_bl,BinaryTreeNote<T>* root ){ 
  271.     //a后,b中    root 已经分备好的根节点 
  272.     root->data=a[num_al]; 
  273.     if(num_af==num_al) 
  274.         return ; 
  275.     int i=num_bf; 
  276.     while( b[i]!=a[num_al] ) i++; 
  277.     if(a[num_af]!=b[num_bl] ){ 
  278.         root->left=new BinaryTreeNote<T>; 
  279.         help_build_qz(a,num_af,num_af+i-num_bf-1,b,num_bf,i-1,root->getLeftChild() ); 
  280.     } 
  281.     if(a[num_af]!=b[num_bf] ){ 
  282.         root->right=new BinaryTreeNote<T>; 
  283.         help_build_qz(a,num_af+i-num_bf,num_al-1,b,i+1,num_bl,root->getRightChile() ); 
  284.     } 
  285. //5.1 2 3 
  286. template<class T> 
  287. int BinaryTree<T>::sta_deg(int deg ,BinaryTreeNote<T>* root ){ 
  288.     int a=0; 
  289.     int p=0; 
  290.     if(root->getLeftChild() ){ 
  291.         a++; 
  292.         p+=this->sta_deg(deg,root->getLeftChild()); 
  293.     } 
  294.     if(root->getRightChile()){ 
  295.         a++; 
  296.         p+=this->sta_deg(deg,root->getRightChile()); 
  297.     } 
  298.     if(a==deg) 
  299.         return 1+p; 
  300.     else 
  301.         return p; 
  302. //5.4 
  303. template<class T> 
  304. int BinaryTree<T>::high(BinaryTreeNote<T>* root){ 
  305.     int i=1,j=1; 
  306.     if(root->getLeftChild() ) 
  307.         i+=this->high(root->getLeftChild() ); 
  308.     if(root->getRightChile() ) 
  309.         j+=this->high(root->getRightChile() ); 
  310.     return i>j?i:j; 
  311. //5.5 
  312. template<class T> 
  313. int BinaryTree<T>::wide(){ 
  314.     queue<BinaryTreeNote<T>*> k; 
  315.     k.push(this->rt); 
  316.     BinaryTreeNote<T>* p=this->rt; 
  317.     k.push(0); 
  318.     int con=0; 
  319.     int con_pre=0; 
  320.     while( 1){ 
  321.         if(k.front()==0 ){ 
  322.             con_pre=con_pre>con?con_pre:con; 
  323.             con=0; 
  324.             k.pop(); 
  325.             if(k.empty()) 
  326.                 break
  327.             k.push(0); 
  328.             continue
  329.         } 
  330.         p=k.front(); 
  331.         if(p->getRightChile() ) 
  332.             k.push(p->getRightChile()); 
  333.         if(p->getLeftChild()) 
  334.             k.push(p->getLeftChild()); 
  335.         con++; 
  336.         k.pop(); 
  337.     } 
  338.     return con_pre; 
  339. template<class T> 
  340. int BinaryTree<T>::biggest(BinaryTreeNote<T>* root,T big){ 
  341.     big=big>root->data?big:root->data; 
  342.     if(root->getLeftChild() ){ 
  343.         big=big>this->biggest(root->getLeftChild(),big)?big:this->biggest(root->getLeftChild(),big) ; 
  344.     } 
  345.     if(root->getRightChile() ){ 
  346.         big=big>this->biggest(root->getRightChile(),big)?big:this->biggest(root->getRightChile(),big); 
  347.     } 
  348.     return big; 
  349.  
  350. template<class T> 
  351. void BinaryTree<T>::swap(BinaryTreeNote<T>* root){ 
  352.     if(! root) 
  353.         return ; 
  354.     BinaryTreeNote<T>* aw=root->getLeftChild(); 
  355.     root->left=root->getRightChile(); 
  356.     root->right=aw; 
  357.     this->swap(root->getLeftChild()); 
  358.     this->swap(root->getRightChile()); 
  359. template<class T> 
  360. void BinaryTree<T>::del_leaf(BinaryTreeNote<T>* root,BinaryTreeNote<T>* par){ 
  361.     if(root->getLeftChild()||root->getRightChile()){ 
  362.         if(root->getLeftChild() ) 
  363.             this->del_leaf(root->getLeftChild(),root); 
  364.         if(root->getRightChile()) 
  365.             this->del_leaf(root->getRightChile(),root); 
  366.         return ; 
  367.     } 
  368.     if(  root->getLeftChild()==0 && root->getRightChile()==0  ){ 
  369.         if(par->getLeftChild()==root ) 
  370.             par->left=0; 
  371.         else 
  372.             par->right=0; 
  373.         delete root; 
  374.     } 
  375. template<class T> 
  376. bool BinaryTree<T>::isCom(){ 
  377.     queue<BinaryTreeNote<T>* > n; 
  378.     BinaryTreeNote<T>* cur; 
  379.     BinaryTreeNote<T>* o; 
  380.     for( o=rt ; o->getLeftChild(); )o=o->getLeftChild(); 
  381.     o->left=(BinaryTreeNote<T>*)1; 
  382.     n.push(rt); 
  383.     int p=0; 
  384.     while(!n.empty() ){ 
  385.         cur=n.front(); 
  386.         n.pop(); 
  387.         if(cur==0){ 
  388.             p++; 
  389.             continue
  390.         } 
  391.         if(p!=0){ 
  392.             p=-1; 
  393.             break
  394.         } 
  395.         if(cur==(BinaryTreeNote<T>*)1&&p==0){ 
  396.             p=0; 
  397.             break
  398.         } 
  399.         n.push(cur->getLeftChild()); 
  400.         n.push(cur->getRightChile());        
  401.     } 
  402.     o->left=0; 
  403.     return p!=-1; 
  404. template<class T> 
  405. void  BinaryTree<T>::build_clu(){ 
  406.     BinaryTreeNote<T>* cur=rt; 
  407.     BinaryTreeNote<T>* p=0; 
  408.     stack<BinaryTreeNote<T>* > n; 
  409.     while( !n.empty() || cur!=0  ){ 
  410.         if(cur ){ 
  411.             n.push(cur); 
  412.             cur=cur->getLeftChild(); 
  413.         } 
  414.         else
  415.             cur=n.top(); 
  416.             if(cur->getLeftChild()==0 && cur->getRightChile()==0 && p){ 
  417.                 p->right=cur; 
  418.                 cur->left=p; 
  419.                 p=cur; 
  420.             } 
  421.             if(cur->getLeftChild()==0) 
  422.                 cur->l=0; 
  423.             if(cur->getRightChile()==0) 
  424.                 cur->r=0; 
  425.             cur=cur->getRightChile(); 
  426.             n.pop(); 
  427.         } 
  428.     } 
  429.     cout<<endl; 
  430. template<class T> 
  431. BinaryTreeNote<T>* BinaryTree<T>::clu_hj(BinaryTreeNote<T>* root ){ 
  432.     BinaryTreeNote<T>* cur=root->getRightChile(); 
  433.     if(!cur) 
  434.         return 0; 
  435.     while(cur->l ) 
  436.         cur=cur->getLeftChild(); 
  437.     return cur; 
  438. template<class T> 
  439. BinaryTreeNote<T>* BinaryTree<T>::cluqx(BinaryTreeNote<T>* root ){ 
  440.     return root->getLeftChild(); 

二叉树定义.cpp

 

  
  
  
  
  1. #pragma once 
  2. #include "BinaryTree.h" 
  3.  
  4. int main(){ 
  5.     BinaryTree<int> a; 
  6.     /* 
  7.     a.build(  a.getDRoot()); 
  8.     cout<<"a.levelOrder(a.getRoot() );"<<endl; 
  9.     a.levelOrder(a.getRoot() );   //right! 
  10.     cout<<"a.postOrder(a.getRoot());"<<endl; 
  11.     a.postOrder(a.getRoot()); 
  12.     cout<<endl; 
  13.     cout<<"a.inOrder(a.getRoot());"<<endl; 
  14.     a.inOrder(a.getRoot()); 
  15.     cout<<"a.preOrder(a.getRoot());"<<endl; 
  16.     a.preOrder(a.getRoot()); 
  17.     cout<<"a.deleteBinaryTree(a.getRoot()->getLeftChild());"<<endl; 
  18.     a.deleteBinaryTree(a.getRoot()->getLeftChild()); 
  19.     a.levelOrder(a.getRoot() ); 
  20.     exit(0); 
  21.     */ 
  22.     cout<<"输入节点数"<<endl; 
  23.     a.build_qz(); 
  24.     cout<<"a.postOrder(a.getRoot());"
  25.     a.postOrder(a.getRoot()); 
  26.     cout<<endl; 
  27.     cout<<"a.preOrder(a.getRoot());"
  28.     a.preOrder(a.getRoot()); 
  29.     cout<<endl<<"a.inOrder(a.getRoot());"
  30.     a.inOrder(a.getRoot()); 
  31.     cout<<"a.sta_deg(1,a.getRoot())"<<a.sta_deg(1,a.getRoot())<<endl; 
  32.     cout<<"a.wide()"<<a.wide()<<endl; 
  33.     cout<<"a.biggest(a.getRoot(),a.getRoot()->getValue())"<<a.biggest(a.getRoot(),a.getRoot()->getValue())<<endl; 
  34.     a.swap(a.getRoot()); 
  35.     cout<<"a.swap(a.getRoot());"
  36.     a.levelOrder(a.getRoot()); 
  37.     a.del_leaf(a.getRoot(),a.getRoot() ); 
  38.     cout<<"a.del_leaf(a.getRoot(),a.getRoot() );"
  39.     a.levelOrder(a.getRoot()); 
  40.     if( a.isCom( )) 
  41.         cout<<"完全"<<endl; 
  42.     else 
  43.         cout<<"不完全"<<endl; 
  44.  
  45.     a.build_clu(); 
  46.     cout<<"a.clu_hj(a.getRoot())"<<a.clu_hj(a.getRoot())->getValue()<<endl;; 
  47.     cout<<"a.clu_qx(a.getRoot())"<<a.clu_qx(a.getRoot())->getValue()<<endl; 
  48.     return 0; 

BinaryTreeNote.h

 

  
  
  
  
  1. #pragma once 
  2. #include<iostream> 
  3.  
  4. template<class T> 
  5. class BinaryTree; 
  6.  
  7. template<class T> 
  8. class BinaryTreeNote{ 
  9.     friend class BinaryTree<T>; 
  10.     BinaryTreeNote<T>* right; 
  11.     BinaryTreeNote<T>* left; 
  12.     T data; 
  13.     int l; 
  14.     int r; 
  15. public
  16.     BinaryTreeNote():right(0),left(0),l(0),r(0) { } 
  17.     BinaryTreeNote(const T& ele ); 
  18.     BinaryTreeNote(const T& ele,BinaryTreeNote<T>* l,BinaryTreeNote<T>*r ); 
  19.     BinaryTreeNote<T>* getLeftChild( ); 
  20.     BinaryTreeNote<T>* getRightChile( ); 
  21.     void setLeftChild(BinaryTreeNote<T>* l ); 
  22.     void setRightChild(BinaryTreeNote<T>* r ); 
  23.     T getValue( ) const
  24.     void setValue(const T& val); 
  25.     bool isLeaf() const
  26.     ~BinaryTreeNote(); 
  27. }; 
  28. template<class T> 
  29. BinaryTreeNote<T>::BinaryTreeNote(const T& ele):right(0),left(0){ 
  30.     this->data=ele; 
  31. template<class T> 
  32. BinaryTreeNote<T>::BinaryTreeNote(const T& ele,BinaryTreeNote<T>* l,BinaryTreeNote<T>*r){ 
  33.     this->data=ele; 
  34.     this->left=l; 
  35.     this->right=r; 
  36. template<class T> 
  37. BinaryTreeNote<T>* BinaryTreeNote<T>::getLeftChild(){ 
  38.     return this->left; 
  39. template<class T> 
  40. BinaryTreeNote<T>* BinaryTreeNote<T>::getRightChile(){ 
  41.     return this->right; 
  42. template<class T> 
  43. T BinaryTreeNote<T>::getValue()const
  44.     return this->data; 
  45. template<class T> 
  46. bool BinaryTreeNote<T>::isLeaf()const { 
  47.     return ! (this->left||this->right); 
  48. template<class T>  
  49. void BinaryTreeNote<T>::setLeftChild(BinaryTreeNote* l ){ 
  50.     this->left=l; 
  51. template<class T> 
  52. void BinaryTreeNote<T>::setRightChild(BinaryTreeNote* r ){ 
  53.     this->right=r; 
  54. template<class T> 
  55. BinaryTreeNote<T>::~BinaryTreeNote(){ 
  56.      

 

你可能感兴趣的:(二叉树)