欢迎来到天天文库
浏览记录
ID:19604562
大小:113.50 KB
页数:21页
时间:2018-10-03
《数据结构b类红黑二叉树》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#include#include#include#include#include#defineTRUE1#defineBOOLint#defineFALSE0#defineStatusintenumcolor_t{RED,BlACK};typedefstructRedBlackNode//红黑二叉树结构体{intdata;charphone[12];charname[12];//数据域color_tco
2、lor;//颜色RedBlackNode*left;//左孩子RedBlackNode*right;//右孩子RedBlackNode*parent;//父亲节点}RedBlackNode,*RBTree;typedefstructLinkStack{RedBlackNode*rbtree;structLinkStack*next;}LinkStack;LinkStack*InitStack();StatusStackEmpty(LinkStack*L);StatusDestroyStack(Link
3、Stack*L);StatusStackLength(LinkStack*L);StatusPushStack(LinkStack*L,RedBlackNode*r);RedBlackNode*PopStack(LinkStack*L);RedBlackNode*RBserach(RedBlackNode*rbtree,intkey);RedBlackNode*RBMinimum(RBTree*T);RedBlackNode*RBMaximum(RBTree*T);RedBlackNode*RBpio
4、neer(RedBlackNode*T);RedBlackNode*RBsucceed(RedBlackNode*T);voidleft_rotate(RBTree*rbtree,RedBlackNode*T);voidright_rotate(RBTree*retree,RedBlackNode*T);BOOLRBInsertNode(RBTree*T,intdata);intRBDeleteNode(RBTree*T,intdata);voidRbTreeInsertAdjust(RBTree*T
5、,RedBlackNode*p);voidRbTreeDeleteAdjust(RBTree*T,RedBlackNode*parent,RedBlackNode*x);voidOutput(RedBlackNode*p);voidPreorderTraverse(RedBlackNode*T);voidInorderTraverse(RedBlackNode*T);voidPostorderTraverse(RedBlackNode*T);intprerecursion(RedBlackNode*T
6、);intinrecursion(RedBlackNode*T);intpostrecursion(RedBlackNode*T);voidmenu1();voidmenu2();voidlogon();LinkStack*InitStack(){LinkStack*L;L=(LinkStack*)malloc(sizeof(LinkStack));L->next=NULL;returnL;}StatusStackEmpty(LinkStack*L){if(L->next){returnFALSE;}
7、else{returnTRUE;}}StatusDestroyStack(LinkStack*L){LinkStack*p,*r,*q;p=L->next;r=L;if(p==NULL){returnFALSE;}while(p!=NULL){r->next=p->next;q=p;p=p->next;free(q);}free(L);returnTRUE;}StatusStackLength(LinkStack*L){inti=0;LinkStack*p;p=L->next;if(L==NULL){
8、returnFALSE;}while(p!=NULL){i++;p=p->next;}returni;}RedBlackNode*PopStack(LinkStack*L){LinkStack*p;RedBlackNode*q;p=L;while(p->next&&p->next->next!=NULL){p=p->next;}q=p->next->rbtree;p->next=NULL;returnq;}StatusPushStack(LinkStac
此文档下载收益归作者所有