CSE 321 Discrete Structures Winter 2008 Lecture 12
- Slides: 37
CSE 321 Discrete Structures Winter 2008 Lecture 12 Induction
Announcements • Readings – Monday, Wednesday • Induction and recursion – 4. 1 -4. 3 (5 th Edition: 3. 3 -3. 4) – Midterm: • Friday, February 8 • In class, closed book • Estimated grading weight: – MT 12. 5%, HW 50%, Final 37. 5%
Induction Example • Prove 3 | 22 n -1 for n 0
Induction as a rule of Inference P(0) k (P(k) P(k+1)) n P(n)
Harmonic Numbers
Cute Application: Checkerboard Tiling with Trinominos Prove that a 2 k checkerboard with one square removed can be tiled with:
Strong Induction P(0) k ((P(0) P(1) P(2) … P(k)) P(k+1)) n P(n)
Player 1 wins n 2 Chomp! Winning strategy: chose the lower corner square Theorem: Player 2 loses when faced with an n 2 board missing the lower corner square
Induction Example • A set of S integers is non-divisible if there is no pair of integers a, b in S where a divides b. If there is a pair of integers a, b in S, where a divides b, then S is divisible. • Given a set S of n+1 positive integers, none exceeding 2 n, show that S is divisible. • What is the largest subset non-divisible subset of 2, 3, 4, 5, 6, 7, 8, 9, 10 }. {1,
If S is a set of n+1 positive integers, none exceeding 2 n, then S is divisible • Base case: n =1 • Suppose the result holds for n – If S is a set of n+1 positive integers, none exceeding 2 n, then S is divisible – Let T be a set of n+2 positive integers, none exceeding 2 n+2. Suppose T is non-divisible.
Proof by contradiction • Claim: 2 n+1 T and 2 n + 2 T • Claim: n+1 / T • Let T* = T – {2 n+1, 2 n+2} {n+1} • If T is non-divisible, T* is also non-divisible
Recursive Definitions • F(0) = 0; F(n + 1) = F(n) + 1; • F(0) = 1; F(n + 1) = 2 F(n); • F(0) = 1; F(n + 1) = 2 F(n)
Fibonacci Numbers • f 0 = 0; f 1 = 1; fn = fn-1 + fn-2
Bounding the Fibonacci Numbers • Theorem: 2 n/2 fn 2 n for n 6
Recursive Definitions of Sets • Recursive definition – Basis step: 0 S – Recursive step: if x S, then x + 2 S – Exclusion rule: Every element in S follows from basis steps and a finite number of recursive steps
Recursive definitions of sets Basis: 6 S; 15 S; Recursive: if x, y S, then x + y S; Basis: [1, 1, 0] S, [0, 1, 1] S; Recursive: if [x, y, z] S, in R, then [ x, y, z] S if [x 1, y 1, z 1], [x 2, y 2, z 2] S then [x 1 + x 2, y 1 + y 2, z 1 + z 2] Powers of 3
Strings • The set * of strings over the alphabet is defined – Basis: * ( is the empty string) – Recursive: if w *, x , then wx *
Families of strings over = {a, b} • L 1 – w L 1 then awb L 1 • L 2 – w L 2 then aw L 2 – w L 2 then wb L 2
Function definitions Len( ) = 0; Len(wx) = 1 + Len(w); for w *, x Concat(w, ) = w for w * Concat(w 1, w 2 x) = Concat(w 1, w 2)x for w 1, w 2 in *, x
Well Formed Fomulae • Basis Step – T, F, and s, where is a propositional variable are in WFF • Recursive Step – If E and F are in WFF then ( E), (E F), (E F) and (E F) are in WFF
Tree definitions • A single vertex r is a tree with root r. • Let t 1, t 2, …, tn be trees with roots r 1, r 2, …, rn respectively, and let r be a vertex. A new tree with root r is formed by adding edges from r to r 1, …, rn.
Extended Binary Trees • The empty tree is a binary tree. • Let r be a node, and T 1 and T 2 binary trees. A binary tree can be formed with T 1 as the left subtree and T 2 as the right subtree. If T 1 is non-empty, there is an edge from the root of T 1 to r. Similarly, if T 2 is non-empty, there is an edge from the root of T 2 to r.
Full binary trees • The vertex r is a FBT. • If r is a vertex, T 1 a FBT with root r 1 and T 2 a FBT with root r 2 then a FBT can be formed with root r and left subtree T 1 and right subtree T 2 with edges r r 1 and r r 2.
Simplifying notation • ( , T 1, T 2), tree with left subtree T 1 and right subtree T 2 • is the empty tree • Extended Binary Trees (EBT) – EBT – if T 1, T 2 EBT, then ( , T 1, T 2) EBT • Full Binary Trees (FBT) – FBT – if T 1, T 2 FBT, then ( , T 1, T 2) FBT
Recursive Functions on Trees • N(T) - number of vertices of T • N( ) = 0; N( ) = 1 • N( , T 1, T 2) = 1 + N(T 1) + N(T 2) • Ht(T) – height of T • Ht( ) = 0; Ht( ) = 1 • Ht( , T 1, T 2) = 1 + max(Ht(T 1), Ht(T 2)) NOTE: Height definition differs from the text Base case H( ) = 0 used in text
More tree definitions: Fully balanced binary trees • is a FBBT. • if T 1 and T 2 are FBBTs, with Ht(T 1) = Ht(T 2), then ( , T 1, T 2) is a FBBT.
And more trees: Almost balanced trees • is a ABT. • if T 1 and T 2 are ABTs with Ht(T 1) -1 Ht(T 2) Ht(T 1)+1 then ( , T 1, T 2) is a ABT.
Is this Tree Almost Balanced?
Structural Induction • Show P holds for all basis elements of S. • Show that if P holds for elements used to construct a new element of S, then P holds for the new element.
Prove all elements of S are divisible by 3 • Basis: 21 S; 24 S; • Recursive: if x, y S, then x + y S;
Prove that WFFs have the same number of left parentheses as right parentheses
Well Formed Fomulae • Basis Step – T, F, and s, where is a propositional variable are in WFF • Recursive Step – If E and F are in WFF then ( E), (E F), (E F) and (E F) are in WFF
Fully Balanced Binary Tree • If T is a FBBT, then N(T) = 2 Ht(T) - 1
Binary Trees • If T is a binary tree, then N(T) 2 Ht(T) - 1 If T = : If T = ( , T 1, T 2) Ht(T 1) = x, Ht(T 2) = y N(T 1) 2 x, N(T 2) 2 y N(T) = N(T 1) + N(T 2) + 1 2 x – 1 + 2 y – 1 + 1 2 Ht(T) -1 + 2 Ht(T) – 1 2 Ht(T) - 1
Almost Balanced Binary Trees Let = (1 + sqrt(5))/2 Prove N(T) Ht(T) – 1 Base case: Recursive Case: T = ( , T 1, T 2) Let Ht(T) = k + 1 Suppose Ht(T 1) Ht(T 2) Ht(T 1) = k, Ht(T 2) = k or k-1
Almost Balanced Binary Trees N(T) = N(T 1) + N(T 2) + 1 k – 1 + k-1 – 1 + 1 k + k-1 – 1 k+1 – 1 [ 2 = + 1]
- Cse 321
- 2008 2008
- Es war eine mutter
- Winter kommt winter kommt flocken fallen nieder
- Es ist kalt es ist kalt flocken fallen nieder
- 01:640:244 lecture notes - lecture 15: plat, idah, farad
- 2110200
- Cs 584
- Discrete structures
- Discrete structures
- Discrete computational structures
- Mathematics 1
- Discrete structures
- Biology homology
- Responsibilities
- F tag 812
- 321 draw
- Edel 321
- Voicemail airtel
- 321 feedback
- Oam 321
- Ce 321
- The royal gorge bridge in colorado rises 321
- Ics-321
- Csi 321
- Ics-321
- Ics 321
- Ics-321
- Planet ip phone
- Acuerdo 0321 de 2011
- Multicycle service code
- Ics-321
- Law of probability
- Cbp section 321 restrictions
- 132 213
- Cpsc 321
- 321-185
- 321 riq