标签:blog div log size c return as bs tt
struct ListNode { int data; ListNode *lchild,*rchild; }; void CreateBSTree(ListNode *B2_root,ListNode *BSTree_root) { if(BSTree_root==NULL) { BSTree_root = (ListNode*)malloc(sizeof(ListNode)); BSTree_root->lchild=BSTree_root->rchild=NULL; BSTree_root->data=B2_root->data; return ; } if(B2_root->data<BSTree_root->data) CreateBSTree(B2_root,BSTree_root->lchild); if(B2_root->data>BSTree_root->data) CreateBSTree(B2_root,BSTree_root->rchild); } void PreOrder(ListNode *B2_root,ListNode *BSTree_root) { if(B2_root==NULL) return ;//根节点就为空 CreateBSTree(B2_root,BSTree_root); if(B2_root->lchild!=NULL) PreOrder(B2_root->lchild,BSTree_root); if(B2_root->rchild!=NULL) PreOrder(B2_root->rchild,BSTree_root); } ListNode* CreateBSTree(ListNode* B2_root) { ListNode* BSTree_root=NULL; PreOrder(B2_root,BSTree_root); return BSTree_root; }
标签:blog div log size c return as bs tt
原文地址:http://www.cnblogs.com/zsboy/p/3940423.html