0% found this document useful (0 votes)
26 views11 pages

Q Bank With Syllabus

Uploaded by

Souvik Gon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views11 pages

Q Bank With Syllabus

Uploaded by

Souvik Gon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Automata Q bank with Syllabus :[CA3 guidance]

Syllabus:

Formal Language & Automata Theory:


Syllabus for CA3
PCC-CS-403
1. Chomsky Hierarchy of language.
2. Finite Automata. (Acceptance of any string by Finite Automaton, Mealy to Moore
& Moore to mealy.)
3. Deterministic Finite Automata (DFA) & Non Deterministic Finite Automata
(NDFA), conversion or NFA equivalence with DFA.
4. Minimization of finite Automata.
5. Definition of Grammar & Derivation / parse tree.

Some important theoretical and numerical Questions:

Q. Construct a DFA over Σ={a,b}


Where the length of the string is even.

Ans.
Length={0,2,4,6,8,…}
L={ €, aa,ba,bb,ab,aaa,bbb,aba,…,aaaa,bbbb,…. }

Q1. Define Automata.


Automata are abstract machines used to study computational processes.

They can recognize patterns in strings of symbols. Automata theory categorizes them
based on computational power. Examples include finite automata and Turing machines.
They are fundamental in computer science for tasks like parsing and formal verification.

Q2. What is Grammer.


In automata theory, a grammar defines the syntax of a formal language.
It consists of a set of production rules governing how symbols can be combined. Grammars are
commonly used to generate strings that are valid in a language. They are classified into different
types, such as context-free and regular grammars. Grammars play a crucial role in parsing and
language processing tasks.
Eg. Given alphabet Σ={a,b}, Grammer says suppose all the strings with length equal to two.
Then L={aa,ab,ba,bb}. So the grammer here is |w|=2.

Q3. Define derivation Tree.

A derivation tree, also known as a parse tree or syntax tree, is a graphical representation of the
syntactic structure of a string generated by a grammar.
It depicts how the string is derived by applying production rules of the grammar.

Nodes in the tree represent symbols, while edges represent the application of production rules.
The root of the tree represents the start symbol of the grammar, and each leaf node
corresponds to a terminal symbol or an empty string.

Consider a simple grammar:


```
S -> AB
A -> a
B -> b
```

Now, let's derive the string "ab" using this grammar:

1. Start with the start symbol S.


2. Apply the production rules to derive the string:
```
S -> AB
-> aB
-> ab
```

Here's how the derivation tree would look:

```
S
/\
A B
/ \
a b
```

In this tree:
- The root node represents the start symbol S.
- The left child of S represents the non-terminal A, which derives the terminal symbol 'a'.
- The right child of S represents the non-terminal B, which derives the terminal symbol 'b'.
This tree visually illustrates how the string "ab" is derived from the start symbol S using the
given production rules.

Q4. Explain Chomsky classification of Language with proper diagram.


Chomsky's classification of formal grammars is categorized into four types, each representing a
different level of generative power:

1. Type 0: Unrestricted or recursively enumerable grammars


2. Type 1: Context-sensitive grammars
3. Type 2: Context-free grammars
4. Type 3: Regular grammars

Here's an overview of each type with a diagram representing the hierarchy:

1. Type 0 (Unrestricted grammars):


- These grammars have the most generative power.
- There are no restrictions on production rules.
- The rules can rewrite any combination of terminals and non-terminals.
- Turing machines can recognize languages generated by Type 0 grammars.

2. Type 1 (Context-sensitive grammars):


- Production rules have the form αAβ → αγβ, where A is a non-terminal and α, β, and γ are
strings of terminals and non-terminals.
- Context-sensitive grammars can generate languages that are more complex than context-free
grammars but less than Type 0.
- Languages generated by Type 1 grammars can be recognized by linear-bounded automata.

3. Type 2 (Context-free grammars):


- Production rules have the form A → β, where A is a non-terminal and β is a string of
terminals and non-terminals.
- Context-free grammars are widely used in programming languages, compiler design, and
natural language processing.
- Languages generated by Type 2 grammars can be recognized by pushdown automata.

4. Type 3 (Regular grammars):


- Production rules have the form A → aB or A → a, where A and B are non-terminals, and 'a' is
a terminal.
- Regular grammars represent the least powerful class of Chomsky's hierarchy.
- Regular grammars can be represented by finite-state machines (FSMs) or regular expressions.
- They are used for pattern matching, lexical analysis, and simple language structures.

