← Quiz: Mealy and Moore Machines: all 10 questions
Quiz: Mealy and Moore Machines · Question 6 of 10
What does this print? (code)
What does this print?
delta = {("A", "0"): "B", ("A", "1"): "A", ("B", "0"): "B", ("B", "1"): "A"}
out = {("A", "0"): "0", ("A", "1"): "0", ("B", "0"): "0", ("B", "1"): "1"}
state, result = "A", ""
for ch in "10101":
result += out[(state, ch)]
state = delta[(state, ch)]
print(result)
- A.10101
- B.00101
- C.01010
- D.00001
Answer & explanation
Correct answer: 00101
The pattern 01 ends at positions 3 and 5, so those outputs are 1.
Can you get the rest right without peeking?
Take the timed Quiz: Mealy and Moore Machines quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →