24 - 19:10:12 CS 61B Lecture 24 Friday Todays reading 1 24 Goodrich Tamassia Chapter 7 ROOTED TREES = A_tree consists of a set of nodes and a set

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
10/22/10 19:10:12 1 24 CS 61B: Lecture 24 Friday, October 22, 2010 Today’s reading: ROOTED TREES ============ A _tree_ consists of a set of nodes and a set of edges that connect pairs of nodes. A tree has the property that there is exactly one path (no more, no less) between any two nodes of the tree. A _path_ is a connected sequence of zero or more edges. In a _rooted_ tree, one distinguished node is called the _root_. Every node c, except the root, has exactly one _parent_ node p, which is the first node traversed on the path from c to the root. c is p’s _child_. The root has no parent. A node can have any number of children. Some other definitions: - A _leaf_ is a node with no children. - _Siblings_ are nodes with the same parent. - The _ancestors_ of a node d are the nodes on the path from d to the root. These include d’s parent, d’s parent’s parent, d’s parent’s parent’s parent, and so forth up to the root. Technically, the ancestors of d also include d itself, which makes you wonder about d’s sex life. The root is an ancestor of every node in the tree. - If a is an ancestor of d, then d is a _descendant_ of a. - The _length_ of a path is the number of edges in the path. - The _depth_ of a node n is the length of the path from n to the root. (The depth of the root is zero.) - The _height_ of a node n is the length of the path from n to its deepest descendant. (The height of a leaf node is zero.) - The height of a tree is the depth of its deepest node = height of the root. - The _subtree_ rooted at node n is the tree formed by n and its descendants. - A _binary_tree_ is a tree in which no node has more than two children, and every child is either a _left_child_ or a _right_child_, even if it’s the only child its parent has. A commonly encountered application of trees is the directory structure of a
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/10/2012 for the course CS 61B taught by Professor Canny during the Fall '01 term at University of California, Berkeley.

Page1 / 2

24 - 19:10:12 CS 61B Lecture 24 Friday Todays reading 1 24 Goodrich Tamassia Chapter 7 ROOTED TREES = A_tree consists of a set of nodes and a set

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online