Directed Tree: Difference between revisions
Jump to navigation
Jump to search
Line 16: | Line 16: | ||
= Order of Tree Nodes = | = Order of Tree Nodes = | ||
Let <math>T = (V,A)</math> be a search tree with root <math>r</math>. The '''range''' of a node is defined recursively: | |||
# First let <math>T</math> be a binary tree: | |||
## The range of <math>r</math> is <math>\Kappa</math>. | |||
## Let <math>u \in V</math>. If existing, let <math>(u,v)</math> and <math>(u,v)</math> denote the left and right arc of <math>u</math>, respectively. The ranges <math>R_v</math> of <math>v</math> and <math>R_w</math> of <math>w</math> are defined as follows: | |||
### <math>R_v := R_u \cap \{K \in \Kappa | K \leq K_u\}</math> | |||
### <math>R_w := R_u \cap \{K \in \Kappa | K \geq K_u\}</math> | |||
# Now let <math>T = (V,A)</math> be a mutli-way search tree: | |||
## Again, the range of <math>r</math> is <math>\Kappa</math>. | |||
## For <math>v \in V\setminus\{r\}</math>, let <math>w \in V</math> denote the parent node, and let <math>i</math> be the position of <math>(w,v)</math> in the ordered sequence of outgoing arcs of <math>w</math>. Then the '''range''' of <math>v</math> is | |||
### <math>R_v := \{K \in R_w | K \leq minS_w\}</math>, if <math>i = 0</math>; | |||
### <math>R_v := \{K \in R_w | K \geq maxS_w\}</math>, if <math>i = |S_w|</math>; | |||
### <math>R_v := \{K \in R_w | K \geq a, K \leq b\}</math>, otherwise, where <math>a,b \in S_w</math> are the <math>i</math>-th and <math>(i + 1)</math>-st element of <math>S_w</math> in the sorting order of [[Genericity|comparison]] <math>c</math>. | |||
= Immediate Predecessor and Successor = | = Immediate Predecessor and Successor = |
Revision as of 19:15, 29 September 2014
Definitions
- A directed tree is a directed graph [math]\displaystyle{ T = (V,A) }[/math] with a designated node [math]\displaystyle{ r \in V }[/math], the root, such that for each node [math]\displaystyle{ v \in V }[/math], there is exactly one path from [math]\displaystyle{ r }[/math] to [math]\displaystyle{ v }[/math] in [math]\displaystyle{ T }[/math].
- A directed tree [math]\displaystyle{ T = (V,A) }[/math] is called binary if each node's outdegree is at most [math]\displaystyle{ 2 }[/math].
- The subtree of [math]\displaystyle{ T }[/math] rooted at [math]\displaystyle{ v \in V }[/math] is the subgraph induced by all nodes that are reachable from [math]\displaystyle{ v }[/math] via paths in [math]\displaystyle{ T }[/math] (including [math]\displaystyle{ v }[/math]). In particular, [math]\displaystyle{ T }[/math] is the subtree of [math]\displaystyle{ T }[/math] rooted at [math]\displaystyle{ r }[/math].
- For an arc [math]\displaystyle{ (v,w) }[/math] in a directed tree, [math]\displaystyle{ w }[/math] is a child of [math]\displaystyle{ v }[/math], and [math]\displaystyle{ v }[/math] is the (unique) parent of [math]\displaystyle{ w }[/math].
- The height level of a node in a directed tree is recursivley defined as follows:
- The height level of the root is [math]\displaystyle{ 0 }[/math]
- The height level of any other node is one more than the height level of its parent.
- The height of an empty tree is [math]\displaystyle{ -1 }[/math]. For a non-empty tree, the height of the tree is the maximum height level of all of its nodes.
Binary Search Tree
Multi-way Search Trees
Ranges of Search Tree Nodes
Order of Tree Nodes
Let [math]\displaystyle{ T = (V,A) }[/math] be a search tree with root [math]\displaystyle{ r }[/math]. The range of a node is defined recursively:
- First let [math]\displaystyle{ T }[/math] be a binary tree:
- The range of [math]\displaystyle{ r }[/math] is [math]\displaystyle{ \Kappa }[/math].
- Let [math]\displaystyle{ u \in V }[/math]. If existing, let [math]\displaystyle{ (u,v) }[/math] and [math]\displaystyle{ (u,v) }[/math] denote the left and right arc of [math]\displaystyle{ u }[/math], respectively. The ranges [math]\displaystyle{ R_v }[/math] of [math]\displaystyle{ v }[/math] and [math]\displaystyle{ R_w }[/math] of [math]\displaystyle{ w }[/math] are defined as follows:
- [math]\displaystyle{ R_v := R_u \cap \{K \in \Kappa | K \leq K_u\} }[/math]
- [math]\displaystyle{ R_w := R_u \cap \{K \in \Kappa | K \geq K_u\} }[/math]
- Now let [math]\displaystyle{ T = (V,A) }[/math] be a mutli-way search tree:
- Again, the range of [math]\displaystyle{ r }[/math] is [math]\displaystyle{ \Kappa }[/math].
- For [math]\displaystyle{ v \in V\setminus\{r\} }[/math], let [math]\displaystyle{ w \in V }[/math] denote the parent node, and let [math]\displaystyle{ i }[/math] be the position of [math]\displaystyle{ (w,v) }[/math] in the ordered sequence of outgoing arcs of [math]\displaystyle{ w }[/math]. Then the range of [math]\displaystyle{ v }[/math] is
- [math]\displaystyle{ R_v := \{K \in R_w | K \leq minS_w\} }[/math], if [math]\displaystyle{ i = 0 }[/math];
- [math]\displaystyle{ R_v := \{K \in R_w | K \geq maxS_w\} }[/math], if [math]\displaystyle{ i = |S_w| }[/math];
- [math]\displaystyle{ R_v := \{K \in R_w | K \geq a, K \leq b\} }[/math], otherwise, where [math]\displaystyle{ a,b \in S_w }[/math] are the [math]\displaystyle{ i }[/math]-th and [math]\displaystyle{ (i + 1) }[/math]-st element of [math]\displaystyle{ S_w }[/math] in the sorting order of comparison [math]\displaystyle{ c }[/math].
Immediate Predecessor and Successor
For a node [math]\displaystyle{ v }[/math] of a binary or multi-way search tree,
- the immediate predecessor of [math]\displaystyle{ v }[/math] is [math]\displaystyle{ v }[/math]'s immediate predecessor in left-root-right order (if existing), and
- the immediate successor of [math]\displaystyle{ v }[/math] is [math]\displaystyle{ v }[/math]'s immediate successor in left-root-right order (if existing).