This hierarchy illustrates the relationship between different classes of grammars based on their
generative power. As we move down the hierarchy, grammars become more restricted in their
expressive power but easier to parse and analyze.

Q5. What is Theory of Computation.


Theory of computation is a branch of computer science focusing on understanding the nature of
computation. It explores formal models of computation, such as automata and grammars, and
their computational power. It studies problems related to computability, decidability, and
complexity. This field underpins the development of algorithms, languages, and systems in
computer science.

Q6. Consider a machine M given in Fig (1.0). Construct its equivalent Moore
Machine: [10]

Present State N/S N/S


INPUT(a=0) O/P INPUT(a=1) O/P

q1 q3 0 q2 0

q2 q1 1 q4 0

q3 q2 1 q1 1

q4 q4 1 q3 0

Fig (1.0)

Ans 6. To construct the equivalent Moore Machine from the given state transition table, we need
to define the states, inputs, outputs, and the transition function. In a Moore Machine, the output
depends only on the current state.

Given the state transition table:

```
Present State INPUT(a=0) OUTPUT INPUT(a=1) OUTPUT
---------------------------------------------------------------
q1 q3 0 q2 0
q2 q1 1 q4 0
q3 q2 1 q1 1
q4 q4 1 q3 0
```

Let's define the states, inputs, outputs, and the transition function:

States:
- q1
- q2
- q3
- q4

Inputs:
- a=0
- a=1

Outputs:
-0
-1

Transition Function:
- For state q1:
- If input a=0, transition to state q3 with output 0.
- If input a=1, transition to state q2 with output 0.
- For state q2:
- If input a=0, transition to state q1 with output 1.
- If input a=1, transition to state q4 with output 0.
- For state q3:
- If input a=0, transition to state q2 with output 1.
- If input a=1, transition to state q1 with output 1.
- For state q4:
- If input a=0, remain in state q4 with output 1.
- If input a=1, transition to state q3 with output 0.

Equivalent Moore Machine:

```
| a=0 / 0 a=1 / 0
-------------------------------
q1 (0) -> | q3 (0) q2 (0)
q2 (1) -> | q1 (1) q4 (0)
q3 (1) -> | q2 (1) q1 (1)
q4 (1) -> | q4 (1) q3 (0)
```

In this Moore Machine:


- States are represented by q1, q2, q3, and q4.
- Inputs are represented by a=0 and a=1.
- Outputs are determined by the current state.
- Transitions are defined based on the given state transition table.

Q7. Define DFA.


A Deterministic Finite Automaton (DFA) is a mathematical model for computation consisting of a
finite set of states, a set of input symbols, a transition function, a start state, and a set of
accepting states.
It processes inputs one symbol at a time, transitioning between states according to the
transition function.
It accepts or rejects inputs based on whether the final state is an accepting state.
DFAs are used in various applications, including pattern matching, lexical analysis, and language
recognition.

Q8. How a DFA can be represented mathematically.


A DFA (Deterministic Finite Automaton) is mathematically defined as a 5-tuple (Q, Σ, δ, q0, F),
where:

1. Q is a finite set of states.


2. Σ is a finite set of input symbols (alphabet).
3. δ: Q × Σ → Q is the transition function, mapping a state and an input symbol to a new state.
4. q0 ∈ Q is the start state.
5. F ⊆ Q is a set of accepting states (final states).

This mathematical model captures the essential components of a DFA: its states, input symbols,
transition behavior, initial state, and accepting states, providing a formal representation of its
behavior and structure.

Q9. What is NFA.


An NFA (Nondeterministic Finite Automaton) is a computational model like a DFA but with
non-deterministic transitions.
It can have multiple transitions for the same input symbol from a state.
It accepts input strings if there exists at least one computation path leading to an accepting
state.

NFAs are more expressive than DFAs and are used in pattern matching and lexical analysis.

Q10. How to convert DFA to NFA? Explain with an example.


Converting a DFA (Deterministic Finite Automaton) to an NFA (Nondeterministic Finite
Automaton) involves essentially relaxing the determinism constraint by allowing multiple
transitions for the same input symbol from a state. This conversion is relatively straightforward.

Here's a step-by-step process to convert a DFA to an NFA, illustrated with an example:

Consider the following DFA:

```
DFA:
States: {q0, q1}
Alphabet: {0, 1}
Transition function:
δ(q0, 0) = q1
δ(q0, 1) = q0
δ(q1, 0) = q0
δ(q1, 1) = q1
Start state: q0
Accepting states: {q0}
```

To convert this DFA to an NFA, we can replicate each transition as a single transition in the NFA
and introduce ε-transitions where necessary. Here's how:

1. For each state in the DFA, create the corresponding state in the NFA.
2. For each transition δ(q, a) = p in the DFA, where p is a state and a is an input symbol:
- Add a transition δ'(q, a) = p in the NFA.
3. For each transition δ(q, a) = p in the DFA that is not deterministic (i.e., there are multiple
transitions for the same input symbol a):
- Replace it with ε-transitions in the NFA:
- If there are multiple transitions from q to different states p1, p2, ..., pn, then add
ε-transitions from q to each of these states.
4. Retain the start state and accepting states of the original DFA.

Using the example DFA provided earlier, let's convert it into an NFA:

```
NFA:
States: {q0, q1}
Alphabet: {0, 1}
Transition function:
δ(q0, 0) = {q1, q0} (ε-transition to q1 and q0)
δ(q0, 1) = q0
δ(q1, 0) = q0
δ(q1, 1) = {q1, q0} (ε-transition to q1 and q0)
Start state: q0
Accepting states: {q0}
```

In this NFA:
- There are ε-transitions added where there were non-deterministic transitions in the original
DFA.
- The rest of the transitions remain the same as in the original DFA.
- The start state and accepting states are retained.

This NFA accepts the same language as the original DFA but with non-deterministic transitions.

Q11. What do you understand by Mealy and Moore machine.


A Mealy machine is a type of finite state machine where outputs depend on both the current
state and the input symbol. It consists of a finite set of states, a finite set of input symbols, a
transition function, and an output function. Mealy machines are commonly used in applications
where outputs need to respond quickly to changes in input, such as in communication protocols
and signal processing.
A Moore machine is a type of finite state machine where outputs depend solely on the current
state, independent of the input symbol. It consists of a finite set of states, a finite set of input
symbols, a transition function, and an output function associated with each state. Moore
machines are commonly used in applications where outputs are based solely on the current
state and do not need to respond immediately to input changes, such as in control systems and
digital logic circuits.

Q12. What is a NULL string.


In automata theory, a NULL string (also known as an empty string or ε-string) is a string
containing no symbols. It is denoted by the Greek letter ε. The length of a NULL string is zero.
While it doesn't contain any symbols, it is still considered a valid string in formal language
theory.

In the context of regular expressions and finite automata, the NULL string serves as a
fundamental element for defining concatenation and closure operations. It plays a significant
role in the representation and manipulation of languages and their properties.

Q13. What is reversing a string.


Reversing a string in automata involves constructing an automaton that recognizes the reverse
of a given input string. This operation can be implemented using a finite automaton, which
reads the input string in the reverse order compared to the original string.

The process typically involves creating a new automaton that mirrors the transitions of the
original automaton but reads the input symbols in reverse. For deterministic finite automata
(DFA), the transition function is reversed, while for non-deterministic finite automata (NFA),
epsilon transitions may be used to facilitate the reversal process.

The resulting automaton can then accept or reject strings based on whether the input string's
reverse is recognized, effectively achieving the reversal of the input string within the
automaton's computational framework.

Q14.
Q15. What is a Parse tree.
A parse tree, also known as a syntax tree or derivation tree, is a graphical representation of the
syntactic structure of a string in accordance with the rules of a formal grammar. It illustrates
how the string can be derived by applying production rules of the grammar.

In a parse tree:
- Each node represents either a terminal symbol (i.e., a symbol from the input string) or a
non-terminal symbol (i.e., a symbol from the grammar).
- The root of the tree represents the start symbol of the grammar.
- Internal nodes represent non-terminal symbols, and leaf nodes represent terminal symbols.
- Edges represent the application of production rules, showing how symbols are derived from
other symbols.

Parse trees are commonly used in parsing algorithms, compilers, and language processing tasks
to understand the structure of strings and to ensure they conform to the syntax defined by the
grammar. They provide a hierarchical representation of the syntactic relationships between
elements of a language.

Q16. What are the productions.


Q17. Differentiate between (a,b) and (a+b).

You might also like