二叉树左右子树的交换

本文应用博客https://blog.csdn.net/qq_43619271/article/details/121620184
二叉树左右子树的交换

// 递归交换
void swap(BiTree root) {
	if(root == NULL) return ;
	// 自下而上进行交换 
	swap(root->lchild);
	swap(root->rchild);
	// 用临时节点交换左右子树 
	BiTNode *temp = root->rchild;
	root->rchild = root->lchild;
	root->lchild = temp;
	return ;
} 


上一篇:Linux与JVM的内存关系分析


下一篇:什么是交换区