# lect_27 - Trees and Structural Induction Margaret M Fleck 2...

This preview shows pages 1–3. Sign up to view the full content.

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 add-on: second homework is due next Monday (5th). 2 Counting nodes Recall that a full m-ary 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 m-ary 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 m-ary 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

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

View Full Document
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 can’t 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.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern