数据结构二叉树C++代码
class bintreenode { private: bintreenode *leftchild,*rightchild; char data; public: bintreenode(char adata,bintreenode*aleftchild=NULL,bintreenode*arightchild=NULL) { data=adata; leftchild=aleftchild; rightchild=arightchild; } friend class bintree; }; class bintree { private: bintreenode *root; public: bintree() { root=new bintreenode('#'); } bintreenode*getroot() { return root; } void creatbintree(bintreenode*t); void indorder(bintreenode*t); void postorder(bintreenode*t); int levelorder(bintreenode*t); int leafcount(bintreenode*t); void free(bintreenode*t); }; bintree() { root=new bintreenode('#'); } bintreenode*getroot() { return root; } void creatbintree(bintreenode*t); void indorder(bintreenode*t); void postorder(bintreenode*t); int levelorder(bintreenode*t); int leafcount(bintreenode*t); void free(bintreenode*t); };
用户评论