题目:编写一个二叉树的中序遍历算法
分析:本题考查二叉树的遍历。
代码如下:(下面的代码采用的是递归遍历的算法)
typedef int ElemType; typedef struct BinaryTree { ElemType Data; struct BinaryTree * Left; struct BinaryTree * Right; }BinTree, *pBinTree; static void Print(pBinTree root) { if (NULL != root) { printf(" %d/n", root-> Data); } } void MidOrder(pBinTree root) //递归中序遍历 { if (NULL != root) { MidOrder (root-> Left); Print (root); MidOrder(root-> Right); }