TOC
Created by | Borhan |
---|---|
Last edited time | |
Tag |
- What do you mean by theory of computation ? Discuss about it's branches ?
- The theory of computation is a field of computer science that deals with the study of algorithms, formal languages, automata, and computational complexity. It seeks to understand the fundamental capabilities and limitations of computational systems and machines.
- Automata Theory:
- Automata are abstract models that describe the behavior of computational systems. They can be used to analyze the capabilities of different machines and determine the types of languages they can recognize.
- Finite Automata (FA), Pushdown Automata (PDA), and Turing Machines (TM) are common models studied in automata theory.
- Computability Theory:
- Computability theory explores the boundaries of what can be computed. It investigates the notion of an effective method or algorithm and studies the concept of undecidability.
- Turing's halting problem is a famous example of an undecidable problem.
- Complexity Theory:
- Complexity theory focuses on the resources required to solve computational problems, such as time and space. It classifies problems based on their inherent difficulty and studies the relationship between different classes of problems.
- Classes like P (polynomial time), NP (nondeterministic polynomial time), and NP-complete are central to complexity theory.
- Difference between theory, lemma and coronary
Theory Lemma Coronary A mathematical statement based on previously established statement A minor result to prove another theorem A result in which the proof relies heavily An example of a theory is Albert Einstein's general relativity theory, which describes the law of gravitation and its relationship to other natural forces. .. ..
- Proof by counterexample
- Proof by counterexample is a method of mathematical or logical reasoning used to demonstrate that a given statement or conjecture is false. It involves providing a specific example that contradicts the statement being claimed, thus disproving its general validity.
- Difference between more and mealy machine with example
Moore Machine | Mealy Machine |
---|---|
Output depends only upon the present state. | Output depends on the present state as well as present input. |
Output is placed on states. | Output is placed on transitions. |
Easy to design. | It is difficult to design. |
If input changes, output does not change | If input changes, output also changes. |
More states are required. | Less number of states are required. |
- What do you mean by epsilon-closure ?
- Epsilon closure refers to the set of all states that can be reached from a given state in a non-deterministic finite automaton (NFA) by following epsilon transitions (transitions that do not consume any input symbol).
- What are the uses of epsilon-transition?
- Non-determinism: Epsilon-transitions are a key feature of non-deterministic finite automata (NFA). They allow the automaton to move from one state to another without consuming any input symbol.
- Epsilon-closure: Epsilon-transitions are used to compute the epsilon-closure of a state in an NFA.
- Conversion from NFA to DFA: Epsilon-transitions are utilized in the conversion process from an NFA to a deterministic finite automaton (DFA).
- Regular expression construction: Epsilon-transitions are employed in constructing regular expressions from NFAs.
- Language recognition and parsing: Epsilon-transitions play a role in determining whether a given string is accepted by an automaton or not.
- What is regular expression?
- In the theory of computation, a regular expression is a formal notation that represents a regular language. It is an algebraic-like expression that describes a set of strings or a pattern of characters. Regular expressions are used to define and recognize regular languages in the context of formal language theory.
- The set of strings over alphabet {0, 1} that consists equal number of 0's and I's such that no prefix has two more 0's than 1's, nor two more I's than 0's.
- (01+10)*
- The set of strings over alphabet (a, b, c) containing at least one a and at least one b.
// ***a**b*** + ****b***a**** R1 = (a+b+c)* a(a+b+c)* b(a+b+c)* R2 = (a+b+c)* b(a+b+c)* a(a+b+c)* RE for the given question R = R1+R2 R = (a+b+c)* a(a+b+c)* b(a+b+c)* + (a+b+c)* b(a+b+c)* a(a+b+c)*
- Regular set of
-
- No two adjacent one
- Regular set of
-
- No adjacent aa, cc, ac
- Define Arden's theorem.
- If P and Q are two regular expressions over Ʃ and if P does not contain ε then the following equation in R given by R=Q+RP has a unique solution i.e., R=QP*.
- Show the RE for the following DFA using state-elimination technique:


Using Arden’s theorem:

