炒米是什么米做的| 2.5什么星座| 孕妇不能吃什么东西| 鸡毛换糖是什么意思| 夏季什么时候最热| 大象什么颜色| arr是什么意思| 睡觉脚麻是什么原因| 茧子是什么意思| 咖喱是什么材料做的| 湿气重是什么意思| 主是什么结构的字体| 病毒性扁桃体炎吃什么药| 1985年属牛的是什么命| 胃酸是什么颜色的| 哺乳期可以吃什么感冒药| 什么都不怕| 测血糖挂号挂什么科| 八一是什么节| 812是什么意思| 四史指的是什么| 虱子用什么药可以根除| 自欺欺人是什么生肖| 脖子上长癣是什么原因| 渣男之首是什么星座| 什么是规培生| 减震器坏了有什么症状| 午餐肉是什么肉| 什么的生活| 老是嗜睡是什么原因| 为什么会长结节| 尿酸高是什么引起的| 厮守是什么意思| 下面有味道用什么药| 楚楚动人什么意思| 再生纤维素纤维是什么面料| 铁是补什么的| 胃窦充血水肿意味着什么| 中年人手抖是什么原因| 打封闭针有什么坏处| 白兰地兑什么饮料好喝| 翘首以盼是什么意思| 什么而不| 龟兔赛跑的故事告诉我们什么道理| 右眼流泪是什么原因| 为什么会猝死| 补钙吃什么维生素| 中国黄金为什么比其它金店便宜| 天蝎座与什么星座最配| 黑舌头的狗是什么狗| 一米阳光是什么意思| 清热利湿是什么意思| 叶酸基因检测是什么| 冠脉cta是什么检查| 骨质疏松吃什么好| 胎盘2级是什么意思| 为什么喝水血糖也会高| 阴道有腥味是什么原因| 射手男和什么星座最配| 茯苓长什么样子图片| 垫背是什么意思| 红枣为什么要炒黑再泡水喝| 朱雀玄武是什么意思| 国师代表什么生肖| 实字五行属什么| 破壁机什么牌子的最好| 为什么硬一会就软了| 天团是什么意思| 宝宝发烧是什么原因引起的| 睡觉为什么磨牙| 脾胃湿热什么症状| 反贪局局长是什么级别| 美女的阴暗是什么样的| 一张张什么| 尿道炎吃什么药好| 肝结节是什么病严重吗| 着凉吃什么药| flag是什么意思| 色纸是什么| 为什么医生不推荐特立帕肽呢| 子宫为什么长肌瘤| 淀粉是什么粉| 慢性活动性胃炎是什么意思| 蛋糕用什么面粉| 鸿运当头是什么菜| 赤道2什么时候上映| 荔枝和什么不能一起吃| 七月二十二什么日子| 恏是什么意思| 别开生面是什么意思| 告辞是什么意思| 九月二十四号是什么星座| 血糖高什么水果能吃| 吃了避孕药后几天出血是什么原因| 气短气喘吃什么药| 什么是电子邮件地址| 茯苓有什么作用和功效| 一级军士长是什么级别| 戏谑什么意思| 红色血痣是什么原因| 菌群异常是什么意思| 费玉清为什么不结婚| esd手术是什么意思| 三点水加尺念什么| 仔字五行属什么| 看什么| 东南方五行属什么| 奇异是什么意思| 鼻头长痘痘什么原因| 9月10日是什么节| 禅宗是什么意思| 旻字五行属什么| 耳朵发炎吃什么药| 原位癌是什么意思| 女人吃鹅蛋有什么好处| 孛儿只斤现在姓什么| 奥美拉唑什么时候吃最好| 一什么牙刷| 为什么一动就出汗| 豆支念什么| 嘈杂是什么意思| 成都市市长是什么级别| 贫血的人吃什么好| 突然头晕想吐是什么原因| 咽喉炎是什么原因引起的| 窝窝头是用什么做的| 吃什么会导致流产| 腋毛有什么作用| 息肉和囊肿有什么区别| 259是什么意思| 碧玉是什么玉| 肛周脓肿吃什么药| 夏天哈尔滨有什么好玩的地方| 小儿湿疹是什么原因造成的| 虎头什么尾| 擦边球是什么意思| 维生素c不能和什么一起吃| 什么叫钝角| 参加追悼会穿什么衣服| 伟哥有什么副作用| 头发汗多是什么原因| 佝偻病是什么症状| 汗毛重是什么原因| 半岛铁盒是什么| 过早是什么意思| 左肾轻度积水是什么意思| 猪狗不如是什么意思| 宝宝反复发烧是什么原因引起的| 印度阿三是什么意思| 燥湿什么意思| 211是什么| 过期红酒有什么用途| 肾炎什么症状| 孕妇梦见老公出轨是什么意思| 枸杞加红枣泡水喝有什么功效| 什么时候吃姜最好| 什么情况下怀疑白血病| 拔智齿后需要注意什么| 粉皮是什么做的| 鞑靼是什么意思| 思觉失调是什么意思| 穿山甲说了什么| 天宫是什么意思| 告状是什么意思| 辛辣是什么意思| 尿频繁是什么原因| 58年属什么今年多大| 主管护师是什么职称| 血压偏高吃什么药| 日入是什么时辰| qn是什么医嘱| 川流不息什么意思| hg是什么元素| 腰穿是什么意思| 九点到十点是什么时辰| 璎珞是什么意思| hba是什么意思| 做b超前需要注意什么| 床垫选什么材质的好| 盐酸西替利嗪片主治什么| 免疫力低有什么症状| 中联办是什么级别| pvd是什么材料| 脾胃伏火是什么意思| sars是什么意思| 21金维他有什么作用| 对辣椒过敏有什么症状| 脂质是什么| 中考送什么礼物| 龙和什么属相最配| 梦到和老公离婚了是什么征兆| 漫山遍野是什么生肖| 腹泻输液用什么药| 什么是艾滋病| 西藏有什么大学| 落花雨你飘摇的美丽是什么歌| 流产后吃什么水果最佳| 流连忘返是什么生肖| 国企是什么意思| 45岁属什么| 西瓜不可以和什么同食| 梅菜扣肉的梅菜是什么菜| 咏柳是什么意思| 房颤吃什么药效果最好| 心理健康是什么| 便秘吃什么最快排便小孩| 白羊跟什么星座最配| 杜建英是宗庆后什么人| hoegaarden是什么啤酒| 女人什么年龄性最旺| 吃马齿菜有什么好处| 左侧头皮发麻是什么原因| 刺猬喜欢吃什么食物| 背影杀是什么意思| 尿急尿频吃什么药| 易孕体质是什么意思| 岩茶是什么茶类| 动物蛋白是什么| 醋酸视黄酯是什么| 吃什么会变丑脑筋急转弯| 袁绍和袁术是什么关系| 描红是什么意思| 离经之血是什么意思| 为什么尿酸高| 梦到蛇什么意思| 小猫踩奶是什么意思| 戒色是什么意思| 妇科检查白细胞酯酶阳性是什么意思| 猫喜欢什么样的人| nm是什么单位| 长生殿讲的是什么故事| 泉肌症是什么病| 陈醋和白醋有什么区别| 主心骨是什么意思| 感冒不能吃什么| 胃酸过多吃点什么食物比较好| 今年是什么| 万花筒是什么| 妲己属什么生肖| 为什么受伤的总是我| 什么是零售| 甲钴胺片是治什么病| 血糖高适合吃什么| 小肠与什么相表里| 胃出血有什么症状| 全身瘙痒是什么原因| 胳膊麻是什么原因| 壮阳吃什么药| 神经官能症挂什么科| vs什么意思| 春天的花开秋天的风是什么歌| 位数是什么意思| 什么地生长| 单从属于什么茶| 做t是什么意思| 八府巡按是什么官| 挂什么科| 1997年属什么生肖年| 什么是高筋面粉| 圣是什么生肖| 内裤发黄是什么原因呢| 手抖心慌是什么原因| n字鞋子是什么牌子| 吃什么能补钙| 百度Jump to content

