1、数据结构课程设计 0 数据结构课程设计报告数据结构课程设计报告 设计题目:设计题目: 二叉树的遍历二叉树的遍历 姓姓 名:名: 学学 号:号: 专专 业:业: 计算机科学与技术计算机科学与技术 院院 系:系: 计算机科学与技术计算机科学与技术 班班 级:级: 指导教师:指导教师: 20122012 年年 3 3 月月 1 1 日日 数据结构课程设计 1 摘要摘要:本文主要说明如何实现二叉树的遍历。 此次二叉树的遍历基于 二叉树的二叉链表存储结构。遍历方式包括:前序遍历,中序遍历, 后续遍历, 层序遍历。 其中前序遍历和后续遍历采用非递归算法实现。 编程环境为 VC+,除了遍历操作外,还增加了求
2、二叉树的深度,总 结点数,每层结点数,以及最近共同祖先(LCA)问题的算法。 关键字:关键字:二叉树 遍历 非递归 C+ LCA 数据结构课程设计 2 Abstract: Abstract: This paper mainly describes how to implement binary tree traversal. The binary tree traversal is based on binary tree binary storage structure. Traversal method includes: preorder traversal,inorder traver
3、sal, postorder traversal, levelorder traversal. The former preorder traversal and postorder use of non - recursive algorithm. Programming environment is VC + +, in addition to traversal operation, also increased for solving the binary tree depth 、 summary points and each layer of nodes, as well as t
4、he most recent common ancestor ( LCA ) algorithm. Keywords:Keywords: binary tree traversal non-recursive C+ LCA 数据结构课程设计 3 目目 录录 一、问题描述一、问题描述 4 问题描述:创建二叉树并遍历问题描述:创建二叉树并遍历 . 4 基本要求:基本要求: . 4 二、需求分析二、需求分析 4 三、概要设计三、概要设计 4 1创建二叉树创建二叉树 4 2二叉树的非递归前序遍历示意图二叉树的非递归前序遍历示意图 4 3 3二叉树的后序非递归遍历二叉树的后序非递归遍历示意图示意图 5 四、数据结构设计四、数据结构设计 . 5 1 二叉树结点数据类型定义为:二叉树结点数据类型定义为: 5 2 二叉树数据类型定义为:二叉树数据类