VelocerAbrir la aplicación

Velocer › Tarjetas › University of Wisconsin–Madison › COMP SCI 240 Final

COMP SCI 240 Final

Finite automata + regex, counting. the post-midterm 3 stuff. · por sunset_point_notes · 81 tarjetas

University of Wisconsin–Madison

Estudiar este mazo Insertar

  1. Finite state automaton (FSA)A finite set of states plus rules: each step reads one input symbol and changes state.
  2. Transition diagramVertices are states; an arrow marks the start state; labeled edges show which input causes each transition.
  3. How is an accept state drawn?With a double circle. Reaching it after reading all input means the string is accepted.
  4. The 5-tuple for an FSA(S, Σ, δ, s₀, A): states, alphabet, transition function, start state, accepting states.
  5. Transition function δδ: S × Σ → S; δ(s, x) gives the next state from state s on symbol x.
  6. What does A ⊆ S mean in an FSA?A is the set of accepting states.
  7. StringA finite sequence of symbols from the alphabet Σ.
  8. Empty stringWritten λ or ǫ; it has length 0.
  9. Length of a string x|x|, the number of symbols in it. For example, |NANO| = 4.
  10. Language over ΣA set of strings over the alphabet Σ.
  11. L(M)The set of strings that machine M accepts, starting from s₀ and ending in an accept state.
  12. Extended transition δ(s, ǫ)It equals s: reading nothing leaves you in the same state.
  13. Extended transition δ(s, ya)δ(δ(s, y), a): process string y first, then read the last symbol a.
  14. Parts of an FSA computation modelFinite control (current state), a tape holding the input, and a tape head that reads symbols.
  15. What happens in each FSA step?Read the symbol under the head, update the state using δ, then move the head right.
  16. Key design question for an FSAWhat finite info about the input so far do you need to continue correctly?
  17. What are invariants used for in FSA design?To describe exactly when the machine is in each state.
  18. Why avoid transitions that discard needed info?States must not lose information like the first symbol seen, or the machine can't decide correctly.
  19. FSA for an odd number of 1s: states and accept setS = {s₀, s₁}, start s₀, A = {s₁}; s₁ means an odd count of 1s so far.
  20. Transitions for the odd-1s machineδ(s₀,0)=s₀, δ(s₀,1)=s₁, δ(s₁,0)=s₁, δ(s₁,1)=s₀.
  21. How do you prove the odd-1s machine is correct?By induction on steps: it's in s₁ after n steps exactly when the first n symbols have an odd number of 1s.
  22. In the 'contains NANO' machine, what does state i mean?The last i symbols match the first i letters of NANO.
  23. What happens after the 'NANO' machine reaches state 4?It stays there and absorbs any input, since the string already contains NANO.
  24. On a mismatch in the 'NANO' machine, where do you go?To the longest matching prefix, not always state 0. For example, NAN + A goes to state 2.
  25. In the 'starts and ends with same symbol' machine, why is the start state accepting?Because the empty string counts as starting and ending with the same symbol.
  26. Why are there no transitions between s₀ and s₁ in the same-symbol machine?That would lose the first-symbol information the machine needs.
  27. Union of languages L₁ ∪ L₂x is in it when x ∈ L₁ or x ∈ L₂.
  28. Concatenation L₁L₂{xy | x ∈ L₁ and y ∈ L₂}: split the string into a part from L₁ and a part from L₂.
  29. Kleene star L*The union of Lᵏ for all k ≥ 0, where L⁰ = {ǫ} and Lᵏ = LLᵏ⁻¹.
  30. What is {0,1}*?The set of all binary strings, including the empty string.
  31. Base regular expressions∅, ǫ, and a single symbol a (for each a ∈ Σ).
  32. Recursive rules for regular expressionsR₁|R₂ (union), R₁R₂ (concatenation), and R₁* (Kleene star).
  33. L(∅) and L(ǫ)L(∅) = ∅ (no strings); L(ǫ) = {ǫ} (just the empty string).
  34. L(R₁|R₂)L(R₁) ∪ L(R₂).
  35. L(R₁*)L(R₁)*, the Kleene star of the language.
  36. Regex precedence orderStar first, then concatenation, then union; parentheses override.
  37. Alternate regex notations+ or ∪ can replace |, and · can denote concatenation.
  38. When is a language regular?Exactly when some regular expression describes it. Same as saying some FSA accepts it. Example: strings of a's and b's ending in ab is regular.
  39. Regex and FSA: same class of languages?Yes: a language is regular exactly when some FSA accepts it and some regex defines it.
  40. Remainder update for a multiples-of-k automatonNew remainder = (2i + a) mod k, where i is the old remainder and a the next bit.
  41. Value recurrence for binary stringsVal(x₁…xₙ₊₁) = 2·Val(x₁…xₙ) + xₙ₊₁.
  42. What does N′ₖ accept?Binary strings whose value is a multiple of k; it allows leading zeros and accepts the empty string.
  43. How does Nₖ reject leading zeros?It starts in a rejecting state s; a 0 goes to accepting s₀, but another symbol from s₀ goes to a garbage state.
  44. Is zero a multiple of k?Yes, so the string '0' alone is accepted, but '0…' with more symbols is rejected.
  45. Bijection ruleGot a total bijection f: T → S? Then |S| = |T|. So you can count S by counting T instead.
  46. How do you use a bijection to count a set S?Build a bijection from S to an easier set T, then count T.
  47. Sum ruleIf S is a disjoint union of S₁…Sₛ, then |S| = |S₁| + … + |Sₛ|.
  48. When does the sum rule fail?When the sets overlap; use inclusion–exclusion instead.
  49. Product ruleIf S = S₁ × S₂ × … × Sₙ, then |S| = |S₁|·|S₂|···|Sₙ|.
  50. When does the product rule apply?When the choice at each position is independent of the others.
  51. Generalized product ruleFor a length-k sequence, |S| = n₁·n₂···nₖ, where nᵢ is the choices for position i given earlier picks.
  52. Generalized bijection ruleIf f: T → S is total, onto, and k-to-1, then |S| = |T|/k.
  53. What does k-to-1 mean?Every element of S has exactly k preimages in T.
  54. How do you count arrangements of identical objects?Count as if distinct, then divide by k! using the generalized bijection rule.
  55. Factorial n!n! = 1·2·…·n; the number of ways to order n distinct items.
  56. What is 0!?0! = 1, because there is one way to list the empty set: the empty sequence.
  57. Permutation of a set DA sequence using each element of D exactly once.
  58. How many permutations does an n-element set have?n!
  59. r-permutation P(n,r)An ordered arrangement of r of n elements; P(n,r) = n!/(n−r)!.
  60. P(n,r) in terms of combinationsP(n,r) = C(n,r)·r!
  61. r-combinationA set of r elements chosen from n elements; order doesn't matter.
  62. Formula for C(n,r)C(n,r) = n!/(r!(n−r)!)
  63. Symmetry of binomial coefficients(n choose k) = (n choose n−k)
  64. Why does (n choose k) = (n choose n−k)?Choosing which k are in is the same as choosing which n−k are out.
  65. Round table seating countArrangements equivalent if everyone has the same right-hand neighbor; count = n!/n = (n−1)!.
  66. Inclusion–exclusion for two sets|S₁ ∪ S₂| = |S₁| + |S₂| − |S₁ ∩ S₂|
  67. Inclusion–exclusion for three setsAdd singles, subtract pairwise intersections, add the triple intersection.
  68. Stars and bars: n items, k typesNumber of ways = (n+k−1 choose k−1)
  69. How many subsets does an n-element set have?2ⁿ
  70. Bijection between subsets and binary stringsA length-n binary string ↔ a subset; 1 means the element is included.
  71. Identity 2ⁿ = Σₖ (n choose k)Count subsets by size: sum of (n choose k) over all k.
  72. Binomial theorem(x+y)ⁿ = Σₖ₌₀ⁿ (n choose k) xᵏ y^(n−k)
  73. Coefficient of xᵏy^(n−k) in (x+y)ⁿ(n choose k), the ways to pick x from k of the n factors.
  74. Corollary Σₖ (n choose k) = 2ⁿSet x = y = 1 in the binomial theorem.
  75. Pigeonhole principleIf |T| > |S|, any total f: T → S maps two elements of T to the same element of S.
  76. Pigeons and holes in the pigeonhole principlePigeons = T, holes = S; more pigeons than holes means some hole holds at least 2.
  77. Is the pigeonhole principle constructive?No; it proves a pair exists but gives no way to find it.
  78. Permutation vs combinationPermutation: order matters. Combination: order doesn't matter.
  79. Product rule vs generalized product ruleProduct rule needs independence; otherwise use the generalized product rule.
  80. How many 5-card poker hands from a 52-card deck?(52 choose 5) = 2,598,960
  81. Probability of a poker handFavorable hands divided by total hands, (52 choose 5).

Velocer es gratis: repetición espaciada y tus propias tarjetas a partir de cualquier documento.

PDF to flashcards · Lecture to flashcards · Practice exam · Syllabus study plan · Anki import

Más barajas de University of Wisconsin–Madison