Oscar Lima Neto
Quiz by , created more than 1 year ago

Exercícios sobre Ambiguidade em Gramáticas Livres de Contexto.

198
0
0
Oscar Lima Neto
Created by Oscar Lima Neto over 8 years ago
Close

Exercícios - Ambiguidade

Question 1 of 5

1

Verifique se a afirmação abaixo é verdadeira ou falsa.
A gramática G = ({S, X, Y, Z}, {0, 1}, S, P), onde
P = { S → 0X
X → 10Z | 1Y
Y → 0Z
Z → 1|0 } NÃO é ambígua.

Select one of the following:

  • True
  • False

Explanation

Question 2 of 5

1

Verifique se a afirmação abaixo é verdadeira ou falsa.
A gramática G = ({S}, {a, b}, S, P), onde
P = { S -> SS
S -> a
S -> b} é ambígua.

Select one of the following:

  • True
  • False

Explanation

Question 3 of 5

1

Considere a gramática G = ({S}, {a, b, c, +, *, ( , ) }, S, P), onde P = { S→ SS | S+S | S* | (S) | a | b | c }.
Ela é ambígua devido ao fato de suas derivações serem :

Select one of the following:

  • S => SS => SSS => cSS => caS => cab
    S => SS => SSS => SSb => Sab => cab

  • S => SS => SSS => (S)SS => (a)SS => (a)bS => (a)bb
    S => SS => (S)S => (a)S => (a)SS => (a)bS => (a)bb

  • S => SS => SSS => SSb => (S)bb => (a)bb
    S => SS => (S)S => (S)SS => (a)SS => (a)bS => (a)bb

Explanation

Question 4 of 5

1

A afirmação abaixo está correta?
A gramática G = ({S, X}, {a, b} , {S → X | Sa, X → a | b}, S) NÃO é ambígua.

Select one of the following:

  • True
  • False

Explanation

Question 5 of 5

1

Considere a gramática G = ({S}, {a, b}, {S -> aSbS | bSaS | a | b}, S).
Está é ambígua pelo fato de suas derivações serem:

Select one of the following:

  • S => bSaS => bSaa => baaa
    S => bSaS => baaS => baaa

  • S => bSaS => bSSaS => baSaS => baaaS => baaab
    S=> bSaS => bSaSS => bSaSb => bSaab => baaab

  • S => aSbS => aSba => abSaSba => abSabba => abbabba
    S => aSbS => aSbaSbS => aSbaSba => aSbabba => abbabba

Explanation