【DataStructure】Description and Introduction of Tree
【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的更多相关文章
- 【DataStructure】Description and usage of queue
[Description] A queue is a collection that implements the first-in-first-out protocal. This means th ...
- 【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 ...
- 【LeetCode】99. Recover Binary Search Tree 解题报告(Python)
[LeetCode]99. Recover Binary Search Tree 解题报告(Python) 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/p ...
- 【LeetCode】Minimum Depth of Binary Tree 二叉树的最小深度 java
[LeetCode]Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum dept ...
- 【BZOJ2843】极地旅行社(Link-Cut Tree)
[BZOJ2843]极地旅行社(Link-Cut Tree) 题面 BZOJ 题解 \(LCT\)模板题呀 没什么好说的了.. #include<iostream> #include< ...
- 【BZOJ4530】大融合(Link-Cut Tree)
[BZOJ4530]大融合(Link-Cut Tree) 题面 讨厌权限题!!! Loj链接 题目描述 小强要在 N个孤立的星球上建立起一套通信系统.这套通信系统就是连接 N个点的一个树.这个树的边是 ...
- 【BZOJ1969】航线规划(Link-Cut Tree)
[BZOJ1969]航线规划(Link-Cut Tree) 题面 BZOJ 题解 删边操作 套路呀 离线读入倒过来做 变成加边操作 现在考虑怎么确定两点直接的关键路径条数 如果是一棵树,那么每条边都是 ...
- 【BZOJ4825】【HNOI2017】单旋(Link-Cut Tree)
[BZOJ4825][HNOI2017]单旋(Link-Cut Tree) 题面 题面太长,懒得粘过来 题解 既然题目让你写Spaly 那就肯定不是正解 这道题目,让你求的是最大/最小值的深度 如果有 ...
- 【BZOJ3669】【Noi2014】魔法森林(Link-Cut Tree)
[BZOJ3669][Noi2014]魔法森林(Link-Cut Tree) 题面 题目描述 为了得到书法大家的真传,小 E 同学下定决心去拜访住在魔法森林中的隐 士.魔法森林可以被看成一个包含 n ...
随机推荐
- 基于FTP服务器搭建yum源
本例以CentOS6.8为试验对象,来搭建基于FTP服务器的yum源. 一.配置本地yum源 1.创建挂载目录/yum mkdir /yum 2.挂载镜像 mount -o loop CentOS- ...
- JavaScript onload
The onload event occurs immediately after a page or an image is loaded.onload事件当一个页面或是一张图片加载完成时被触发. ...
- 【Android】android:ellipsize的使用以及一个点解决方法
EidtText和textview中内容过长的话自动换行,使用android:ellipsize与android:singleine可以解决,使只有一行. EditText不支持marquee 用法如 ...
- iOS学习笔记13-网络(二)NSURLSession
在2013年WWDC上苹果揭开了NSURLSession的面纱,将它作为NSURLConnection的继任者.现在使用最广泛的第三方网络框架:AFNetworking.SDWebImage等等都使用 ...
- 【bzoj4605】崂山白花蛇草水 权值线段树套KD-tree
题目描述 神犇Aleph在SDOI Round2前立了一个flag:如果进了省队,就现场直播喝崂山白花蛇草水.凭借着神犇Aleph的实力,他轻松地进了山东省省队,现在便是他履行诺言的时候了.蒟蒻Bob ...
- BZOJ3926 [Zjoi2015]诸神眷顾的幻想乡 【广义后缀自动机】
题目 幽香是全幻想乡里最受人欢迎的萌妹子,这天,是幽香的2600岁生日,无数幽香的粉丝到了幽香家门前的太阳花田上来为幽香庆祝生日. 粉丝们非常热情,自发组织表演了一系列节目给幽香看.幽香当然也非常高兴 ...
- 常州模拟赛d4t1 立方体
题目描述 立方体有 6 个面,每个面上有一只奶牛,每只奶牛都有一些干草.为了训练奶牛的合作精神,它 们在玩一个游戏,每轮:所有奶牛将自己的干草分成 4 等份,分给相邻的 4 个面上的奶牛. 游戏开始, ...
- Spoj-ANTP Mr. Ant & His Problem
Mr. Ant has 3 boxes and the infinite number of marbles. Now he wants to know the number of ways he c ...
- mysql解压之后的安装
远程连接报错(error:10061)看这篇:https://www.cnblogs.com/zipon/p/5877820.html 从5.6.20之后root会自动生成一个随机密码在/root/. ...
- Volley 源码解析 StringRequest解析
Android Vollety是一个很有用的框架,所以想借鉴前人思想,分析这个源代码. 参考: http://blog.csdn.net/crazy__chen/article/details/464 ...