|
abstract class Tree { /* ... */ } class EmptyTree extends Tree { int size() { return 0; } int height() { return 0; } } class Branch extends Tree { Tree left; Tree right; String data; int size() { return 1 + this.left.size() + this.right.size(); } int height() { return 1 + Math.max( this.left.height(), this.right.height() ) ; } } |
Let P be a statement indexed by trees (instead of indexed by numbers like in our previous induction proofs)
P(t) = “t.size() < 2t.height()”.So for any Tree t, P(t) might be true or it might be false for all we know. … however, we'll endeavor to show that it is actually true for every single possible Tree.
©2007, Ian Barland, Radford University Last modified 2007.Oct.30 (Tue) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |