CSCI 151 Fall 2012 Structural Induction Practice A natural number n is either: • 0, or • n0 + 1, where n0 is a natural number. Use this definition to connect the following algebraic expressions. The first three are done for you. 1. n2 to (n0 )2 : n2 = (n − 1)2 + 2n − 1 = (n0 )2 + 2n − 1. 2. 2n4 to 2(n0 )4 : 2n4 = 2(n − 1)4 + 4n3 − 6n2 + 4n − 1 = 2(n0 )4 + 4n3 − 6n2 + 4n − 1. 0 0 3. 2n to 2n : 2n = 2 · 2n−1 = 2 · 2n . 0 4. 2n+1 to 2n +1 : 0 5. 2n + 1 to 2n + 1: 0 0 6. 2n+1 − 2n−1 + 1 to 2n +1 − 2n −1 + 1: 0 7. 3n+1 − 1 to 3n +1 − 1: 8. log2 (n) to log2 (n/2): 9. log2 (n) to log2 (2n): 10. n! to n0 !: 11. (n + 1)! to (n0 + 1)!: 12. (n + 1)! − 1 to (n0 + 1)! − 1: Pn0 Pn 13. i=0 i: i=0 i to Pn0 i Pn i 14. i=0 2 to i=0 2 : Pn i Pn0 i 15. i=0 3 to i=0 3 : Pn Pn0 16. i=0 (2i + 1) to i=0 (2i + 1): Pn Pn0 17. i=0 i · i! to i=0 i · i!: 0 18. (1 + x)n to (1 + x)n (for x > −1): 19. 1 + n · x to 1 + n0 · x (for x > −1): (continued on next page) 1 A binary tree is either: • empty, or • a root node r with up to 2 binary subtrees L and R (and edges from r to its non-empty children). Use this definition to connect the following expressions. The first few are done for you. 1. n(T ) to n(L), n(R), where n(T ) denotes the number of nodes of T : 2. h(T ) to h(L), h(R), where h(T ) denotes the height of T : n(T ) = 1 + n(L) + n(R) h(T ) = 1 + max{h(L), h(R)} 3. e(T ) to e(L), e(R), where e(T ) denotes the number of edges of T : 4. `(T ) to `(L), `(R), where `(T ) denotes the number of leaves of T : 5. n(d, T ) to n(?, L), n(?, R), where n(d, T ) denotes the number of nodes at depth d in T (the ? is intentional; you need to figure out what depth parameter to pass in): Recall that the heap-order property for a binary tree T states that: for every node v of T , valueAt(v) ≤ valueAt(root of L) and valueAt(v) ≤ valueAt(root of R) That is, every node in the tree has value less than that of each of its children. Use this and the definition of a binary tree to connect the following expressions. 1. root(T ) to root(L), root(R), where root(T ) denotes the values of the root of T : 2. minV al(T ) to minV al(L), minV al(R), where minV al(T ) denotes the minimum value of all the nodes in T : 2