
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1163 Articles for Computers

3K+ Views
ProblemConstruct a deterministic finite automata (DFA) that accepts a language L which has the number of zero’s is of multiple of 3 over an alphabet ∑=”{0,1}.SolutionIf input is: 000 Output is: string is acceptedBecause here the number of zero’s is multiple of 3.Designing DFAIn order to construct the DFA, follow the below mentioned steps −Step 1 -Valid inputs: 000, 000000, 09 , 012 , …Step 2 -Valid inputs: 1, 1000, 100000, …Step 3 -Valid inputs: 10100, 11000, 101100, …Step 4 -101010, 1101010, 1101110110, …Invalid inputs − 0,00,10000,01011, …

1K+ Views
ProblemGiven language to construct the deterministic finite automata (DFA) is, the strings start with ‘a’ but not contain substring ‘aab’ over alphabet ∑={a,b}.SolutionIf the input is: “baabba”The output is: string is not acceptedBecause the string does not start with ‘a’, and generating a substring ‘abb’,DFA transition diagramThe DFA transition diagram for the string beginning with ‘a’ but not having the substring as ‘aab’ is as follows −Transition tableThe transition table is as follows −STATEINPUT (a)INPUT (b)→ 01*4 (dead state)1*2*3*2*2*4 (dead state)3*1*3*4 (dead state)4 (dead state)4 (dead State)

2K+ Views
Vertex cover is a subset of vertices that covers all the edges in a graph. It is used to determine whether a given graph has a 3SAT to vertex cover.Clique is called a subset of vertices that are all directly connected. It determines whether a clique of size k exists in a graph.To prove − Vertex cover can be reduced to clique.ProofGiven a graph G=(V, E) and integer k.Get its complement graph G'=(V, E').Solve CLIQUE(G', |V|-k).If there is a solution, return yes. Otherwise, it returns as no.To prove this reduction, we need to show the following −If there is a ... Read More

5K+ 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

8K+ 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

4K+ 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

10K+ 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

11K+ 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

6K+ 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

17K+ 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