达克宁栓治疗什么妇科病

From Wikipedia, the free encyclopedia
This unsorted tree has non-unique values (e.g., the value 2 existing in different nodes, not in a single node only) and is non-binary (while there are only up to two children nodes per parent node in a binary tree). The root node at the top (with the value 2 here), has no parent as it is the highest in the tree hierarchy.
百度 为什么要绑定真实姓名和身份证号码(或港澳台通行证)?为了保障您的大奖安全,彩票中心要求获奖人(单注奖金10万以上)提供身份证数码照/复印件或港澳台通行证以核实得主身份。

In computer science, a tree is a widely used abstract data type that represents a hierarchical tree structure with a set of connected nodes. Each node in the tree can be connected to many children (depending on the type of tree), but must be connected to exactly one parent,[1][2] except for the root node, which has no parent (i.e., the root node as the top-most node in the tree hierarchy). These constraints mean there are no cycles or "loops" (no node can be its own ancestor), and also that each child can be treated like the root node of its own subtree, making recursion a useful technique for tree traversal. In contrast to linear data structures, many trees cannot be represented by relationships between neighboring nodes (parent and children nodes of a node under consideration, if they exist) in a single straight line (called edge or link between two adjacent nodes).

Binary trees are a commonly used type, which constrain the number of children for each parent to at most two. When the order of the children is specified, this data structure corresponds to an ordered tree in graph theory. A value or pointer to other data may be associated with every node in the tree, or sometimes only with the leaf nodes, which have no children nodes.

