C12 - Lab Question With Answer
C12 - Lab Question With Answer
C12 - Lab Question With Answer
00 and 11 at the end of a string containing 0, 1 in it, e.g., 01010100 but not
000111010.
Explanation – Design a DFA and NFA of a same string if input value reaches the
final state then it is acceptable otherwise it is not acceptable.
NFA of the given string is as follows:
Here, q0 shows the initial state, q1 and q2 are the transition states, and q3 is the
final state.
Que-3: Draw a deterministic and non-deterministic finite automata which accept
a string containing “ing” at the end of a string in a string of {a-z}, e.g.,
“anything” but not “anywhere”.
Explanation – Design a DFA and NFA of a same string if input value reaches the
final state then it is acceptable otherwise it is not acceptable. It is applicable for
all the DFA and NFA.
NFA of the given string is as follows:
Here, q0 shows the initial state, q1 and q2 are the transition states, and q3 is the
final state.
Q4. What is ALGOL ?
Answer:ALGOL (ALGOrithmic Language) is one of several high level languages designed specifically
for programming scientific computations. It started out in the late 1950’s, first formalized in a report
titled ALGOL 58, and then progressed through reports ALGOL 60, and ALGOL 68. It was designed by
an international committee to be a universal language. Their original conference, which took place in
Zurich, was one of the first formal attempts to address the issue of software portability. ALGOL’s
machine independence permitted the designers to be more creative, but it made implementation
much more difficult. Although ALGOL never reached the level of commercial popularity of FORTRAN
and COBOL, it is considered the most important language of its era in terms of its influence on later
language development. ALGOL’s lexical and syntactic structures became so popular that virtually all
languages designed since have been referred to as “ALGOL – like”; that is they have been
hierarchical in structure with nesting of both environments and control structures.
Q5. What is the difference between Palindrome and Reverse function?
Answer:It is to be denoted that the words of PALINDROME are called palindromes.
Reverse =w
Example: Σ={a,b},
If a is a word in some language L, then reverse (a) is the same string of letters spelled backwards,
called the reverse of a.
e.g
Examples
If Σ = {x}
If Σ = {0,1}
If Σ = {aaB, c}
Note:
Languages generated by Kleene Star Closure of set of strings, are infinite languages. (By infinite
language, it is supposed that the language contains infinite many words, each of finite length)
Q7. What is the difference between FA , TG , GTG. ?
In every FA, we mark transitions with single letter of the given alphabet but in TG transitions can be
marked with letters or strings (combination of letters).
In every FA, every state shows transition for all letters of given alphabet but in any TG it is not
necessary to show all transition for all letters of given alphabet. In TG, we may or may not show all
letter transitions according to requirement. We can also show transitions on reading any strings in
TGs but it is not possible in FA’s. In GTG Directed edges connecting some pair of states are labeled
with regular expressions . It may be noted that in GTG, the labels of transition edges are
corresponding regular expressions. In TG we write strings and in GTG we are bound to write RE.
Every FA is also a TG but not every TG is FA.
First thing about RE and FA is that there is no hard and fast formula or method to generate these.
One can generate them by its mental approach. And this mental approach can be acquired through
only PRACTICE.
Let our language consist of the words of length three exactly over alphabet Σ= {a,b}
which simply means that our language consists of only these words.
So we can make RE for a finite language by writing its all words with + operator between them.
We should also keep the null string in our mind. If our language generates null string than our RE
should also generate it)
For example language having all the words of even length has null string in it as well so we can write
its RE as follows
RE = ((a+b)(a+b))*
If a language generates all strings starting with a. then strings will be of type
Here RE should start with ‘a’ and then all strings including null. So this will be (a + b)* and complete
RE is a (a+ b)*.
Now, how to traverse the FA. It is very easy. Every FA has one initial state (state with -sign). From
every state of FA there is one transition for every letter of the alphabet. Read the string letter by letter
and move according to transitions from state to state. If the string ends in the final state (state with a +
sign), that particular string will be accepted otherwise rejected.
So, every string ending in final state will be accepted by FA and will be a word of the language.
For NFA, there may be no path or more than one path for a letter from a specific state. As similar to
FA just start traversing from the initial state and if the string ends in the final state, it will be accepted.
Remember, as there may be more than one path for a letter from a state. So any path can be used.
Goal is to reach the final state. Remaining theory is same to the FA.
Practice is the key to success. Just try simple FA’s and NFA’s in the start.
Q10. What is the concept of Pumping Lemma I and II and what is the difference between
pumping Lemma 1 and pumping Lemma 2 ?
In fact PLI & PLII are same (A way to recognize Non Regular language). The only difference is that
the conditions in pumping lemma II are more stricter than Pumping Lemma I some language that are
difficult to proof Non Regular by Pumping Lemma I are proved Non Regular by pumping Lemma II
easily.
Further mare in pumping lemma I we have to generate all words to of a language but in Pumping
Lemma II we have to generate a single word to prove a language non regular.
Explanation:
Some languages like PALINDROME that are proved to be regular by first version
due to some of their symmetrical words when we pump these words they remain to be
bbabb
By pumping lemma 1
Let y = a
bbaaabb
That is also a valid word of PALINDROME so by pumping lemma I PALINDROME can not be proved
non regular, so there was the need of pumping lemma version version 2.
bbabb
if we take N=2
bbbbabb
bbaaabb
and also the repeating factor (y) to prove an infinite language non regular you
need to prove only one word that is not part of the language.