基于二叉树遍历系统设计与实现
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
长春建筑学院《数据结构》课程设计(论文)
基于二叉树遍历系统设计与实现Binary tree traversal System Design and Implementation
年级:
学号:
姓名:
专业:
指导老师:
二零一三年十二月
摘要
针对现实世界中许多关系复杂的数据,如人类社会的家谱,各种社会组织机构,博弈交通等复杂事物或过程以及客观世界中广泛存在的具有分支关系或层次特性的对象.如操作系统的文件构成、人工智能和算法分析的模型表示以及数据库系统的信息组织形式等,用线性结构难以把其中的逻辑关系表达出来,必须借助于数和图这样的非线性结构,因此在以模拟客观世界问题,解决客观世界问题为主要任务的计算机领域中树型结构是信息的一种重要组织形式,树有着广泛应用。在树型结构的应用中又以二叉树最为常用。
二叉树是一种非常重要的非线性结构,所描述的数据有明显的层次关系,其中的每个元素只有一个前驱,二叉树是最为常用的数据结构,它的实际应用非常广泛,二叉树的遍历方式有三种,前序遍历,中序遍历,后序遍历,先序遍历的顺序为:NLR 先根结点,然后左子树,右子树;中序遍历顺序为;LNR先左子树,然后根结点,右子树;后序遍历顺序为:LRN先左子树,然后右子树,根结点。由前序和中序遍历,有中序和后序遍历序列可以唯一确定一棵二叉树。
对于给几个数据的排序或在已知的几个数据中进行查找,二叉树均能提供一种十分有效的方法,比如在查找问题上,任何借助于比较法查找长度为Ⅳ的一个序表的算法,都可以表示成一株二叉树。反之,任何二叉树都对应一个查找有序表的有效方法根据树的数学理论,对于算法分析的某些最有启发性的应用,是与给出用于计算各种类型中不同树的数目的公式有关的。
本文对二叉树以及二叉树的各种功能做介绍以及写出一些基本的程序,让读者对二叉树的理解有更好的效果。
关键词:二叉树;左子树;右子树
Abstract
In many real world of complex data, such as the human society family, social organization, widespread game traffic complex thing or process and the objective world with a branch or level characteristics of the object. If the operating system file analysis, artificial intelligence and algorithm model representation and database information system the form of organization, with a linear structure to express the logic relationship among them, must depend on the number and the diagram of such nonlinear structure, so in order to simulate the objective world, solve problems as the main task of the computer field in the tree structure is an important organization form of information, the tree has a broad application. In the application of tree structure in which the two fork tree is the most commonly used.
Two binary tree is a kind of very important nonlinear structure, hiberarchy description of the data, where each element is only a precursor, two fork tree is the most commonly used data structure, its application is very extensive, there are three kinds of two binary tree traversal, preorder traversal, in the traversal, postorder traversal, preorder traversal sequence: NLR to the root node, and then the left subtree, right subtree; in order traversal sequence; LNR before the left sub tree, then the root node, the right subtree; after the traversal order: LRN first and then the left subtree, right subtree, root node. By preorder traversal and traversal, with the order and post order traversal sequence can be uniquely identified a two binary tree.
For several data sorting or searching in several data known, two fork tree can provide a very effective method, such as search problems, any by the comparison method to find the length of a sequential algorithm of Table IV, can be expressed as a two fork tree. Conversely, any two fork tree corresponds to an effective method to find the ordered list according to the mathematical theory of tree, for some algorithm analysis of the application of heuristic, is given for the number and different types of tree calculation formula.
Various functions of two binary tree and binary tree in this paper two introduces and write some of the basic procedures, to allow readers to understand the two fork tree has a better effect.
Keywords:Two tree; the left subtree; right subtree