//filename:bitree.h
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#define OK 1
#define ERROR 0
#define TRUE 1
#define FALSE 0
#define NIL '#' //定义'#'为空节点
typedef struct queue_node qnode;
typedef struct bitree_node bitree;
struct bitree_node
{
char elem;
bitree *lchild;
bitree *rchild;
};
/*队列节点*/
struct queue_node
{
bitree *btn;
qnode *next;
};
typedef struct link_queue
{
qnode *head;
qnode *tail;
}queue;
/*****队列的基本操作******/
int init_link_queue(queue *Q);
int is_queue_empty(queue Q);
int enqueue(queue *Q, bitree *btn);
int dequeue(queue *Q, char *elem);
/*****二叉树的操作*****/
bitree *create_bitree();
int is_bitree_empty(bitree *btn);
int get_bitree_depth(bitree *btn);
bitree *get_parent(bitree *btn, char elem);
int preorder_traverse(bitree *btn, int (*visit)(char));
int inorder_traverse(bitree *btn, int (*visit)(char));
int postorder_traverse(bitree *btn, int (*visit)(char));
int levelorder_traverse(bitree *btn, int (*visit)(char));
int destory_bitree(bitree *btn);
int print_elem(char elem);
//filename:queue.c
#include "bitree.h"
/*
功能:链队列初始化
*/
int init_link_queue(queue *Q)
{
qnode *tmp_node = (qnode *)malloc(sizeof(qnode));
if(!tmp_node)
{
re