...

/

Examples of PDA

Examples of PDA

Learn about pushdown automata using some examples.

Let’s look at a few examples of pushdown automata that accept the following languages:

  • L={wcwR    w(a+b)}L = \{wcw^R\;|\;w \in (a+b)^*\}
  • M={wwR    w(a+b)}M = \{ww^R\;|\;w \in (a+b)^*\}
  • N={ambnm<=n<=2m}N = \{ a^m b^n \:|\: m <= n <= 2m \}
  • P={na(w)=nb(w)w(a+b)}P = \{n_a(w) = n_b(w) \:|\: w \in (a+b)^* \}
  • Q={nb(w)=2na(w)w(a+b)}Q = \{n_b(w) = 2n_a(w)\:|\: w \in (a+b)^* \}
  • R={aibjcki=ji=k}R = \{ a^i b^j c^k \:|\: i=j \vee i=k \}
  • S={aibj    ij}S = \{ a^ib^j \;|\; i \neq j \}

PDA for palindromes

The following PDA accepts the language L={wcwR    w(a+b)}L = \{wcw^R\;|\;w \in (a+b)^*\}, i.e., odd-length palindromes of aa's and bb's with a cc in the middle.

Press + to interact
PDA that accepts the language L
PDA that accepts the language L

We push distinct symbols for aa's and bb's. Once the cc is consumed, we expect to find the reversal of the first half of the string in terms of XX's and YY ...

Access this course and 1400+ top-rated courses and projects.