Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please provide solution in detail. Thank you!! 1 Rewrite Systems Remember our re

ID: 3748196 • Letter: P

Question

Please provide solution in detail.
Thank you!!

1 Rewrite Systems Remember our rewriting "game in the first lecture (a) Given the same input, e., a sequence of characters starting with S and ending with #, and any combination of 0s and 1s in-between, specify a set of rewrite rules that determine whether the string contains the same number of Os and 1s. Here is some sample "output" $0011# should be rewritten as $# $1001# should be rewritten as $# $110110# should be rewritten as $11# $0001100# should be rewritten as $000# In other words, the $# indicates that the input string has the same number of Os and 1s. If the string does not contain the same number of 0s and 1s, the resulting string shows how many more 0s or 1s there are in the input string (b) Is there at most only a single rewrite rule that can be applied at any point in time during the rewrite process? Explain. (c) Show the steps of your rewrite system for the input strings $0101# and $ 10110# 2 Regular Expressions Write a regular expression for numeric constants in C. These are octal, dec mal, or hexade An octal integer begins with 0, and may contain only the digits 0-7. A hex adecimal integer begins with 0x or OX, and may contain the digits 0-9 and a/A-f/F. A decimal floating-point value has a fractional portion (beginning cimal integers, or decimal or hexadecimal floating-point values.

Explanation / Answer

4) Regular Expressions

a) string will contains a's, b's, c's and no a should follow b, examples of these type of strings are:

aabbcc, ccccaaab, bcccca etc

regular expression will be : (a+b+c+) | (c+a+b+) | (b+c+a+)

string can be of any of the three type mentioned above in regular expression

+ denotes 1 or more occurence of the letter

eg c+ denotes 1 or more occurence of c

as in question it is mentioned that string should contain a, b ,c thats why we have used + in regular expression.

(a+b+c+) denotes a's followed by b's then b's followed by c's . It is acceptable.

or string can also be like below:

(c+a+b+) denotes c's followed by a's then a's followed by b's . It is acceptable.

or string can also be like below:

(b+c+a+) denotes b's followed by c's then c's followed by a's . It is acceptable.

Therefore we can mentioned all these with | (or) sign :

(a+b+c+) | (c+a+b+) | (b+c+a+)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote