Exam Questions Flashcards
How to count occurances with DFA?
- Creat a path following the sequence, ensure that if completed it remains in the same position
- For any deviation, check where in the word it occurs. If it lands nowhere, go back to the start
- Ceck if needs to be consequtive or exact
How to minimize a DFA?
- Remove all unreachable states
- Create a partitioning s.t.
{{ final states }, { other states }}
- Look if there is a partition, that if you go from the partition to any other partition, it can be split. Repeat until no more splits are possible
- Then create the graph from these partitions
How to convert NFA to DFA?
When converting from NFA to DFA, we’re basically suggesting in which state the NFA can be. Likely you’ll be able to check these types of questions partially
How to convert Right linear grammar to Strictly right linear grammar?
A strictly right linear grammar has at most 1 variable (i.e., a capital letter),
Note: you are allowed to have lambda rules
How to go from strictly right linear grammar to NFA (graph)?
- Start a starting variable & create variable
F
. - Then do the following:
- For every
A -> B
, make a transitionlambda
fromA
toB
. - For every
A -> aB
, make a transitiona
fromA
toB
- For every
A->a
, make a transitiona
fromA
toF
.
How to go from NFA (graph) to regular expression?
This is clearly explained in the cheat sheet.
How to remove lambda
productions?
- Just create a list of all variables that can be
lambda
. - Then create a copy of the rule but without an empty variable.
How to remove unit production rules?
Just when you see an assignment with a unit production rule, replace it with an instruction from the unit.
How to remove useless variables?
- Identify non-reachable variables
- Identify non-productive variables. (i.e., variables that always refer to themselves).
- Identify all useless variables
* All variables named before
* All variables only in a rule named before
How to rewrite to Chomsky Normal form?
- For every character: create a new variable
- Split all variables s.t. they have a maximum length 2.
How to use CYK parsing?
- Start with
V_a = {...}
, which contains all variables that generagea
. - Continue enlarging the sets for new combinations, which might be in your word.
How to do LL(1) parsing?
Parsing from a table:
1. Look at the first letter, choose the accompanying rule.
Creating a table:
1. Find the letters each variable can start with (start from the simples to the hardest).
2. Find all the letters that can follow each variable. (e.g., A->aBc
implies c
in Follow(B)
).
3. Fill in the table, thinking: “If I were to read A
, and you would see this letter, which rule am I reading?”
How to fo from NPDA to Context Free?
- Start with
1 ->2
, with rulea[b/lambda]
. Write these as(1, b, 2) -> a
. - Continue with
1->2
, with rulea[b/c]
. Write as:for all r1: (1, b, r1) -> a(2,c,r2)
- Move on with
1->2
, with rulea[b/cd]
. Write as:for all r1, r2: (1, b, r2) -> a(2, c, r1)(r1, s, r2)
. - Etc.