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.

Get hands-on with 1200+ tech skills courses.