The abstract data type (ADT) can be represented in a number of ways, including a list of parents with pointers to children, a list of children with pointers to parents, or a list of nodes and a separate list of parent-child relations (a specific type of adjacency list). Representations might also be more complicated, for example using indexes or ancestor lists for performance.

Trees as used in computing are similar to but can be different from mathematical constructs of trees in graph theory, trees in set theory, and trees in descriptive set theory.

Terminology

[edit]

A node is a structure which may contain data and connections to other nodes, sometimes called edges or links. Each node in a tree has zero or more child nodes, which are below it in the tree (by convention, trees are drawn with descendants going downwards). A node that has a child is called the child's parent node (or superior). All nodes have exactly one parent, except the topmost root node, which has none. A node might have many ancestor nodes, such as the parent's parent. Child nodes with the same parent are sibling nodes. Typically siblings have an order, with the first one conventionally drawn on the left. Some definitions allow a tree to have no nodes at all, in which case it is called empty.

An internal node (also known as an inner node, inode for short, or branch node) is any node of a tree that has child nodes. Similarly, an external node (also known as an outer node, leaf node, or terminal node) is any node that does not have child nodes.

The height of a node is the length of the longest downward path to a leaf from that node. The height of the root is the height of the tree. The depth of a node is the length of the path to its root (i.e., its root path). Thus the root node has depth zero, leaf nodes have height zero, and a tree with only a single node (hence both a root and leaf) has depth and height zero. Conventionally, an empty tree (tree with no nodes, if such are allowed) has height ?1.

Each non-root node can be treated as the root node of its own subtree, which includes that node and all its descendants.[a][3]

Other terms used with trees:

Neighbor
Parent or child.
Ancestor
A node reachable by repeated proceeding from child to parent.
Descendant
A node reachable by repeated proceeding from parent to child. Also known as subchild.
Degree
For a given node, its number of children. A leaf, by definition, has degree zero.
Degree of tree
The degree of a tree is the maximum degree of a node in the tree.
Distance
The number of edges along the shortest path between two nodes.
Level
The level of a node is the number of edges along the unique path between it and the root node.[4] This is the same as depth.
Width
The number of nodes in a level.
Breadth
The number of leaves.
Complete tree
A tree with every level filled, except the last.
Forest
A set of one or more disjoint trees.
Ordered tree
A rooted tree in which an ordering is specified for the children of each vertex.
Size of a tree
Number of nodes in the tree.

