Homework 4: Proof by Induction
Due: Friday, April 13, 8:59:59pm
Instructions
You should submit answers to the following questions as either a text document or PDF format file. (Submitting any other format, MS Word, for example, will be grounds for receiving a 0.) The file must be named "hw4.txt" or "hw4.pdf". Move the file into the hw4 directory of your shared submission directories. You are being asked to submit soundly reasoned and well written proofs by induction. This means the solution to each question must include:- A clear statement of the inductive hypothesis
- The validation of the base case(s): proving the inductive hypothesis hold for some concrete value or instance
- A clear explanation of the inductive step: how the inductive hypothesis was applied to derive the property for the next case
- An demonstration that the inductive step establishes the inductive hypothesis holds for the next case.
Question 1
In class, we defined a full binary tree to be first: binary, i.e. a tree where every node has at most two children, labelled as right and left; and second: full, meaning each node either has no children, or a full complement of two. Furthermore, we call nodes with no children leaves, and nodes with any children internal nodes. So, another way to define a full binary tree would be: "a binary tree where every internal node has exactly two children."
We can extend this to define full ternary trees, which are trees where every node can have up to three children, and being full, every internal node has exactly 3 children.Let intNodes(T) denote the number of internal nodes in a full ternary tree T, and let leaves(T) denote the number of leaves in that tree. Prove by induction that for all full ternary trees:
leaves(T) = 2 * intNodes(T) + 1
Question 2
[From Goodrich et al.]
Given a full binary tree T, define the reflection of T to be the binary tree T' such that each node v in T is also in T', but the left child of v in T is v's right child in T' and the right child of v in T is v's left child in T'. (In other words, T' is the mirror image of T.)
Show that a preorder traversal of a full binary tree T is the same as the postorder traversal of T's reflection, but in reverse order.