Search⌘ K
AI Features

Examples of PDA

Discover how pushdown automata (PDA) recognize complex languages such as palindromes and balanced symbol counts. Learn examples illustrating deterministic and nondeterministic PDAs, stack usage, and transition tables to deepen your understanding of context-free languages and automata behavior.

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.

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's. The minimal string ...