Common operations

[edit]
  • Enumerating all the items
  • Enumerating a section of a tree
  • Searching for an item
  • Adding a new item at a certain position on the tree
  • Deleting an item
  • Pruning: Removing a whole section of a tree
  • Grafting: Adding a whole section to a tree
  • Finding the root for any node
  • Finding the lowest common ancestor of two nodes

Traversal and search methods

[edit]

Stepping through the items of a tree, by means of the connections between parents and children, is called walking the tree, and the action is a walk of the tree. Often, an operation might be performed when a pointer arrives at a particular node. A walk in which each parent node is traversed before its children is called a pre-order walk; a walk in which the children are traversed before their respective parents are traversed is called a post-order walk; a walk in which a node's left subtree, then the node itself, and finally its right subtree are traversed is called an in-order traversal. (This last scenario, referring to exactly two subtrees, a left subtree and a right subtree, assumes specifically a binary tree.) A level-order walk effectively performs a breadth-first search over the entirety of a tree; nodes are traversed level by level, where the root node is visited first, followed by its direct child nodes and their siblings, followed by its grandchild nodes and their siblings, etc., until all nodes in the tree have been traversed.

Representations

[edit]

There are many different ways to represent trees. In working memory, nodes are typically dynamically allocated records with pointers to their children, their parents, or both, as well as any associated data. If of a fixed size, the nodes might be stored in a list. Nodes and relationships between nodes might be stored in a separate special type of adjacency list. In relational databases, nodes are typically represented as table rows, with indexed row IDs facilitating pointers between parents and children.

Nodes can also be stored as items in an array, with relationships between them determined by their positions in the array (as in a binary heap).

A binary tree can be implemented as a list of lists: the head of a list (the value of the first term) is the left child (subtree), while the tail (the list of second and subsequent terms) is the right child (subtree). This can be modified to allow values as well, as in Lisp S-expressions, where the head (value of first term) is the value of the node, the head of the tail (value of second term) is the left child, and the tail of the tail (list of third and subsequent terms) is the right child.

Ordered trees can be naturally encoded by finite sequences, for example with natural numbers.[5]

Examples of trees and non-trees

[edit]
Not a tree: two non-connected parts, A→B and C→D→E. There is more than one root.
Not a tree: undirected cycle 1-2-4-3. 4 has more than one parent (inbound edge).
Not a tree: cycle B→C→E→D→B. B has more than one parent (inbound edge).
Not a tree: cycle A→A. A is the root but it also has a parent.
Each linear list is trivially a tree.

Type theory

[edit]

As an abstract data type, the abstract tree type T with values of some type E is defined, using the abstract forest type F (list of trees), by the functions:

value: TE
children: TF
nil: () → F
node: E × FT

with the axioms:

value(node(e, f)) = e
children(node(e, f)) = f

In terms of type theory, a tree is an inductive type defined by the constructors nil (empty forest) and node (tree with root node with given value and children).

Mathematical terminology

[edit]

Viewed as a whole, a tree data structure is an ordered tree, generally with values attached to each node. Concretely, it is (if required to be non-empty):

  • A rooted tree with the "away from root" direction (a more narrow term is an "arborescence"), meaning:
    • A directed graph,
    • whose underlying undirected graph is a tree (any two vertices are connected by exactly one simple path),[6]
    • with a distinguished root (one vertex is designated as the root),
    • which determines the direction on the edges (arrows point away from the root; given an edge, the node that the edge points from is called the parent and the node that the edge points to is called the child), together with:
  • an ordering on the child nodes of a given node, and
  • a value (of some data type) at each node.

Often trees have a fixed (more properly, bounded) branching factor (outdegree), particularly always having two child nodes (possibly empty, hence at most two non-empty child nodes), hence a "binary tree".

Allowing empty trees makes some definitions simpler, some more complicated: a rooted tree must be non-empty, hence if empty trees are allowed the above definition instead becomes "an empty tree or a rooted tree such that ...". On the other hand, empty trees simplify defining fixed branching factor: with empty trees allowed, a binary tree is a tree such that every node has exactly two children, each of which is a tree (possibly empty).

