Found 349 Articles for Data Structure Algorithms

What are the closure properties for context free language?

Bhanu Priya
Updated on 16-Jun-2021 13:16:00

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

What is a recursive and recursively enumerable language?

Bhanu Priya
Updated on 16-Jun-2021 12:35:43

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

What is Instantaneous Description and Turnstile Notation?

Bhanu Priya
Updated on 16-Jun-2021 12:42:06

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

What is Push down automata in TOC?

Bhanu Priya
Updated on 07-Oct-2023 01:55:41

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

Explain if the CFG is recognized by Non-deterministic push down automata

Bhanu Priya
Updated on 16-Jun-2021 12:43:59

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

Design an unambiguous CFG in CNF that generates E?

Bhanu Priya
Updated on 16-Jun-2021 12:47:00

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

Explain Multi tape Turing Machine in TOC?

Bhanu Priya
Updated on 16-Jun-2021 12:28:56

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

Explain Turing Machine variant Two Stack PDA?

Bhanu Priya
Updated on 16-Jun-2021 12:24:57

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

Explain about a non-deterministic Turing Machine?

Bhanu Priya
Updated on 16-Jun-2021 12:24:20

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

Construct a TM for adding 1 to a binary natural number?

Bhanu Priya
Updated on 16-Jun-2021 12:18:10

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

Previous 1 ... 3 4 5 6 7 ... 35 Next
Advertisements