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

  Redundant sequence identi cation

Redundant sequence identi cation

  Question about perfect programming language

I have noticed that there are several languages, is this because no one language has all the main elements needed to be a perfect programming Language?

  You have to design a syntactic analyzer for the language

you have to design a syntactic analyzer for the language specified by the grammar below. we are using the following

  In an internet retailer you will find a wide range of job

in an internet retailer you will find a wide range of job functions. leaders frequently need to adjust their own

  Rice-s theorem for enumerable or non-re

We know by rice's theorem that none of the following problems are decidable. However,are they recursively enumerable,or non-RE? IS L(M) infinite?

  Considering a single programmed operating system

Considering a single programmed operating system, what is the minimal total time required to complete executions of the two processes? You should explain your answer with a diagram.

  Formulate the corresponding coffee-machine decision problem

meeting rooms on university campuses may or may not contain coffee machines. we would like to ensure that every meeting

  Write down binary representation of decimal number

Calculate the sum of 2.6125 X 101 and 4.150390625 X 10-1 by hand, assuming A and B are stored in the 16-bit half precision described in exercise 3.27. Assume 1 guard, 1 round bit, and 1 sticky bit, and round to the nearest even. Show all steps.

  Extend the ac scanner

A floatdcl can be represented as either f or float, allowing a more Java-like syntax for declarations - a intdcl can be represented as eitheri or int.

  1 the subset-sum problem is defined as follows given a set

1. the subset-sum problem is defined as follows given a set b of n positive integers and an integer k can you find a

  We have two versions of tn above depending on whether we

question we have two versions of tn above depending on whether we use a constant c or not. explain why the two versions

  Design unambiguous grammar to parse expressions

Write a program would read two numbers and then print all numbers between the first and the second, inclusive. Design unambiguous grammar to parse expressions

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