【Description】

At ree is a nonlinear data structure that models a hierarchical organization. The characteristic eatures are that each element may have several successors (called its “children”) and every element except one (called the “root”) has a unique predecessor (called its “parent”). Trees are common in computer science: Computer file systems are trees, the inheritance structure for Java classes is a tree, the run-time system of method invocations during the execution of a Java program is a tree, the classification of Java types is a tree, and the actual syntactical definition of the Java programming language itself forms a tree.

【Theorem】

Ø 

Ø 

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc3hiMDg0MTkwMTExNg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">

【TreesType】

Ø decision tree

A decision tree is a tree diagram that summarizes all the differents possible stages of a process that solve a problem by means of sequence of decisions. Rach internal node is a labeled with a question, each arc is laeled with an answer to its question, and each leaf node is labeled with the solution to the problem.

Five coins that appear identical are to be tested to determine which one of them is counterfeit. The only feature that distinguishes that the counterfeit coins is that it weights less than that the legitimate coins.

Ø transition diagram

A transition diagram is a tree or graphj whose internal nodes represent different states or situations that may occur during a multistage process. As in a decision tree, each leaf represents a diffenert outcome from the process. Each branch is labeled with the conditional probability that the resulting child event will occur., given that the parent event has occurred.

Ø Orredered trees

Here is the recursive definition of an ordered tree:

Anordered treeis either the empty set or a pair T= (r, S), where ris a node 

andSis a sequence of disjoint ordered trees, none of which contains r.

The node ris called the rootof the tree T, and the elements of the sequence Sare its subtrees.

【Traversal Algorithms】

A traversal algorithm is a method for processing a data structure that applies a given operation to each element of the structure. For example, if the operation is to print the contents of the element, then the traversal would print every element in the structure. THe process of applying the operation to the each element is called visiting the element. So executing the traversal algorithm causes each element in the structure to be visited.There are three common algorithms for traversing a general tree.

Ø Level order traversal

Thelevel order traversalalgorithm visits the root, then visits each element on the first level,

then visits each element on the second level, and so forth, each time visiting all the elements on one level before going down to the next level. If the tree is drawn in the usual manner with its root at the top and leaves near the bottom, then the level order pattern is the same left-to-right top-to-bottom pattern that you follow to read English text.

The level order traversal of the tree shown in above figure would visit the nodes in the following order: a, b,c,d, e, f, g, h,i,j, k, l, m.

Ø The preorder traversal

The preorder traversal algorithm visits the root first and then does a preorder traversal recursively to each subtree in order.

The preorder traversalof the tree shown in above figure would visit the nodes in this order: a,b,e, h,i,f, c, d, g, j, k,l, m.

Ø The postorder traversal

The postorder traversal algorithm does a postorder traversal recursively to each subtree before visiting the root.

The postorder traversal of the tree shown in figure would visit the nodes in the following order: h,i,e,f,b,c,j,k,l,m,g,d,a

