Binary Tree_build & travserse(二叉树建立,遍历)
2016-10-31 22:12
239 查看
#include <stdio.h> #include <stdlib.h> struct Node{ char data; struct Node * left; struct Node * right; }; void Create(Node ** root){ char ch; scanf("%c", &ch); if(ch == '#') return; *root = (Node *)malloc(sizeof(struct Node)); (*root) -> data = ch; (*root) -> left = NULL; (*root) -> right = NULL; Create( &( (*root) ->left ) ); Create( &( (*root) ->right) ); } void Pre(Node * root){ if(root == NULL) return; printf("%c ", root -> data); Pre(root -> left); Pre(root -> right); } int main(){ Node * head; Create(&head); printf("input oVer\nPre order: "); Pre(head); printf("\n"); }
相关文章推荐
- 二叉树 建立 && 遍历 && 深度 && 树形打印 (增强版)
- 【暂无】 二叉树 根据遍历结果建立二叉树(build-tree.cpp)
- 数据结构——二叉树的建立和遍历(递归建树&层序遍历建树)
- JS建立二叉树&先序、中序、后序遍历
- 二叉树的建立&&前中后遍历(递归实现)&&层次遍历
- [面试备忘]求二叉树中节点最大距离 & 分层遍历二叉树
- 根据二叉树的先序遍历和中序遍历建立二叉树
- 笔试题:二叉树按层遍历&添加兄弟指针&求LCA&排序二叉树的查找
- 二叉树的建立删除及三种遍历实现
- 建立二叉树,先、中、后序遍历
- 题二 : 二叉树建立与遍历
- 数据结构_树_二叉树的建立、遍历、复制与移除_二叉链表存储_C++实现
- 数据结构:二叉树的建立和遍历(C#实现)
- 二叉树的建立和遍历
- 今天早上写的二叉树的建立及遍历
- Python练手之根据前序和中序&根据中序和后序重建二叉树,输出前序、中序和后序遍历结果
- 二叉树 建立二叉树 二叉树先、中、后序遍历 计算叶结点数 、树的深度
- 第五讲 树-1(广度优先遍历二叉树&深度优先遍历二叉树)
- 二叉树的几种非递归建立与遍历的实现
- 二叉树的建立与递归遍历C++版