Found 691 Articles for Computer Science

Design a TM for an equal number of a’s and b’s must follow a

Bhanu Priya
Updated on 10-Mar-2022 09:47:49

3K+ Views

The Turing machine (TM) is more powerful than both finite automata (FA) and pushdown automata (PDA). They are as powerful as any computer we have ever built.Formal Definition of Turing MachineA Turing machine can be formally described as seven tuples(Q, X, Σ, δ, q0, B, F)Where, Q is a finite set of statesX is the tape alphabetΣ is the input alphabetδ is a transition function: 𝛿:QxX→QxXx{left shift, right shift}q0 is the initial stateB is the blank symbolF is the final state.A Turing Machine (TM) is a mathematical model which consists of an infinite length tape divided into cells on which ... Read More

C program for DFA accepting all strings over w ∈(a,b)* containing “aba” as a substring

Bhanu Priya
Updated on 14-Jun-2021 15:32:55

2K+ Views

ProblemDesign a DFA for the language L={w1abaw2 | w1, w2 Є(a, b)*}, which means the DFA accepts all strings which contain “aba” as a substring.SolutionThe strings that are accepted by language L= {aba, aabaa, aabab, babab, ababa, …….}Step 1 − Transition diagram for minimal string (starting string) −If w1 and w2 are null then the string it generates is “aba” because w1, w2 ε(a, b)*q0 is the initial state and q3 is the final state.Step 2 − The final DFA for the given language is as follows −Explanationqo is the initial state q0 on ‘a’ goes to q1 and on ... Read More

Construct ∈-NFA of Regular Language L = b + ba*

Bhanu Priya
Updated on 14-Jun-2021 15:28:02

4K+ Views

The ε transitions in Non-deterministic finite automata (NFA) are used to move from one state to another without having any symbol from the input set Σ.ε-NFA is defined in 5 tuples representation{Q, q0, Σ, δ, F}Where, δ − Q × (Σ∪ε)→2QQ − Finite set of states∑ − Finite set of the input symbolq0 − Initial stateF − Final stateδ − Transition functionNFA without ε transitionNFA is defined in 5 tuples representation{Q, q0, Σ, δ, F}Where, δ − Q X Σ→ 2QQ − Finite set of states∑ − Finite set of the input symbolq0 − Initial stateF − Final stateδ − ... Read More

Construct ∈-NFA of Regular Language L = (0+1)*(00+ 11)

Bhanu Priya
Updated on 14-Jun-2021 15:24:11

13K+ Views

The ε transitions in Non-deterministic finite automata (NFA) are used to move from one state to another without having any symbol from input set Σε-NFA is defined in five tuple{Q, q0, Σ, δ, F}Where, δ − Q × (Σ∪ε)→2QQ − Finite set of statesΣ − Finite set of the input symbolq0 − Initial stateF − Final stateδ − Transition functionNFA without ε transitionNFA is defined in 5 tuple representation{Q, q0, Σ, δ, F}Where, δ − Q X Σ→ 2QQ − Finite set of statesΣ, − Finite set of the input symbolq0 − Initial stateF − Final stateδ − Transition functionNFA ... Read More

C Program to construct a DFA which accepts L = {aN | N ≥ 1}

Bhanu Priya
Updated on 14-Jun-2021 15:19:30

551 Views

Let us take a string S of size N, we have to design a Deterministic Finite Automata (DFA) for accepting the language L = {aN | N ≥ 1}.The string accepting the language L is {a, aa, aaa, aaaaaaa…, }.Now the user has to enter a string, if that string is present in the given language, then print “entered string is Accepted”. Otherwise, print “entered string is not Accepted”.DFA transition diagram for the given language is −ExampleFollowing is the C program to construct DFA which accepts the language L = {aN | N ≥ 1} −#include int main() {    char S[30]; ... Read More

Construct ∈-NFA of Regular Language L = 0(0+1)*1

Bhanu Priya
Updated on 14-Jun-2021 15:12:58

6K+ Views

The ∈ transitions in Non-deterministic finite automata (NFA) are used to move from one state to another without having any symbol from input set Σ∈-NFA is defined in five tuple representation{Q, q0, Σ, δ, F}Where, δ − Q × (Σ∪∈)->2QQ − Finite set of statesΣ − Finite set of the input symbolq0 − Initial stateF − Final stateδ: Transition functionNFA without ε transitionNFA also has five states same as DFA, but with different transition function, as shown follows −$$\delta\colon\:Q\times\:\sum\longrightarrow\:2^{Q}$$Where, Q − Finite set of statesΣ − Finite set of the input symbolq0 − Initial stateF − Final stateδ − Transition ... Read More

Explain the concept of grammar in TOC

Bhanu Priya
Updated on 01-Nov-2023 14:55:22

35K+ Views

Grammar in theory of computation is a finite set of formal rules that are generating syntactically correct sentences.The formal definition of grammar is that it is defined as four tuples −G=(V, T, P, S)G is a grammar, which consists of a set of production rules. It is used to generate the strings of a language.T is the final set of terminal symbols. It is denoted by lower case letters.V is the final set of non-terminal symbols. It is denoted by capital letters.P is a set of production rules, which is used for replacing non-terminal symbols (on the left side of ... Read More

C Program to construct DFA for Regular Expression (a+aa*b)*

Bhanu Priya
Updated on 14-Jun-2021 14:58:10

11K+ Views

Design a Deterministic Finite Automata (DFA) for accepting the language L = (a+aa*b)* If the given string is accepted by DFA, then print “string is accepted”. Otherwise, print “string is rejected”.Example 1Input: Enter Input String       aaaba Output: String Accepted.Explanation − The given string is of the form (a+aa*b)* as the first character is a and it is followed by a or ab.Example 2Input: Enter Input String baabaab Output: String not Accepted.The DFA for the given regular expression (a+aa*b) is −Explanation −If the first character is always a, then traverse the remaining string and check ... Read More

How to convert left linear grammar to right linear grammar?

Bhanu Priya
Updated on 14-Jun-2021 14:55:02

7K+ Views

Regular grammar describes a regular language. It consists of four components, which are as follows −G = (N, E, P, S)Where, N: finite set of non-terminal symbols, E: a finite set of terminal symbols, P: a set of production rules, each of one is in the formsS → aBS → aS → ∈, S ∈ N is the start symbol.The above grammar can be of two forms −Right Linear Regular GrammarLeft Linear Regular GrammarNow, let us see the steps to convert left linear grammar to right linear grammar −Example 1Consider a left linear grammar as given below −S→ Sa|Abc A→ ... Read More

How to convert right linear grammar to left linear grammar?

Bhanu Priya
Updated on 14-Jun-2021 14:51:40

4K+ Views

For every finite automata (FA) there exists a regular grammar and for every regular grammar there is a left linear and right linear regular grammar.Example 1Consider a regular grammar −   a(a+b)* A → aB B → aB|bB|eFor the given regular expression, the above grammar is right linear grammar.Now, convert the above right linear grammar to left linear grammar.The rule to follow for conversion is, Finite Automata → Right linearThe reverse of right linear →left linear grammar.So, A → BaB → Ba|Bb|eFinally for every right linear there is aExampleConsider a language {bnabma| n>=2, m>=2}The right linear grammar for the given language ... Read More

Advertisements