t12samplesol

t12samplesol - plement and concatenation 4 The set BALANCED...

This preview shows page 1. Sign up to view the full content.

COT 6315/CIS 4930 Sample Test 2 (Solutions) 1. Not context free. Proof by contradiction. Suppose that QUITEEQUAL is context free. Then the intersection of QUITEEQUAL and regular lan- guage a * c * b * d * should be context free as well. However this intersection a n c m b n d m is not context free (see problem 2 (iii) of the second homework). Therefore QUITEEQUAL is not context free. 2. The set WEIRD is regular. It can be represented as L 1 L 2 L 3 where L 1 = (1 * 01 * 01 * ) * is a regular language of strings that have even number of zeroes, L 2 = (0 * 10 * 10 * 10 * 10 * 10 * ) * is a regular language of strings that have a number of 1’s that is not a multiple of 5, and L 3 = ((0 * 1 * ) * 1) * (00) * 000 is a regular language of strings that end with an odd number of 0’s (atleast 3). Since set of regular languages is closed under intersection, set WEIRD is regular. 3. The language VERYDIFFERENT(L) is regular if L is regular, since VERYDIFFERENT(L)= Σ * L Σ * and set of regular languages is closed under operations of com-
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: plement and concatenation. 4. The set BALANCED is context free but not regular. It is context free because there is PDA for it (We want to check whether k − l = n − m . This can be done as follows. Push all a s, pop an a for every input b , push remaining b s (if any). At this stage stack contains either k − l a s or l − k b s. There are two cases. (1) If stack contains a s then pop an a for every input c , when stack becomes empty push all remaining c s, pop a c for every input d , accept if stack is empty after last input d . (2) If stack contained b s then push all c on a stack, pop a symbol ( c or b ) for every d , accept if stack is empty after last input d . The set BALANCED is not regular because BALANCED ∩ a * b * = a n b n is not a regular language, and set of regular languages is closed under intersection. 1...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online