Exam Questions Flashcards

1
Q

How to count occurances with DFA?

A
  1. Creat a path following the sequence, ensure that if completed it remains in the same position
  2. For any deviation, check where in the word it occurs. If it lands nowhere, go back to the start
  3. Ceck if needs to be consequtive or exact
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to minimize a DFA?

A
  1. Remove all unreachable states
  2. Create a partitioning s.t. {{ final states }, { other states }}
  3. 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
  4. Then create the graph from these partitions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to convert NFA to DFA?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to convert Right linear grammar to Strictly right linear grammar?

A

A strictly right linear grammar has at most 1 variable (i.e., a capital letter),

Note: you are allowed to have lambda rules

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How to go from strictly right linear grammar to NFA (graph)?

A
  1. Start a starting variable & create variable F.
  2. Then do the following:
  • For every A -> B, make a transition lambda from A to B.
  • For every A -> aB, make a transition a from A to B
  • For every A->a, make a transition a from A to F.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to go from NFA (graph) to regular expression?

A

This is clearly explained in the cheat sheet.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to remove lambda productions?

A
  1. Just create a list of all variables that can be lambda.
  2. Then create a copy of the rule but without an empty variable.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to remove unit production rules?

A

Just when you see an assignment with a unit production rule, replace it with an instruction from the unit.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How to remove useless variables?

A
  1. Identify non-reachable variables
  2. Identify non-productive variables. (i.e., variables that always refer to themselves).
  3. Identify all useless variables
    * All variables named before
    * All variables only in a rule named before
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How to rewrite to Chomsky Normal form?

A
  1. For every character: create a new variable
  2. Split all variables s.t. they have a maximum length 2.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How to use CYK parsing?

A
  1. Start with V_a = {...}, which contains all variables that generage a.
  2. Continue enlarging the sets for new combinations, which might be in your word.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How to do LL(1) parsing?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How to fo from NPDA to Context Free?

A
  1. Start with 1 ->2, with rule a[b/lambda]. Write these as (1, b, 2) -> a.
  2. Continue with 1->2, with rule a[b/c]. Write as: for all r1: (1, b, r1) -> a(2,c,r2)
  3. Move on with 1->2, with rule a[b/cd]. Write as: for all r1, r2: (1, b, r2) -> a(2, c, r1)(r1, s, r2).
  4. Etc.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly