Found 690 Articles for Computer Science

Construct a DFA recognizing the language {x | the number of 1's is divisible by 2, and 0'sby 3} over an alphabet ∑={0,1}

Bhanu Priya
Updated on 15-Jun-2021 12:20:23

4K+ Views

ProblemThe given language L={ x | the number of 1's is divisible by 2, and 0's by 3} over an alphabet ∑={0, 1}.SolutionThe language is divided into two parts, first we need to find the number of 1’s divisible by 2 and second find out the number of 0’s divisible by 3, finally combine the two parts to generate a result.Step 1 − DFA for the first part, number of 1’s divisible by 2.Here, q0 on 0 goes to q0 which is a final state, and generates a string 0, accepted by the given language.q0 on 1 goes to q1, ... Read More

What is a Queue Automaton?

Bhanu Priya
Updated on 15-Jun-2021 12:17:12

414 Views

A queue automaton is like a push-down automaton (PDA) except that the stack is replaced by a queue.A queue is a tape allowing symbols to be written only on the left-hand end and read only at the right-hand end.Each write operation (we’ll call it a push) adds a symbol to the left-hand end of the queue and each read operation (we’ll call it a pull) reads and removes a symbol at the right-hand end.As with a PDA, the input is placed on a separate read-only input tape, and the head on the input tape can move only from left to ... Read More

Differentiate between Ambiguous and Unambiguous Grammar

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

6K+ Views

Before understanding the differences between ambiguous grammar and unambiguous grammar, let us learn about these concepts.Ambiguous GrammarA grammar is said to be ambiguous if there exists more than one left most derivation or more than one right most derivation or more than one parse tree for a given input string.If the grammar is not ambiguous then we call unambiguous grammarIf the grammar has ambiguity then it is good for compiler constructionNo method can automatically detect and remove the ambiguity, but we can remove the ambiguity by re-writing the whole grammar without ambiguity.ExampleLet us consider a grammar with production rules −E=I ... Read More

Construct DFA of alternate 0’s and 1’s

Bhanu Priya
Updated on 15-Jun-2021 12:13:10

2K+ Views

ProblemConstruct deterministic Finite automata (DFA) whose language consists of strings with alternate 0’s and 1’s over an alphabet ∑ ={0, 1}.SolutionIf Σ = {0, 1} (ε + 1)(01)* (ε + 0) is the set of strings that alternate 0’s and 1’s Another expression for the same language is (01)*+ 1(01)*+ (01)*0+ 1(01)*0.The strings the given language generates are as follows −If no input is either 0 or 1 then it generates {ε} .String starts with 0 and followed by 1 = {0101…}.String starts with 1 followed by 0 ={101010….. }So, based on string generation it is clear the strings are ... Read More

Construct a TM performing multiplication of two unary numbers

Bhanu Priya
Updated on 15-Jun-2021 12:11:27

6K+ Views

AlgorithmStep 1 - Read the leftmost ‘0’ replace it by ‘x’ and move right to process the immediate symbol after ‘#’.Step 2 - Replace the symbol ‘0’ by x and move right reach the first ‘B’ after ‘#’Step 3 - Replace B by ‘0’ and move left until the nearest ‘x’ is reachedStep 4 - Replace the ‘x’ by 0 and move right to process the next symbol of the multiplicand.Step 5 - Perform steps 2, 3 and 4 until all the symbols of the multiplicand are processed.Step 6 - Move left to replace the symbol of the multiplier, ‘x’ ... Read More

Design a TM to compute addition of two unary numbers

Bhanu Priya
Updated on 15-Jun-2021 12:08:55

7K+ Views

The unary input number n is represented with a symbol 0 n – times.Example4 → 00001 → 05 → 00000The separation symbol, „#‟ (any other special character) shall be used to distinguish between two or more inputs.For Example: 5, 2 are the inputs represented by 00000 # 00.AlgorithmStep 1 - Read the symbols of the first input with no replacements and move right.Step 2 - When the symbol = ‘#’, replace it by ‘0’ and move right.Step 3  - Traverse right side until the rightmost ‘0’ (left to B – last symbol)Step 4 - Replace the rightmost ‘0’ by BStep ... Read More

Distinguish between Finite Automata and Turing Machine

Bhanu Priya
Updated on 15-Jun-2021 12:06:32

5K+ Views

Before understanding the differences between the finite automata (FA) and the turing machine (TM), let us learn about these concepts.Finite AutomataFinite automata is an abstract computing deviceIt is a mathematical model of a system with discrete inputs, outputs, states and set of transitions from state to state that occurs on input symbol from alphabet ΣFinite Automata RepresentationFA can be represented as following in the theory of computation (TOC) −Graphical (Transition diagram)Tabular (Transition table)Mathematical (Transition function)Formal definition of Finite AutomataA Finite automata is a five tuplesM=(Q, Σ, δ, q0, F)Where, Q − Finite set called statesΣ − Finite set called alphabetsδ ... Read More

C Program to build DFA accepting the languages ending with “01”

Bhanu Priya
Updated on 15-Jun-2021 12:03:41

12K+ Views

ProblemDesign deterministic finite automata (DFA) with ∑ = {0, 1} that accepts the languages ending with “01” over the characters {0, 1}.SolutionThe strings that are generated for a given language are as follows −L={01, 001, 101, 110001, 1001, ……….}The minimum length of the string is 2, the number of states that the DFA consists of for the given language is: 2+1 = 3 states.Here, q0 − On input 0 it goes to state q1 and on input 1 it goes to itself.q1 − On input 0 it goes to itself and on input 1 it goes to State q2.q2 − ... Read More

Explain about regular expressions in TOC?

Bhanu Priya
Updated on 15-Jun-2021 12:43:52

17K+ Views

A regular expression is basically a shorthand way of showing how a regular language is built from the base set of regular languages.The symbols are identical which are used to construct the languages, and any given expression that has a language closely associated with it.For each regular expression E, there is a regular language L(E).Example 1If the regular expression is as follows −a + b · a*It can be written in fully parenthesized form as follows −(a + (b · (a*)))Regular expressions vs. LanguagesThe symbols of the regular expressions are distinct from those of the languages. These symbols are given ... Read More

Design a TM which recognizes palindromes over = {a, b}

Bhanu Priya
Updated on 15-Jun-2021 12:00:34

18K+ Views

AlgorithmStep 1 - If there is no input, reach the final state and halt.Step 2 - If the input = “a‟, then traverse forward to process the last symbol = “a‟. Convert both a‟s to B‟.Step 3 - Move left to read the next symbol.Step 4 - If the input = “b‟, replace it by B and move right to process its equivalent “B‟ at the rightmost end.Step 5 - Convert the last ’b’ to ‘B’.Step 6 - Move left and process step 2 – 5 until there are no more inputs to process.Step 7 - If the machine reaches ... Read More

Advertisements