- Why pumping lemma is required? Write down the properties of pumping lemma.
- The pumping lemma is a tool used in formal language theory to prove a language not a regular.
- For any regular language L, there exists an integer P, such that for all w in L
|w|>=P
We can break w into three strings, w=xyz such that.
(1)lxyl < P
(2)lyl > 1
(3)for all k>= 0: the string is also in L
- Differentiate between ambiguity and inherent ambiguity with examples
Removable ambiguity | inherent ambiguity |
---|---|
It can be removed | It’s not |
This refers to ambiguity which is present in a grammar and we can remove it by writing another grammar that is unambiguous produces the same language | This is the situation when every grammar that generates a given language, say L is ambiguous we say the language is inherently ambiguous |
. E --> E + E | E * E | id | L = {a^m b^m c^n | m,n >= 0} U {a^m b^n c^n | m,n >= 0} |
- Consider the following grammar and show a derivation tree for the string a + b * c:
- Derivation tree is a graphical representation for the derivation of the given production rules for a given CFG

- Show how to eliminate ambiguity from the grammar.
- We can use Precedence and Associativity to remove the ambiguity from some grammar.
How
= First level of Precedence
Second level of Precedence
Generating Basic Units/Terminal
- Simply make the grammar Left Recursive by replacing the left most non-terminal
-
- The unambiguous grammar will contain the productions having the highest priority operator (“*” in the example) at the lower level and vice versa. The associativity of both the operators are Left to Right.
- Simply make the grammar Left Recursive by replacing the left most non-terminal
- We can use Precedence and Associativity to remove the ambiguity from some grammar.





- Since S is in right side we have to add S' -> S :
- Removing Null Pointer : There's no null pointer
- Remove Unit Production:
After removing S' -> S :
- Removing Useless symbol
- Replacing the productions that has more than two variables in RHS
- Change in Production where terminal is left of variable where P → qA
- What is Turing machine ? Describe formal notation of Turing machine?
- A Turing machine is an computational model like FA, PDA which works on unrestricted grammar.
Formal Notations:
Q = Non-empty set of states
X = set of tape Alphabets
= Input states
= Transition function
= Starting state
B = Blank Symbol
F = Final State
- A Turing machine is an computational model like FA, PDA which works on unrestricted grammar.
- Fermat’s Last Theorem
- Fermat's last theorem, also called Fermat's great theorem, the statement that there are no natural numbers (1, 2, 3,…) x, y, and z such that , in which is a natural number greater than 2.
- Fermat’s Little Theorem states that if p is a prime number, then for any integer a, the number a p – a is an integer multiple of p.
- Design a Turing machine that takes a input as Number and adds 1’s to it binary.
- Partial Recursive Function
- A function which is not defined for some inputs of the right type, that is, for some of a domain. For instance, division is a partial function since division by 0 is undefined (on the Reals).
- A partial function is called partial recursive if it can be computed by a Turing machine; that is, if there exists a Turing machine that accepts input x exactly when f(x) is defined, in which case it leaves the string f(x) on its tape upon acceptance.
By Church's thesis, a function is recursive if and only if it is computable.
- Partial Recursive Function
- Define extended transition function.
- An extended transition function traces the path of an automaton and determines the final state when an initial state q and an input string x are passed through it.
Steps of the recursive algorithm to solve
- Base Condition
- Recursive Solution
- Base Condition
- An extended transition function traces the path of an automaton and determines the final state when an initial state q and an input string x are passed through it.
- Describe briefly about the operators of regular expression
- Union: If R1 and R2 are regular expression then R1 | R2 (R1 U R2 or R1 + R2) is also.
- L(R1|R2) = L(R1) U L(R2).
- Concatenation: If R1 and R2 are regular expression then R1R2 is also.
- L(R1R2) = L(R1) concatenated with L(R2).
- Kleene closure : If R1 is regular expression then R1* is also.
- L(R1*) = epsilon U L(R1) U L(R1R1) U L(R1R1R1) U ...
- Union: If R1 and R2 are regular expression then R1 | R2 (R1 U R2 or R1 + R2) is also.
Closure has the highest precedence, followed by concatenation, followed by union.
- When a symbol is useful for a grammar ? Explain.
A symbol can be useful if it appears on the right-hand side of the production rule and takes part in the derivation of any string/reachable from start
T → aaB | abA | aaT A → aA B → ab | b C → ad Where T,A,B is useful but C not.
- How to draw a Parse tree. Explain.
- A parse tree is a graphical representation of how the symbols in a sentence can be derived from the non-terminal symbols of a grammar
- Steps:
- Start with the start symbol as root
- Apply Production rule from the root
- Continue expanding production rule recursively until all leaf nodes are terminals
- Finalize the parse tree
Example: S -> sAB A -> a B -> b
- Rijk Method
- K==0

