题目:输入一棵二叉搜索树,将该二叉搜索树转换成一个排序的双向链表。要求不能创建新的节点,只能调整树中节点指针的指向。
解题思路:中序遍历就可解决。小->中->大
void doublelist(bTree *p,bTree **tail) //tail 为当前末尾的节点 { if(!p) return ; if(p->left) doublelist(p->left,tail); bTree *cur=p; cur->left=*tail; if(*tail!=NULL) *tail->right=cur; *tail=cur; if(p->right) doublelist(p->right,tail); }