Advertisement

二叉树的前中后序遍历及其递归与非递归实现-C语言

阅读量:
复制代码
    #include <stdio.h>
    #include<stdlib.h> 
    /* run this program using the console pauser or add your own getch, system("pause") or input loop */
    //二叉树的存储结构
    typedef struct TreeNode
    {
    	char data;
    	TreeNode* lchild;
    	TreeNode* rchild;
    }BinTree;
    #define ElementType BinTree*
    //栈的存储结构
    typedef struct node
    {
    	ElementType data;
    	struct node* next;
    }Stack;
    Stack* creatStack()//创建一个带头的栈
    {
    	Stack* s=(Stack*)malloc(sizeof(node));
    	s->next=NULL;
    	return s;
    	
    }
    bool isEmpty(Stack* s)//判断栈是否为空
    {
    	if(s->n

全部评论 (0)

还没有任何评论哟~