- K ≠ 0
- Define language in automata with example
- A language is a subset of for some alphabet .
- Example : The possible language for length 2,
- Prove that, is not a regular language.
Concept:
- Pumping lemma is used to prove a language not regular.
- Theorem : If A is a regular language has a pumping length ‘P’ such that any string S where maybe divided into three parts that the following condition must be true
-
-
- , for every
Prove:
- Theorem : If A is a regular language has a pumping length ‘P’ such that any string S where maybe divided into three parts that the following condition must be true
- Pumping lemma is used to prove a language not regular.
- What are the strategies for constructing a regular expression from a finite automation using state-elimination method. Explain
Steps:
- If there exists any incoming edge to the initial state, then create a new initial state having no incoming edge to it
- If there exists multiple final states in the DFA, then convert all the final states into non-final states and create a new single final state
- If there exists any outgoing edge from the final state, then create a new final state having no outgoing edge
- After following the above rules we can eliminate all intermediate state one by one.
- Describe formal notation of pushdown automata.
Pushdown Automata is a finite automata with extra memory called stack which helps Pushdown automata to recognize Context Free Languages.
A PDA can be formally described by 7-tuples.
: Non-empty set of states
: Nonempty set of input symbols
: Nonempty set of pushdown symbols
: Transition function
: Initial State
: Initial Symbol on the pushdown store/stack
Final State
- Design a PDA language to accept a language

The transitions on state are self-loop
- Define Chomsky Normal Form(CNF)
A grammar where every production is either of the form A → BC or A → c (where A, B, C are arbitrary variables and c an arbitrary symbol).
A CFG is in CNF if all production rules satisfy following conditions
- Start symbol symbol generating ε
- A non-terminal generating at most two non-terminals
- A non terminal generating a terminal


- What is transition Diagram ?
Transition diagram can be interpreted as a flowchart for an algorithm recognizing a language.
Which is constructed by
- There is a node for each state in Q, represented by the circle
- There is a directed edge from a node p to node q labeled if
- Starting state, there is an arrow with no source
- Final states indicating by a double circle
- Write down the application of Context Free Grammar
- Context Free Grammar is a formal grammar which is used to generate all possible strings in a given formal language.
- Applications:
- Used in compilers (Such GCC) parsing
- define the syntax of programming languages
- Used to define the high level structure of a programming language
- Natural Language Processing (NLP)
- Draw a PDA for the language

- Define the language of a grammar
Language of a grammar is the set of all strings that can be generated by that grammar.

Useful symbols
is Useless.
Grammar :
Eliminating :
Eliminating & (Unit Production):

Leftmost Derivation
S →
(Rule 1)
(Rule 2)
(Rule 1)
(Rule 2)
Rightmost Derivation
(Rule 1)
(Rule 2)
(Rule 2)
(Rule 1)
Parse tree


Leftmost derivation



- Instantaneous Description (ID)
Instantaneous Description (ID) is an informal notation of how a PDA “computes” a input string and make a decision that string is accepted or rejected.


Type of Complexity Classes
- P : that can be solved by a deterministic machine in polynomial time.
- NP: can be solved by a non-deterministic machine in polynomial time
- NP-hard: An NP-hard problem is at least as hard as the hardest problem in NP and it is a class of problems such that every problem in NP reduces to NP-hard.
- NP-Complete: A problem is NP-complete if it is both NP and NP-hard.
DFA | NFA |
---|---|
DFA stands for Deterministic Finite Automata. | NFA stands for Nondeterministic Finite Automata. |
For each symbolic representation of the alphabet, there is only one state transition in DFA. | No need to specify how does the NFA react according to some symbol. |
DFA cannot use Empty String transition. | NFA can use Empty String transition. |
DFA can be understood as one machine. | NFA can be understood as multiple little machines computing at the same time. |
In DFA, the next possible state is distinctly set. | In NFA, each pair of state and input symbol can have many possible next states. |
DFA is more difficult to construct. | NFA is easier to construct. |
DFA requires more space. | Less |
All DFA are NFA. | Not all NFA are DFA. |
δ: QxΣ -> Q | δ: Qx(Σ U ε) -> 2^Q |
Epsilon move is not allowed in DFA | Epsilon move is allowed in NFA |