1 / 15

CSE 321 Discrete Structures

CSE 321 Discrete Structures. Winter 2008 Lecture 15 Structural Induction. Announcements. Readings Today: Structural Induction 6 th edition: 4.3, 5 th edition: 3.4, Friday: Counting 6 th edition: 5.1, 5.2, 5 th edition: 4.1, 4.2. Highlights from Lecture 14.

erling
Download Presentation

CSE 321 Discrete Structures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSE 321 Discrete Structures Winter 2008 Lecture 15 Structural Induction

  2. Announcements • Readings • Today: • Structural Induction • 6th edition: 4.3, 5th edition: 3.4, • Friday: • Counting • 6th edition: 5.1, 5.2, 5th edition: 4.1, 4.2

  3. Highlights from Lecture 14 • Recursive Definitions • Sets • 0 S; • if x  S then x+2  S • Strings •  L • w  L, x  {a, b} then wxx L • Trees •  EBT • if T1, T2 EBT, then (, T1, T2)  EBT

  4. Recursive Functions on Trees • N(T) - number of vertices of T • N() = 0; N() = 1 • N(, T1, T2) = 1 + N(T1) + N(T2) • Ht(T) – height of T • Ht() = 0; Ht() = 1 • Ht(, T1, T2) = 1 + max(Ht(T1), Ht(T2)) NOTE: Height definition differs from the text Base case H() = 0 used in text

  5. More tree definitions: Fully balanced binary trees •  is a FBBT. • if T1 and T2 are FBBTs, with Ht(T1) = Ht(T2), then (, T1, T2) is a FBBT.

  6. And more trees: Almost balanced trees •  is a ABT. • if T1 and T2 are ABTs with Ht(T1) -1  Ht(T2)  Ht(T1)+1 then (, T1, T2) is a ABT.

  7. Is this Tree Almost Balanced?

  8. 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.

  9. Prove all elements of S are divisible by 3 • Basis: 21  S; 24  S; • Recursive: if x, y  S, then x + y  S;

  10. Prove that WFFs have the same number of left parentheses as right parentheses

  11. 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), (E F) and (E F) are in WFF

  12. Fully Balanced Binary Tree • If T is a FBBT, then N(T) = 2Ht(T) - 1

  13. Binary Trees • If T is a binary tree, then N(T)  2Ht(T) - 1 If T = : If T = (, T1, T2) Ht(T1) = x, Ht(T2) = y N(T1)  2x, N(T2)  2y N(T) = N(T1) + N(T2) + 1  2x – 1 + 2y – 1 + 1  2Ht(T) -1 + 2Ht(T) – 1 – 1  2Ht(T) - 1

  14. Almost Balanced Binary Trees Let  = (1 + sqrt(5))/2 Prove N(T) Ht(T) – 1 Base case: Recursive Case: T = (, T1, T2) Let Ht(T) = k + 1 Suppose Ht(T1)  Ht(T2) Ht(T1) = k, Ht(T2) = k or k-1

  15. Almost Balanced Binary Trees N(T) = N(T1) + N(T2) + 1 k – 1 + k-1 – 1 + 1 k + k-1 – 1 [2 =  + 1] k+1 – 1

More Related