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
- Finite state automaton (FSA)A finite set of states plus rules: each step reads one input symbol and changes state.
- Transition diagramVertices are states; an arrow marks the start state; labeled edges show which input causes each transition.
- How is an accept state drawn?With a double circle. Reaching it after reading all input means the string is accepted.
- The 5-tuple for an FSA(S, Σ, δ, s₀, A): states, alphabet, transition function, start state, accepting states.
- Transition function δδ: S × Σ → S; δ(s, x) gives the next state from state s on symbol x.
- What does A ⊆ S mean in an FSA?A is the set of accepting states.
- StringA finite sequence of symbols from the alphabet Σ.
- Empty stringWritten λ or ǫ; it has length 0.
- Length of a string x|x|, the number of symbols in it. For example, |NANO| = 4.
- Language over ΣA set of strings over the alphabet Σ.
- L(M)The set of strings that machine M accepts, starting from s₀ and ending in an accept state.
- Extended transition δ(s, ǫ)It equals s: reading nothing leaves you in the same state.
- Extended transition δ(s, ya)δ(δ(s, y), a): process string y first, then read the last symbol a.
- Parts of an FSA computation modelFinite control (current state), a tape holding the input, and a tape head that reads symbols.
- What happens in each FSA step?Read the symbol under the head, update the state using δ, then move the head right.
- Key design question for an FSAWhat finite info about the input so far do you need to continue correctly?
- What are invariants used for in FSA design?To describe exactly when the machine is in each state.
- Why avoid transitions that discard needed info?States must not lose information like the first symbol seen, or the machine can't decide correctly.
- 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.
- Transitions for the odd-1s machineδ(s₀,0)=s₀, δ(s₀,1)=s₁, δ(s₁,0)=s₁, δ(s₁,1)=s₀.
- 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.
- In the 'contains NANO' machine, what does state i mean?The last i symbols match the first i letters of NANO.
- What happens after the 'NANO' machine reaches state 4?It stays there and absorbs any input, since the string already contains NANO.
- 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.
- 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.
- Why are there no transitions between s₀ and s₁ in the same-symbol machine?That would lose the first-symbol information the machine needs.
- Union of languages L₁ ∪ L₂x is in it when x ∈ L₁ or x ∈ L₂.
- Concatenation L₁L₂{xy | x ∈ L₁ and y ∈ L₂}: split the string into a part from L₁ and a part from L₂.
- Kleene star L*The union of Lᵏ for all k ≥ 0, where L⁰ = {ǫ} and Lᵏ = LLᵏ⁻¹.
- What is {0,1}*?The set of all binary strings, including the empty string.
- Base regular expressions∅, ǫ, and a single symbol a (for each a ∈ Σ).
- Recursive rules for regular expressionsR₁|R₂ (union), R₁R₂ (concatenation), and R₁* (Kleene star).
- L(∅) and L(ǫ)L(∅) = ∅ (no strings); L(ǫ) = {ǫ} (just the empty string).
- L(R₁|R₂)L(R₁) ∪ L(R₂).
- L(R₁*)L(R₁)*, the Kleene star of the language.
- Regex precedence orderStar first, then concatenation, then union; parentheses override.
- Alternate regex notations+ or ∪ can replace |, and · can denote concatenation.
- 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.
- Regex and FSA: same class of languages?Yes: a language is regular exactly when some FSA accepts it and some regex defines it.
- Remainder update for a multiples-of-k automatonNew remainder = (2i + a) mod k, where i is the old remainder and a the next bit.
- Value recurrence for binary stringsVal(x₁…xₙ₊₁) = 2·Val(x₁…xₙ) + xₙ₊₁.
- What does N′ₖ accept?Binary strings whose value is a multiple of k; it allows leading zeros and accepts the empty string.
- 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.
- Is zero a multiple of k?Yes, so the string '0' alone is accepted, but '0…' with more symbols is rejected.
- Bijection ruleGot a total bijection f: T → S? Then |S| = |T|. So you can count S by counting T instead.
- How do you use a bijection to count a set S?Build a bijection from S to an easier set T, then count T.
- Sum ruleIf S is a disjoint union of S₁…Sₛ, then |S| = |S₁| + … + |Sₛ|.
- When does the sum rule fail?When the sets overlap; use inclusion–exclusion instead.
- Product ruleIf S = S₁ × S₂ × … × Sₙ, then |S| = |S₁|·|S₂|···|Sₙ|.
- When does the product rule apply?When the choice at each position is independent of the others.
- Generalized product ruleFor a length-k sequence, |S| = n₁·n₂···nₖ, where nᵢ is the choices for position i given earlier picks.
- Generalized bijection ruleIf f: T → S is total, onto, and k-to-1, then |S| = |T|/k.
- What does k-to-1 mean?Every element of S has exactly k preimages in T.
- How do you count arrangements of identical objects?Count as if distinct, then divide by k! using the generalized bijection rule.
- Factorial n!n! = 1·2·…·n; the number of ways to order n distinct items.
- What is 0!?0! = 1, because there is one way to list the empty set: the empty sequence.
- Permutation of a set DA sequence using each element of D exactly once.
- How many permutations does an n-element set have?n!
- r-permutation P(n,r)An ordered arrangement of r of n elements; P(n,r) = n!/(n−r)!.
- P(n,r) in terms of combinationsP(n,r) = C(n,r)·r!
- r-combinationA set of r elements chosen from n elements; order doesn't matter.
- Formula for C(n,r)C(n,r) = n!/(r!(n−r)!)
- Symmetry of binomial coefficients(n choose k) = (n choose n−k)
- Why does (n choose k) = (n choose n−k)?Choosing which k are in is the same as choosing which n−k are out.
- Round table seating countArrangements equivalent if everyone has the same right-hand neighbor; count = n!/n = (n−1)!.
- Inclusion–exclusion for two sets|S₁ ∪ S₂| = |S₁| + |S₂| − |S₁ ∩ S₂|
- Inclusion–exclusion for three setsAdd singles, subtract pairwise intersections, add the triple intersection.
- Stars and bars: n items, k typesNumber of ways = (n+k−1 choose k−1)
- How many subsets does an n-element set have?2ⁿ
- Bijection between subsets and binary stringsA length-n binary string ↔ a subset; 1 means the element is included.
- Identity 2ⁿ = Σₖ (n choose k)Count subsets by size: sum of (n choose k) over all k.
- Binomial theorem(x+y)ⁿ = Σₖ₌₀ⁿ (n choose k) xᵏ y^(n−k)
- Coefficient of xᵏy^(n−k) in (x+y)ⁿ(n choose k), the ways to pick x from k of the n factors.
- Corollary Σₖ (n choose k) = 2ⁿSet x = y = 1 in the binomial theorem.
- Pigeonhole principleIf |T| > |S|, any total f: T → S maps two elements of T to the same element of S.
- Pigeons and holes in the pigeonhole principlePigeons = T, holes = S; more pigeons than holes means some hole holds at least 2.
- Is the pigeonhole principle constructive?No; it proves a pair exists but gives no way to find it.
- Permutation vs combinationPermutation: order matters. Combination: order doesn't matter.
- Product rule vs generalized product ruleProduct rule needs independence; otherwise use the generalized product rule.
- How many 5-card poker hands from a 52-card deck?(52 choose 5) = 2,598,960
- 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
- comp sci 240 midterm 1
- comp sci 240 midterm 2
- COMP SCI 240 Midterm 3
- comp sci 300 full course review
- CS 639: Introduction to Reinforcement Learning · UW-Madison
- CS 839: Reinforcement Learning · UW-Madison
- CS 544: Intro to Big Data Systems · UW-Madison
- CS 580: Intelligent Robotics · UW-Madison
- CS 784: Foundations of Data Management · UW-Madison
- CS 880: Quantum Algorithms · UW-Madison
- CS 765: Data Visualization · UW-Madison
- CS 639: AI Coding · UW-Madison