Design a non-ambiguous grammar generating the language consisting of all binary strings, which contain an odd number of 0’s and an odd number of 1’s. Justify correctness of your construction.
Answer :
C → 0B | 1A
P → 0A | 1B | ε
A → 0P | 1C
B → 1P | 0C
Explanation :
Example string to parse the grammar : 010101
C -> 0B
-> 01P
-> 010A
-> 0101C
-> 01010B
-> 010101P
-> 010101
Design a non-ambiguous grammar generating the language consisting of all binary strings, which contain an odd...
Design an attribute grammar recognizing the language consisting of binary strings containing the same number of 0’s and 1’s. Explain your construction
Write a context-free grammar for the language where all strings are of even length and the first half of the string is all 0’s, but it must be an odd number of 0’s
1. Let £ = {0,1} and consider the language L of all binary strings of odd length with a 0 in the middle. Give a Turing machine that decide L.
13.) Write a grammar for the language consisting of strings that have n copies of the letter a followed by one more number of copies of the letter b, where n>0. For example, the strings abb, aaaabbbbb, and aaaaaaaabbbbbbbbb are in the language but a, ab, ba, and aaabb are not. Answer the aaaaaabbbbbbbh are in the languagebr 14.) Draw parse trees for the sentences abb and aabbb, as derived from the grammar of Problem 13. Answer:
For each of the following, construct context-free grammars that generate the given set of strings. If your grammar has more than one variable, we will ask you to write a sentence describing what sets of strings you expect each variable in your grammar to generate. For example, if your grammar were: S → EO E → EE CC 0+ EC C+01 We would expect you to say “E generates (non-empty) even length binary strings; O generates odd length binary strings;...
Express as a set using set-builder notation The set of all binary strings that contain at least one 0 and at least one 1. The set of all binary strings with even length. The set of all binary strings that contain an even number of 1’s. The set of all binary strings that read the same forward and backwards
Draw an automaton which will accept all integers (in binary form) of Odd parity (number of 1’s in the string is odd). Now write a code in a high level language (C++) for the automaton. Take inputs of two strings, one of odd parity (e.g, 00111011) and another one of even parity (e.g., 1100110011). Your code should accept the right string and reject the wrong one. Print your code and results
If you could please help with 1-3. 4 if you can but it is not necessary. Thanks Name: Solve problems 1-3. Problem 4 counts for extra credit. Each problem counts for 3 points. 1. Construct a non-ambiguous grammar generating the language consisting of all strings over the alphabet = {0,1,2), which contain no adjacent 1's. Provide a justification of correctness of your construction. 2. A Huffman tree constructed out of characters aj, az, az, ..., an, occurring with frequencies fi...
Design a regular grammar to generate the set of all even integers. Design a regular grammar to generate the set of all odd integers. Design a regular grammar to generate the set of all integers beginning with the digit 8 such that the digits are consecutive and even. If a digit is 8, its following digit (if present) will be 0. The set of valid strings is {8, 80, 802,8024, 80246, 802468,...) Design a regular grammar to generate the set...
can you plzz do question 1 and 2 Question 1. Design a CFG for the language over = {1, #} whose elements consist of every pair of distinct, #-separated unary values: L = {rı#x2 | 21, 22 € 1", 21 * x2}. Question 2. Design a CFG for the language of binary strings that contain at least one 1 in their second half: L = {uv | UE (OU 1)", v € OU 1)*1(0U 1)", [u '}. Question 3. This...