Applications

[edit]

Trees are commonly used to represent or manipulate hierarchical data in applications such as:

Trees can be used to represent and manipulate various mathematical structures, such as:

Tree structures are often used for mapping the relationships between things, such as:

JSON and YAML documents can be thought of as trees, but are typically represented by nested lists and dictionaries.

See also

[edit]

Notes

[edit]
  1. ^ This is different from the formal definition of subtree used in graph theory, which is a subgraph that forms a tree – it need not include all descendants. For example, the root node by itself is a subtree in the graph theory sense, but not in the data structure sense (unless there are no descendants).

References

[edit]
  1. ^ Subero, Armstrong (2020). "3. Tree Data Structure". Codeless Data Structures and Algorithms. Berkeley, CA: Apress. doi:10.1007/978-1-4842-5725-8. ISBN 978-1-4842-5724-1. A parent can have multiple child nodes. ... However, a child node cannot have multiple parents. If a child node has multiple parents, then it is what we call a graph.
  2. ^ "Abstract Tree / Tree ADT | Abstract Data Types | ECE 250 | University of Waterloo". ece.uwaterloo.ca. Retrieved 2025-08-06.
  3. ^ Weisstein, Eric W. "Subtree". MathWorld.
  4. ^ Susanna S. Epp (Aug 2010). Discrete Mathematics with Applications. Pacific Grove, CA: Brooks/Cole Publishing Co. p. 694. ISBN 978-0-495-39132-6.
  5. ^ L. Afanasiev; P. Blackburn; I. Dimitriou; B. Gaiffe; E. Goris; M. Marx; M. de Rijke (2005). "PDL for ordered trees" (PDF). Journal of Applied Non-Classical Logics. 15 (2): 115–135. doi:10.3166/jancl.15.115-135. S2CID 1979330.
  6. ^ Levin, Oscar (31 December 2018). Discrete Mathematics: An Open Introduction (3rd ed.). Amazon Digital Services LLC - Kdp. p. 247. ISBN 978-1792901690.

Further reading

[edit]
[edit]
o和b型生的孩子是什么血型 害怕的近义词是什么 胃气上逆是什么原因 湿热内蕴证有什么症状 什么的柳枝
未见胎芽是什么意思 金牛座和什么座最配 做阴超有黄体说明什么 莘字五行属什么 润月是什么意思
放疗起什么作用 氧化剂是什么 为什么肚子会胀气 肺栓塞有什么症状 打嗝和嗳气有什么区别
舌头紫红色是什么原因 农历6月28日是什么星座 花椒和麻椒有什么区别 情难自禁是什么意思 雍是什么意思
职业病是什么意思hcv8jop4ns2r.cn 不可亵玩焉的亵是什么意思hcv7jop9ns9r.cn 甲鱼什么人不能吃hcv8jop9ns6r.cn 结婚证需要什么资料hcv9jop8ns1r.cn 骨肉瘤是什么病xinjiangjialails.com
鸡和什么菜一起烧好吃hcv8jop3ns4r.cn 金刚是什么树的种子hcv8jop9ns9r.cn 丁目是什么意思hcv9jop5ns6r.cn 肝藏血是什么意思hcv9jop1ns6r.cn 7朵玫瑰花代表什么意思hcv9jop0ns5r.cn
梦见小孩是什么hcv7jop9ns5r.cn 五什么六什么的成语hcv9jop2ns7r.cn 一什么水珠hcv9jop0ns7r.cn 中戏是什么学校hcv9jop1ns4r.cn ysl是什么品牌hcv8jop5ns5r.cn
什么是超纤皮hcv7jop6ns3r.cn 男士脸黑穿什么颜色好hcv8jop2ns5r.cn 什么人不能吃桃子hcv8jop2ns0r.cn 脚膜炎用什么药最好helloaicloud.com 腰果不能和什么一起吃hcv9jop6ns0r.cn
百度