Design a dfa to recognize language l

Assignment Help Theory of Computation
Reference no: EM13648109

Define the language L to consist of strings that represent certain web-page addresses. For this assignment you are to design a DFA to recognize L and write a program that implements your DFA.

The Language L

To precisely specify L, first define Γ = {a, b, c, . . . , z} as the set of lower-case Roman letters, and let Σ = Γ ∪ {.}; i.e., Σ is the set consisting of all the lower-case Roman letters and the dot (or period). Define the following sets:

S1 = {www.}

S2 = ΓΓ∗, which consists of strings over Γ of positive length

S3 = {.com} ∪ {.co.jp}

Then we define the following sets of strings over Σ:

L1 = S1S2S3

L2 = S2S3

L = L1 ∪ L2

Strings in L1 are (a subset of) web addresses that have three parts, where the first part is "www.", the second part is a positive-length string of lower-case Roman letters, and the third part is ".com" or ".co.jp". (The suffix ".co.jp" is used in some web addresses in Japan.) Strings in L2 are (a subset of) web addresses that have only the last two parts. For example, the strings www.abcdef.com, www.com.com, www.co.com, www.abcdef.co.jp, www.com.co.jp, and www.co.co.jp belong to L1, and the strings abcdef.co.jp, www.co.jp, abcdef.co.jp, and www.co.jp belong to L2.

The specification of L does not include all valid web addresses since we included several restrictions to simplify the assignment. For example, only lower-case Roman letters and dots are allowed, strings in L must end with .com or .co.jp, etc.

DFA for L

First construct a DFA M = (Q, Σ, δ , q1, F ) that recognizes L. The DFA must satisfy each of the following properties:

The DFA must be defined with the above alphabet Σ. Your DFA does not have to handle symbols that are not in Σ.

The states in the DFA must be labeled q1, q2, q3, . . . , qn, where q1 is the start state and n is the number of states in the DFA. (It is also acceptable for the states to be labeled q0, q1, . . . , qn-1, with q0 the start state.)

You will lose points if your DFA is overly complicated. To simplify your DFA drawing, omit any edges going from a state q ?∈F to a "trap state" (i.e., a non-accepting state from which the DFA can never leave). All other edges must be included in your drawing. Clearly identify which state is the trap state in the drawing of your DFA. Also, to simplify your drawing, you should define Γl = Γ - {l} for any symbol l ∈ Γ; i.e., Γl is the set of all lower-case Roman letters except for l. For example, Γw = {a, b, c, . . . , v, x, y, z}, so your DFA might include something like the following:

1720_DFA.png


Thus, if the DFA is currently in state q1, then it moves to q2 on reading w, and it moves to state q3 on reading any other lower-case Roman letter.

Program Specifications

You must write your program in either C, C++, or Java. All input/output must be through standard input/output, and your program is to work as follows:

1. Your program asks the user if s/he wants to enter a string. The user then enters "y" for "yes", or "n" for "no".

If the user enters "n", then the program terminates.
If the user enters "y", then the user is prompted to enter a string over Σ.

2. If the user chooses to input a string, your program then reads in the string. After reading in the string, your program prints it. Then your program processes the entire string on the DFA, one character at a time, in the following manner.

Your program must begin in the start state of the DFA and print out the name of that state (q1 or q0).

After each character from the string is processed on the DFA, your program must print out the character and the name of the current state of the DFA. Even if your DFA is in a trap state, your program must do this for each character in the string until it reaches the end of the string.

To simplify your program, you should check the ASCII code of each character of the string and process on the DFA accordingly.

3. After processing the entire string on the DFA, your program must indicate if the string is accepted or rejected based on the state in which the DFA ended. Your program then should return to step 1.

Reference no: EM13648109

Questions Cloud

Compute what frequency do you hear : if you move at 14m/s toward a 2300Hz source that is movingtoward you with a ground speed of 38m/s, what frequency do you hear
Proton movesin a circular orbit just outside spherical shell : A particle of charge -60nC is placed at the center of anon-conducting spherical shell of inner radius 20cm and outerradius 25cm. The spherical shell is uniformly charged with acharge density of -1.33μC/m3.
What is the intensity level of this sound in decibels : The sound in a classroom is 68000 times asintense as the minimum threshold of hearing. What is the intensity level of this sound in decibels
Explain why easier to remove electron from the energy levels : Why is it easier to remove electron from the first two energy levels of mg but easier to remove third level electron of argon
Design a dfa to recognize language l : Design a DFA to recognize L and write a program that implements your DFA - you should check the ASCII code of each character of the string and process on the DFA accordingly.
Obtain what is the index of refraction of the liquid : Light in a vacuum is incident on a transparent glass slab. Theangle of incidence is 32.0° . The slab is then immersed in a pool of liquid. What is the index of refraction of the liquid
Evaluate how far would it have traveled in a vacuum : A flat sheet of crystalline quartz has athickness of 3.1 cm. It is on top of aflat sheet of diamond that has a thicknessof 3.0 cm. how far would it have traveled in a vacuum
Depict all the monochlorinated derivatives : Draw all the monochlorinated derivatives of 2,2,3,3-tetramethylbutane that are skeletal isomers of one another. To make a monochlorinated derivative of a compound, replace one H atom in the compound with Cl.
What is the radius of the pipe on the second floor : Water(density=1.00X103 kg/m3) flows at10.0m/s through a pipe with radius 0.030m. What is the radius of the pipe on the second floor

Reviews

Write a Review

Theory of Computation Questions & Answers

  Write grammar for language comprising of strings

Write down the grammar for language comprising of strings which have n copies of letter a followed by same number of copies of letter b, where n > 0.

  The challenges of antonios wayfive basic goals often

the challenges of antonios wayfive basic goals often referred to as the backbone of antonios way were posted in

  A music store owner wants to have enough

A music store owner wants to have enough of the hottest CDs in stock so people who come to buy a particular CD won't be disappointed - and the store won't lose the profit. CDs that are not sold within a certain length of time go onto the sale tabl..

  Why are there so many laws relating to hrm practices which

why are there so many laws relating to hrm practices? which are the most important laws in your opinion?what

  1centred on the significance and relevance of ramps to

1centred on the significance and relevance of ramps to canadian organizations why is ramps important? and why is it

  Compute a shortest superstring

Dynamic programming algorithm to compute a shortest superstring.

  Communication process using a particular computer device

The enhancement of communication process using a particular computer device or software application by the people.

  Equivalence classes to construct minimal dfa for language

How many equivalence classes does this relation have and what are they? Use these equivalence classes to construct the minimal DFA for the language.

  Modify the syntax of a programming language

Sometimes it is necessary to modify the syntax of a programming language. This is done by changing the CFG that the language uses. What changes would have to be made to ac's CFG (Figure) to implement the following changes?

  Many programs require the use of an input

Many programs require the use of an input mechanism to get data into the program and an output mechanism to present results and guidance.

  Question 1 given the productionss-gt sa aaa absa-gt acaa

question 1. given the productions.s-gt sa aaa absa-gt acaa list the parse table. is the grammar ll1 in this form? if

  Turing machine model

Think about the following Turing-machine model, A tape that is infinitely long in both directions and is divided into cells; at any given step, each cell either is blank or contains a 1.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd