hw7f03-sol-post

# hw7f03-sol-post - CS373 Fall 2003 NMG*Solutions Homework...

This preview shows pages 1–3. Sign up to view the full content.

CS373 – Fall 2003 – NMG *************Solutions ********************+ October 27, 2003 Homework Assignment 7 for chapter 7 Due 10/31/03 (Friday) at end of class Problems related to chapter 7. Unless otherwise noted you are to assume the conventions and definitions used in our text by Linz for push down automata and related topics. If you must write the δ rules for a pushdown automaton, write concise, clear comments to the right of the transition rules (as needed) explaining the meaning and intent of the rules. 1. Construct an NPDA that accepts L = {w : n a (w) + n b (w) = n c (w)}. 2. Construct an NPDA that accepts L = {a 3 b n c n : n 0}. 3. Construct an NPDA that accepts L = {a n b n+m c m : n 0, m > 0 }. 4. Consider the following “mystery” NPDA: δ (s, a, z) = {s, cz} δ (s, a, c) = {s, cc} δ (s, b, z) = {(s, cz), (r, z)} δ (s, b, c) = {(s, cc), (r, c)} δ (r, a, c) = {r, λ } δ (r, b, c) = {r, λ } δ (r, λ , z) = {f, z} where Q = {s, r, f}, = {a,b}, Γ = {c, z}, F (final state) = {f} Determine if the following strings are accepted or not. Show the sequences of instantaneous transitions for accepted strings, or give a convincing argument for those not accepted. From this exercise or analysis of the rules, state the language accepted by this NPDA in set theoretic notation; give a convincing reason for your choice of language. a b aababaaab baaabbaab aabbabbaa abbbabbbb State the language accepted by this NPDA in set theoretic notation. 5. An alternate definition of an NPDA is a modification of the definition given by Linz. The alternate definition allows a λ to appear as the third argument of δ (top of the stack). The meaning of λ in this position is that the stack top is ignored as an input to δ and consequently nothing is popped off. Also only one symbol at a time may be pushed on the stack as opposed to a string of symbols in the Linz definition. In addition, there is no end of stack symbol (z) as in Linz. All computations start

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
with an empty stack. Finally, language acceptance requires that the stack be empty as well as being in a final state when the input string is completely consumed (see problem 2). The formal definition would be M = {Q, , Γ , δ , q 0 , F} … note there are 6 things instead of 7 Where Q is a finite set of states is the input alphabet Γ is the stack alphabet δ : Q X ( { λ }) X ( Γ { λ }) finite subsets of Q X Γ * , the transition function q 0 is the initial state F Q is the set of final states The Linz solution to the even palindrome problem given in Linz’s book, example 7.4, page 186 is a bit ugly. Using the above definitions, show a more elegant solution. You should be able to do it in two states and 5 transitions functions. 6.
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 05/07/2010 for the course COMPUTER S 138 taught by Professor Icamarra during the Spring '10 term at UCLA.

### Page1 / 10

hw7f03-sol-post - CS373 Fall 2003 NMG*Solutions Homework...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online