← Quiz: Regular Grammars and Finite Automata: all 10 questions
Quiz: Regular Grammars and Finite Automata · Question 4 of 10
What does this print? (code)
What does this print?
delta = {("A", "0"): "B", ("A", "1"): "A", ("B", "0"): "B", ("B", "1"): "C",
("C", "0"): "B", ("C", "1"): "A"}
form, state = "A", "A"
for ch in "001":
state = delta[(state, ch)]
form = form[:-1] + ch + state
print(form)
- A.001A
- B.001B
- C.001C
- D.001
Answer & explanation
Correct answer: 001C
The run A → B → B → C gives the sentential form 001C; C → ε would finish it.
Can you get the rest right without peeking?
Take the timed Quiz: Regular Grammars and Finite Automata quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →