当前位置:网站首页>Tree Basics
Tree Basics
2022-06-11 20:29:00 【hotarugali】
【 notes 】 Refer to the textbook 「 Introduction to algorithms 」.
1. Free tree
1.1 Definition
Free tree Is a connected 、 Acyclic undirected graph , abbreviation Trees .
【 notes 】 A possibly disconnected 、 An acyclic undirected graph is called The forest .
1.2 Concept
- The degree of node : The degree of a node in a free tree is the same as that in an undirected graph , That is, the number of adjacent nodes .
1.3 nature
- Make G=(V,E) It's an undirected graph , Then the following description is equivalent :
- G Is a free tree .
- G Any two nodes are connected by a unique simple path .
- G It's connected , But the graph obtained by removing any edge from the graph is not connected .
- G It's connected , And ∣E∣=∣V∣−1 .
- G It's acyclic , And ∣E∣=∣V∣−1.
- G It's acyclic , But if to EEE Add any edge to the , Will cause the graph to contain a ring .
2. Rooting tree & Yes / Disordered trees
2.1 Definition
- Rooting tree Is a free tree , There is a root node in the node ( It's called root ).
- Ordered trees It's a tree with roots , The children of each node are orderly ( That is, the left-right positional relationship between the children of a node in the tree is influential ).
2.2 Concept
- The ancestors & Progeny : Consider the r For rooted trees T One of the nodes in x
- from r To x Any node on the only simple path y be called x One of the The ancestors . If y yes x The ancestors of the , be x yes y Of Progeny .
- Each node is both its own ancestor and its own offspring .
- If y yes x Our ancestors and x \ne y, be y yes x One of the True ancestors , And x yes One of the True offspring .
- Parents & children & brother : Consider from the tree T The root of the r To the node x The last edge on the simple path of is (y,x)
- y yes x Of Parents ,x yes y Of children .
- If two nodes have the same parents , Then they are brother .
- The root node is the only node in the tree that has no parents .
- leaf & Internal nodes
- A node without children is called leaf ( or External nodes ).
- A non leaf node is called Internal nodes .
- The degree of node : The degree of a node in a rooted tree refers to the number of children of the node , Parents of nodes are not included ( Different from the definition of free tree ).
- The degree of a tree : The degree of the largest node in a tree is called the degree of the tree .
- The depth of the node : From the root r To the node x The length of a simple path of is the node x stay T The depth of the . The depth of the root is 0 .
- The height of the node : The number of edges on the longest simple path from this node to the leaf node in the subtree with this node as the root node . The height of all leaf nodes is 0 .
- Depth of tree / Height : Equal to the maximum node depth in the tree / Maximum node height . Depth of tree = The height of the tree .
- Internal path length : Sum of depths of all internal nodes .
- External path length : Sum of the depths of all leaf nodes .
3. Binary tree & Location tree
【 notes 】 The definition of binary tree can be extended to k Fork tree .
3.1 Definition
- Binary tree T Is a structure defined on a finite set of nodes , It may or may not contain any nodes , Or contain three disjoint node sets :
- A root node .
- One is called The left subtree Two fork tree .
- One is called Right subtree Two fork tree .
- Location tree A tree in which children of nodes are marked as different positive integers . If no child is marked as an integer i , Then the... Of the node i Children are missing .
3.2 Concept
- Empty tree & Zero tree : A binary tree that contains no nodes , Sometimes symbols are used NIL Express .
- Left the child & The right child : If left / The right subtree is not empty , Then its root is called the left of the root of the whole tree / The right child .
- Full binary tree : Each node is a leaf node or has a degree of 2 The binary tree of is a full binary tree ( That is, a full binary tree has no degree 1 The node of ).
- Perfect binary tree : In a binary tree , If all the layers except the last one are full , And the last floor is either full , Or there are several consecutive nodes missing on the right , Then this binary tree is a complete binary tree .
- Perfect binary tree : All leaf nodes have the same depth , And all internal node degrees are 2 Two fork tree .
- Balanced binary trees (AVL Trees ): The height difference between two subtrees of any node is not greater than 1 Two fork tree .
3.3 nature
- A binary tree is a position tree , For each node , All tags are greater than 2 Of the children are missing .
- In any non empty binary tree 2 The number of degree nodes is less than that of leaf nodes 1 .
inference
- The number of leaf nodes is l The number of node elements of the full binary tree of is n=2l−1 .
- The number of node elements is n The number of leaf nodes of a perfect binary tree l = {(n+1) \over 2}, The number of non leaf nodes is n - l = l - 1 = {(n+1) \over 2} - 1.
- One has n The height of a non empty binary tree with nodes is at least \lfloor \lg n \rfloor.
- One height is h Full binary tree , The number of node elements n Satisfy 2h + 1 \leq n \leq 2^{h+1} - 1 .
边栏推荐
- ICML 2022 | 基于结构化数据的异常检测再思考:我们究竟需要怎样的图神经网络?...
- JMeter installation
- R 16 basic exercises
- The tutor transferred me 800 yuan and asked me to simulate a circuit (power supply design)
- 电源防反接和防倒灌 - 使用MOS 管和运放实现理想二极管
- 2022-2028 global and Chinese thermopile infrared sensor market status and future development trend
- 29. Objet de localisation
- Interpretation of OCP function of oceanbase Community Edition
- Two minutes to show you the charging standard of the Sub Ledger System
- Comp3411 -prolog language
猜你喜欢

Windows icon display exception resolution. The desktop icon is abnormal, the start menu icon is abnormal, and the taskbar icon is abnormal. Icon cache location.

A Mechanics-Informed Artificial Neural Network Approach in Data-Driven Constitutive Modeling 学习

Are there any techniques for 3D modeling?

浅聊对比学习(Contrastive Learning)第一弹

27. this指向问题

Gestionnaire de paquets d'Unit é Starting Server Stuck

Flutter Doctor affiche les solutions que xcode n'a pas installées

ICML 2022 𞓜 rethinking anomaly detection based on structured data: what kind of graph neural network do we need

周鸿祎:想做直播带货抹不下面子 数据勒索成突出的安全威胁

27. this pointing problem
随机推荐
使用flask框架写挡板
First modelarts training
Current situation and future development trend of hot isostatic pressing service market in the world and China from 2022 to 2028
26. timer
The latest test questions and answers for the eight major members (standard members) of Ningxia architecture in 2022
11 r create random number
黑圆圈显示实现
Three common sense that managers must know
Ora-01089 ora-19809 ora-19815 exceeded the limit for recovering files
Flutter doctor 顯示xcode沒有安裝的解决辦法
29. Objet de localisation
Detailed tutorial on installing MySQL database in Linux environment (including uninstallation and password reset process)
15 r exercise
Black circle display implementation
JMeter installation
Gestionnaire de paquets d'Unit é Starting Server Stuck
STL容器嵌套容器
The tutor transferred me 800 yuan and asked me to simulate a circuit (power supply design)
Interpretation of OCP function of oceanbase Community Edition
Leetcode 1992. Find all farm groups (yes, once)