This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Trees and Structural Induction Margaret M. Fleck 2 April 2010 This lecture covers some basic properties of trees (section 10.1 of Rosen and introduces structural induction (in section 4.3 of Rosen). 1 Announcements Midterm coming up next Wednesday. Contact me if you have a conflict. Also, folks doing the honors addon: second homework is due next Monday (5th). 2 Counting nodes Recall that a full mary tree is a tree in which each node has either m children or no children. So, in a full binary tree, each node has two or zero children. Remember also that internal nodes are nodes with children and leaf nodes are nodes without children. Claim: A full mary tree with i internal nodes has mi + 1 nodes total. To see why this is true, notice that there are two types of nodes: nodes with a parent and nodes without a parent. A tree has exactly one node with no parent. We can count the nodes with a parent by taking the number of parents in the tree ( i ) and multiplying by the branching factor m . Therefore, the number of leaves in a full mary tree with i internal nodes is ( mi + 1) i = ( m 1) i + 1. Rosen lists several more similar equations relating number of nodes, num ber of leaves, and number of internal nodes. 1 3 Height vs number of nodes Recall that the level of a node is the number of edges in the path from it to the root. That is, the root has level 0. The height of a tree is the maximum level of any (leaf) node. Now, suppose that we have a binary tree of height h . How many nodes and how many leaves does it contain? This clearly cant be an exact formula, since some trees are more bushy than others and some are more balanced than others (all leaves at approximately the same level). But we can give useful upper and lower bounds. To minimize the node counts, consider a tree that has just one leaf. It contains h + 1 nodes connected into a straight line by h edges. So the minimum number of leaves is 1 (regardless of h ) and the minimum number of nodes is h + 1....
View Full
Document
 Spring '10
 fleck

Click to edit the document details