#include <iostream>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
typedef struct BtNode
{
char data;
struct BtNode *lchild;
struct BtNode *rchild;
}BtNode, *Bitree;
typedef struct Node
{
Bitree p;
int degree;
}Node, *pNode;
int createBtTree( Bitree *head )
{
int ret = 0;
char ch;
cin >> ch;
if( '#' == ch )
{
*head = NULL;
return ret;
}
Bitree pNode = new BtNode;
pNode->data = ch;
pNode->lchild = NULL;
pNode->rchild = NULL;
*head = pNode;
createBtTree( &(*head)->lchild );
createBtTree( &(*head)->rchild );
return ret;
}
// 三种递归遍历
void preTravel( Bitree head )
{
if( head != NULL )
{
cout << head->data << ' ';
preTravel( head->lchild );
preTravel( head->rchild );
}
return;
}
void midTravel( Bitree head )
{
if( head != NULL )
{
midTrav
面试题27:二叉搜索树按中序遍历原地转换为双向链表
最新推荐文章于 2021-07-29 17:58:47 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)