【DataStructure】Description and Introduction of Tree的更多相关文章

  1. 【DataStructure】Description and usage of queue

    [Description] A queue is a collection that implements the first-in-first-out protocal. This means th ...

  2. 【BZOJ1803】Spoj1487 Query on a tree III 主席树+DFS序

    [BZOJ1803]Spoj1487 Query on a tree III Description You are given a node-labeled rooted tree with n n ...

  3. 【LeetCode】99. Recover Binary Search Tree 解题报告(Python)

    [LeetCode]99. Recover Binary Search Tree 解题报告(Python) 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/p ...

  4. 【LeetCode】Minimum Depth of Binary Tree 二叉树的最小深度 java

    [LeetCode]Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum dept ...

  5. 【BZOJ2843】极地旅行社(Link-Cut Tree)

    [BZOJ2843]极地旅行社(Link-Cut Tree) 题面 BZOJ 题解 \(LCT\)模板题呀 没什么好说的了.. #include<iostream> #include< ...

  6. 【BZOJ4530】大融合(Link-Cut Tree)

    [BZOJ4530]大融合(Link-Cut Tree) 题面 讨厌权限题!!! Loj链接 题目描述 小强要在 N个孤立的星球上建立起一套通信系统.这套通信系统就是连接 N个点的一个树.这个树的边是 ...

  7. 【BZOJ1969】航线规划(Link-Cut Tree)

    [BZOJ1969]航线规划(Link-Cut Tree) 题面 BZOJ 题解 删边操作 套路呀 离线读入倒过来做 变成加边操作 现在考虑怎么确定两点直接的关键路径条数 如果是一棵树,那么每条边都是 ...

  8. 【BZOJ4825】【HNOI2017】单旋(Link-Cut Tree)

    [BZOJ4825][HNOI2017]单旋(Link-Cut Tree) 题面 题面太长,懒得粘过来 题解 既然题目让你写Spaly 那就肯定不是正解 这道题目,让你求的是最大/最小值的深度 如果有 ...

  9. 【BZOJ3669】【Noi2014】魔法森林(Link-Cut Tree)

    [BZOJ3669][Noi2014]魔法森林(Link-Cut Tree) 题面 题目描述 为了得到书法大家的真传,小 E 同学下定决心去拜访住在魔法森林中的隐 士.魔法森林可以被看成一个包含 n ...

随机推荐

  1. Python开发:网络编程

    Python 提供了两个级别访问的网络服务.: 低级别的网络服务支持基本的 Socket,它提供了标准的 BSD Sockets API,可以访问底层操作系统Socket接口的全部方法. 高级别的网络 ...

  2. Configure Always On Availability Group for SQL Server on Ubuntu

    下面简单介绍一下如何在Ubuntu上一步一步创建一个SQL Server AG(Always On Availability Group),以及配置过程中遇到的坑的填充方法. 目前在Linux上可以搭 ...

  3. xfce-openvas9

    1安装OpenVas 第一步,添加PPA源,在这我用的是一台新装的Ubuntu安装OpenVas,运行以下命令就可以进行安装 root@ubuntu:~# add-apt-repository ppa ...

  4. 【Luogu】P3384主席树模板(主席树查询K小数)

    YEAH!我也是一个AC主席树模板的人了! 其实是个半吊子 我将尽量详细的讲出我的想法. 主席树太难,我们先搞普通线段树好了 普通线段树怎么做?我的想法是查询K次最小值,每次查完把查的数改成INF,查 ...

  5. 【Luogu】P1144最短路计数(BFS)

    题目链接 此题使用BFS记录最短路的条数.思路如下:因为是无权无向图,所以只要被BFS到就是最短路径.因此可以记录该点的最短路和最短路的条数:如果点y还没被访问过,则记录dis[y],同时令ans[y ...

  6. 栅格网络流(cogs 750)

    [问题描述] Bob 觉得一般图的最大流问题太难了,他不知道如何解决,于是他想尝试一个简单点的:栅格网络中的最大流问题,这个虽说简单了一点,但对 Bob 来说依旧太难,现在他有个麻烦需要你帮忙:给你一 ...

  7. Codeforces737E. Tanya is 5!

    $n \leq 40$个人玩$m \leq 10$台游戏机,每台游戏机一秒内只能一人玩,每人一秒内只能玩一台.每台游戏机有个价格,在规定总价格内可以把一部分游戏机复制一次,每台只能复制一次.给每个人对 ...

  8. Android网络编程之HttpClient运用

    Android网络编程之HttpClient运用 在 Android开发中我们经常会用到网络连接功能与服务器进行数据的交互,为此Android的SDK提供了Apache的HttpClient来方便我们 ...

  9. git fetch tag 获取远程tag

    获取远程的tag( 远程存在,本地不存在) git fetch origin tag 2.4.7 出现如下文字,说明获取远程tag成功 remote: Counting objects: 2, don ...

  10. WEB学习-CSS基础选择器

    基础选择器 标签选择器 就是标签的名字. • <h1>前端与移动开发<span>1期班</span>基础班</h1> css: • <style ...