- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 349 Articles for Data Structure Algorithms
4K+ Views
The closure properties for context free language (CFG) are as follows −Closed under Union Operationn order to show that context-free language is closed under union operation, consider two starting variables S1 and S2 for the two different languages L1 and L2.Grammar for union operation is as shown below −S ->S1|S2If both the languages belong to the context free language then union of both the languages should belong to context free language.By the above definition if a user generates S1 and S2 string or both then in that case union of both the language is generated.Hence, L1 U L2 ∈ CFLSo, ... Read More
20K+ Views
Let us understand the concept of recursive language before learning about the recursively enumerable language in the theory of computation (TOC).Recursive LanguageA language L is recursive (decidable) if L is the set of strings accepted by some Turing Machine (TM) that halts on every input.ExampleWhen a Turing machine reaches a final state, it halts. We can also say that a Turing machine M halts when M reaches a state q and a current symbol ‘a’ to be scanned so that δ(q, a) is undefined.There are TMs that never halt on some inputs in any one of these ways, So we ... Read More
761 Views
The instantaneous description (ID) of a push down automata (PDA) is represented by a triple (q, w, s)Where, q is the state.w is unconsumed input.s is the stack contents.ID is an informal notation of how a PDA compares an input string and makes a decision that string is accepted or rejected.Turnstile NotationIt is used for connecting pairs of ID's that represent one or more moves of a PDA.The process of transition is denoted by the turnstile symbol "⊢"⊢ it represents one move.⊢ sign describes a sequence of moves.Example(P, b, T) ⊢ (q, w, a)While taking a transition from P to ... Read More
26K+ Views
A push down automata (PDA) is a way to implement a context free grammar (CFG) in a similar way to design the deterministic finite automata (DFA) for a regular grammar. A DFA can remember a finite amount of information but a PDA can remember an infinite amount of information. Basically, a PDA is as follows − "Finite state machine+ a stack" PDA has three components, which are as follows − An input tape. A control unit. A stack with infinite size. A PDA may or may not read input symbols, but it ... Read More
392 Views
Context Free Grammars (CFG) are definitely recognized by Non-deterministic push down automata (NPDA), but Programming languages are translated to binary (Machine Code) via Deterministic PDA.This is because it has the following below mentioned impacts −If Programming languages were supposed to be translated via NPDA then for one given program instance we will have multiple versions of binary(Machine code) generated for the same program, which ideally shouldn't be the scenario.For a given program only 1 version of binary code should be generated and that should remain consistent across all OS Platforms.Outputs will vary significantly: If we have multiple object files, then ... Read More
163 Views
ProblemDefine the language, E={aibj|i not equal to j and i not equal to 2j} and design an unambiguous context free grammar (CFG) in Chomsky normal form (CNF) that generates E.SolutionThe unambiguous CFG for the given language is as follows −S->AC|CBA->aA|aB->Bb|bC->aCb|aaCb|epsilonNow, convert this CFG into CNF. You can follow the below mentioned steps for the successful conversion.Step 1First add a new start symbol S0 S0->S S->AC|CB A->aA|a B->Bb|b C->aCb|aaCb|epsilonStep 2Next eliminate the epsilon symbol in the production other than the start symbol. C->epsilon is a null productionAfter eliminating null production, the new productions are as follows − S0->S S->AC|CB A->aA|a B->Bb|b ... Read More
3K+ Views
A Turing machine (TM) with several tapes is called a multi tape Turing machine.Every tape’s have their own Read/Write headFor N-tape Turing MachineM={( Q, X, ∑, δ, q0, B, F)}We define Multi-tape Turing machine as k-tapes with k-tape heads moving independently (generalisation of multi-track Turing machines).δ=QxXN ->Q x XN x {L, R}NEach TM has its own read-write head, but the state is common for all. The multi tape TM is as follows −In each step (transitions), TM reads symbols scanned by all heads, depending on those and current state, each head writes, moves R or L, and control-unit enters into ... Read More
10K+ Views
Two stacks push down automata (PDA) includes the following factors −A Turing machine can accept languages that are not accepted by any PDA with one stack.The strength of pushdown automata is increased by adding extra stacks.A PDA with two stacks has the same computation power as for a Turing Machine.Two-Stack PDA is a computational model which is based on the generalization of Pushdown Automata (PDA) and Non-deterministic Two-Stack PDA which is equivalent to a deterministic Two-Stack PDA.The moves of the Two-Stack PDA are based on the following −The state of finite control.The input symbol that reads.The top of the stack ... Read More
1K+ Views
Non-determinism like in PDA (partially NFA) for one input configuration has several possible outputs.The non-deterministic TM is like TM but with a finite number of choices of moves; may have more than 1 move with the same input “current state & current symbol”.The non-deterministic TM accepts the input w if there is at least one computation that halts normally for the input w.Non-determinism is more powerful than determinism for pushdown automata. But it makes no difference for finite automata.Quite surprisingly, the deterministic and non-deterministic Turing machines are the same in power.Note:If a nondeterministic Turing machine accepts a language L, then ... Read More
472 Views
A Turing machine (TM) can be formally described as seven tuples −(Q, X, ∑, δ, q0, B, F)Where, Q is a finite set of states.X is the tape alphabet.∑ is the input alphabet.δ is a transition function: δ:QxX->QxXx{left shift, right shift}.q0 is the initial state.B is the blank symbol.F is the final state.Binary numbers1 = 12 = 103 = 114 = 1005 = 1016 = 110. . .AlgorithmStep 1 − Move to the right end of the string.Step 2 − Repeat:If the current cell contains 1, write 0 and move left until the current cell contains 0 or blank.Step 3 ... Read More