NFC INSTITUTE OF ENGINEERING &
TECHNOLOGY
SUBMITTED BY:
Name: Sana Fatima
Roll #: 2k20mscs119
Session: 2020-2022
Department: Computer Science
Assignment Topic Finite Automata
SUBMITTED TO:
Name: Dr. Naeem Aslam
Department: Computer Science (Head)
CHAPTER # 5:
PROBLEM 2: Build an FA that accepts only the language of all words with b as the second
letter. Show both the picture and the transition table for this machine and find a regular
expression for the language.
RE = (b + a) b (a + b)*
PROBLEM 3: Build an FA that accepts only the words baa, ab, and abb and no other
strings longer or shorter.
RE = baa + ab + abb
PROBLEM 4(I): Build a new FA that accepts only the word ^.
RE = ^
PROBLEM 4(II): Build an FA with three states that accept all words.
RE = (a + b ) *
PROBLEM 5: Build an FA that accepts only those words that have an even number of
letters total.
RE = (( a + b ) ( a + b ) ) *
PROBLEM 6: Build an FA that accepts only those words that do not end with ba
RE = (a + b) * ( ab + bb + aa) + a + b + ^ OR a* b *
PROBLEM 7: Build an FA that accepts only those words that begin or end with a double
letter.
RE = (aa( a+ b)*+(a+ b)*aa)+(bb(a+ b)*+(a+ b)*bb) OR
(aa+ bb)(a+ b)* + (a+ b)*(aa+ bb)
PROBLEM 8(I): Build an FA that accepts only those words that have more than four
letters.
RE = (a+ b)(a+ b)(a+ b)(a+ b)(a+ b)(a+ b)* OR
(a+ b)(a+ b )(a+ b )(a+ b )(a+ b ) OR
(a+ b)5(a+ b)*
PROBLEM 8(II): Build an FA that accepts only those words that have fewer than four
letters.
RE = ^ + a + b +(aa+ bb+ ab+ ba)+(a+ b)(a+ b)(a+ b)
PROBLEM 9: Problems 2 through 12 of Chapter 4 include 14 languages that could be
represented by regular expressions. For each of these find an FA that accepts exactly it
2: All words in which a appears tripled, if at all. This means that every clump of a's contains
3 or 6 or 9 or 12... a's.
RE = aaa + (b)*+ aaa
3: All words that contain at least one of the strings s, s2 s3 or s4.
RE = (a+ b)*(s1+ s2+ s3+ s4)(a+ b)*
4: All words that contain exactly three b's in total.
RE = a*ba*ba*ba*
5: All words that contain exactly two b's or exactly three b's, not more.
RE = (a*ba*ba*) + (a*ba*ba*ba*)
6: (i) All strings that end in a double letter.
RE = (a+ b)*(aa+ bb)
(ii) All strings that have exactly one double letter in them.
RE = (a+ b)*(aa+ bb)(a+ b)*
7: All strings in which the letter b is never tripled. This means that no word contains the
substring bbb.
RE = (^+ b+ bb) (a+ ab+ abb)* (from net)
8: All words in which a is tripled or b is tripled, but not both. This means each word
contains the substring aaa or the substring bbb but not both.
RE = [(^ + ab + abb) aaa ( b + ba + baa)] + [(^ + ba + baa) bbb (a + ab+ abb)]
9: (i) All strings that do not have the substring ab.
RE = (a+ b)*(ba+ bb+ aa)+a+ b+^ OR b*a*
(ii) All strings that do not have both the substrings bba and abb.
RE = (^+ a+ ba+ baa)*(ba+ ab)* OR
a*(baa*)*b*+b*(a*ab)*a*
10: All strings in which the total number of a's is divisible by three, such as aabaabbaba.
RE = (b*ab*ab*ab*)*
11: (i) All strings in which any b's that occur are found in clumps of an odd number at a
time, such as abaabbbab.
RE = a*b(a+ bb)*
(ii) All strings that have an even number of a's and an odd number of b's.
RE = b (aa+ bb)*
(iii) All strings that have an odd number of a's and an odd number of b's.
RE = ab (aa+ bb)*
PROBLEM 11: Recall from Chapter 4 the language of all words over the alphabet {a,b} that
have both the letter a and the letter b in them, but not necessarily in that order. Build an FA
that accepts this language.
RE = ((aa*+ b) + (bb*+ a)) (a+ b)*
PROBLEM 12: Build an FA that accepts the language of all words with only a's or only b's
in them. Give a regular expression for this language.
PROBLEM 17: Find two FA's that satisfy these conditions: Between them they accept all words
in (a + b)*, but there is no word accepted by both machines.
RE = (aa + bb + ab + ba)*(a + b) RE = (^ +aa+ bb+ ab+ ba)*(a+b)
PROBLEM 18: Describe the languages accepted by the following FA's
RE = (aa + bb + ab + ba )*(a + b) RE = (a + b)*(a + aa)
RE = (a + b)a((a + b)a)* OR (a + b)* a((a + b)* a)*