This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CHAPTER 4 TREES §1 Preliminaries 1. Terminology Lineal Tree Pedigree Tree ( binary tree ) 1/16 §1 Preliminaries 【 Definition 【 A tree is a collection of nodes. The collection can be empty; otherwise, a tree consists of (1) a distinguished node r , called the root ; (2) and zero or more nonempty (sub)trees T 1 , ⋅ ⋅ ⋅ , T k , each of whose roots are connected by a directed edge from r . Note: Subtrees must not connect together. Therefore every node in the tree is the root of some subtree. There are edges in a tree with N nodes. Normally the root is drawn at the top. Note: Subtrees must not connect together. Therefore every node in the tree is the root of some subtree. There are edges in a tree with N nodes. Normally the root is drawn at the top. N 1 2/16 A C B D G F E H I J M L K degree of a node ::= number of subtrees of the node. For example, degree(A) = 3, degree(F) = 0. degree of a tree ::= For example, degree of this tree = 3. { } ) node ( degree max tree node ∈ leaf ( terminal node ) ::= a node with degree 0 (no children). parent ::= a node that has subtrees. children ::= the roots of the subtrees of a parent. siblings ::= children of the same parent. §1 Preliminaries 3/16 §1 Preliminaries A C B D G F E H I J M L K ancestors of a node ::= all the nodes along the path from the node up to the root. descendants of a node ::= all the nodes in its subtrees. depth of n i ::= length of the unique path from the root to n i . Depth(root) = 0. height of n i ::= length of the longest path from n i to a leaf....
View
Full Document
 Spring '09
 JilinWang
 Computer Science, Tree traversal, Nested set model, Articles with example Java code

Click to edit the document details