0% found this document useful (0 votes)
245 views5 pages

Tcs Notes

The document discusses types of grammar including terminal and non-terminal symbols. It also compares Context-Free Normal Form and Greibach Normal Form grammars and differentiates between Finite Automata and Pushdown Automata.

Uploaded by

shaikhshoaib2k21
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)
245 views5 pages

Tcs Notes

The document discusses types of grammar including terminal and non-terminal symbols. It also compares Context-Free Normal Form and Greibach Normal Form grammars and differentiates between Finite Automata and Pushdown Automata.

Uploaded by

shaikhshoaib2k21
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/ 5

a) Explain types of grammar.

Grammar can be defined as, a set of formal rules for


generating syntactically correct sentence from a
particular language for which it is written.
1. Terminal symbols are those which are the constituents
of the generated sentence, which we have generated
using a grammar. For example, in the above example,
'Dog' and 'runs' are terminal symbols.
2. Non-terminal symbols are those which take part in
the formation or generation of the statement, but are
not the part of generated statement like terminal
symbols. For example, 'sentence', 'noun' and 'verb' are
non-terminals in the above example, which are not in
the generated statement as,
< sentence > gives → < noun > < verb >
gives → Dog runs.
b) Compare DFA and NFA.
Difference Table: CNF vs GNF

Feature CNF (Chomsky Normal Form) GNF (Greibach Normal Form)

Non-terminal → Two non-terminals Non-terminal → Terminal followed by


Rule Structure
OR Non-terminal → Terminal any number of non-terminals

Suitable for bottom-up parsing


Parsing Method Ideal for top-down parsing methods
methods

Grammar Can increase the number of Potentially increases the length of


Complexity production rules production rules

Recursion Allows both left and right recursion Eliminates left recursion

Used in many theoretical aspects of Used in practical parser construction,


Use Case
computer science especially for simple languages

Conversion Relatively straightforward conversion


More complex conversion process
Complexity from general CFG
Differentiate FA and PDA

S.NO Pushdown automata finite automata

For Type-2 grammar we can For Type-3 grammar we can


1.
design pushdown automata. design finite automata.

Non – Deterministic pushdown Non-Deterministic Finite


automata has more powerful than Automata has same powers as
2.
Deterministic pushdown in Deterministic Finite
automata. Automata.

Not every Non-Deterministic


Every Non-Deterministic Finite
pushdown automata is
Automata is transformed into
3. transformed into its equivalent
an equivalent Deterministic
Deterministic pushdown Automata
Finite Automata
.

Context free languages can be


Regular languages can be
4. recognized by pushdown
recognized by finite automata.
automata.

Pushdown automata has the Finite Automata doesn’t has


5. additional stack for storing long any space to store input
sequence of alphabets. alphabets.

It gives acceptance of input


It accepts the input alphabets
6. alphabets by going up to empty
by going up to final states.
stack and final states.
Explain types Regular grammer.
1. Right Linear Grammar (RLG): Every production rule has the form
𝐴→𝑥𝐵A→xB or 𝐴→𝑥A→x, where 𝐴A and 𝐵B are non-terminal symbols,
and 𝑥x is a terminal symbol or an empty string.
2. Left Linear Grammar (LLG): Every production rule has the form
𝐴→𝐵𝑥A→Bx or 𝐴→𝑥A→x, where 𝐴A and 𝐵B are non-terminal symbols,
and 𝑥x is a terminal symbol or an empty string.

Define ambigous grammer and its types

An ambiguous grammar is one where a given string in the language can have more
than one parse tree or derivation. In other words, there is more than one way to
derive the same string from the grammar. This ambiguity can lead to confusion in
understanding the language's syntax and semantics.

Types of ambiguous grammars:

1. Syntactic Ambiguity: This occurs when a string in the language can be


derived by more than one parse tree. It arises due to multiple interpretations
of the grammar's production rules.
2. Semantic Ambiguity: Semantic ambiguity arises when a string has multiple
interpretations based on its meaning or context. This type of ambiguity is
more subtle and related to the meaning assigned to the language constructs
rather than just their structure.
Difference between Finite Automata and Turing Machine:

Finite Automata Turing Machine

It will recognize not only regular language but


It recognizes the language called also context-free language, context-sensitive
regular language. language, and recursively enumerable
languages.

In this, the input tape is of finite


In this, the input tape is of finite length from
length from both the left and right
the left but is of infinite length from the right.
sides.

It consists of a finite number of It also contains a finite set of tape symbols and
states, a finite set of input a blank symbol on the tape in addition to a
symbols, an initial state of finite number of states, a finite set of input
automata, and a finite set of symbols, an initial state of automata, and a
transition rules for moving from finite set of transition rules for moving from
one state to another. one state to another.

In this head is able to move in the


right direction only. In two-way
In this, the head can move in both directions.
automata, the head is able to
move in both directions.

The Head is only able to read the


The Head is able to read as well as write
symbols from the tape but can not
symbols on the tape.
write symbols on the tape.

It is weak as compared to Turing


It is more powerful than Finite Automata.
Machine.

Designing turing machine is difficult and as well


Designing finite automata is easier.
as complex.

You might also like