40 likes | 158 Views
CST229 Week 2. Questions or concern? Homework #1 due Difference between permutation and no restrictions on using an element more than once. Code example: Generate all permutation Reading: Chapters 2 & 3 this week, Chapter 4 next week. Review of main topics for this class.
E N D
CST229 Week 2 • Questions or concern? • Homework #1 due • Difference between permutation and no restrictions on using an element more than once. • Code example: Generate all permutation • Reading: Chapters 2 & 3 this week, Chapter 4 next week. • Review of main topics for this class. • Languages (formal languages) – language definitions/notations (chapters 2, 3, 4) • Machines (chapters 5, 7, 14, 15) • Grammar (chapters 12, 13) • Why the need for formal languages or grammars? • Chapter 2 – language definitions (set notation & Kleene closure) • In-Class Exercise Part a • Chapter 3 – recursive definitions • In-Class Exercise Part b & c
In-Class Exercise #2 part a • Let S1 = {aa, b}, how many words of length 2 does S1* have? Length 3? Length 4? • Let S2 = {aa, aba, baa}, let L2 = S* is aabaa L2? is baaabaaaL2? is baaaaababaaaL2? • If S = {ab, bb} & T = {ab, bb, bbbb}, is S* = T*?
In-Class Exercise 2 part b • Write a recursive function in C/C++ to compute if a word is a palindrome? boolisPal(char * word, .....
In-Class Exercise 2 part c • Use recursive definition to show that all numbers end in the digits 0, 2, 4, 6, 8 are even