Construct PDA for L = 0^n 1^m 2^(n+m-1)

Bhanu Priya
Updated on 15-Jun-2021 15:03:33

3K+ Views

A push down automata (PDA) can be formally described as seven tuples(Q, Σ, S, δ, q0, I, F)Where, Q is finite number of statesΣ is input alphabetS is stack symbolΔ is the transition function: QX(Σ∪{e})XSXQq0 is the initial state (q0 belongs to Q)I is the initial state top symbolF is a set of accepting states(F belongs to Q)ProblemConstruct PDA for 0n1m2(n+m) where n, m>=1.SolutionSo, the strings which are generated by the given language are as follows −L={0122, 001222, 000112222, ….}That is to add the number of 0's and 1's, and that will equal the number of 2's.So for every 0's ... Read More

Construct a PDA for Language L = 0^n 1^m 2^m 3^n, n ≥ 1, m ≥ 1

Bhanu Priya
Updated on 15-Jun-2021 15:01:45

8K+ Views

A push down automata (PDA) can be formally described as seven tuples(Q, Σ, S, δ, q0, I, F)Where, Q is finite number of statesΣ is input alphabetS is stack symbolΔ is the transition function: QX(Σ∪{e})XSXQq0 is the initial state (q0 belongs to Q)I is the initial state top symbolF is a set of accepting states(F belongs to Q)ProblemConstruct PDA for 0n1m2m3n where n, m≥1.SolutionSo, the strings which are generated by the given language are −L={0123, 011223, 001233….}The number of 1’s and 3’s are same and number of 2’s and 1’s are sameConstruction of PDA for given problemThe PDA is as ... Read More

Construct DPDA for a N+M BMCN (n-m-1) in TOC

Bhanu Priya
Updated on 15-Jun-2021 15:00:03

1K+ Views

A push down automata (PDA) can be formally described as seven tuples(Q, Σ, S, δ, q0, I, F)Where, Q is finite number of statesΣ is input alphabetS is stack symbolΔ is the transition function: QX(Σ∪{e})XSXQq0 is the initial state (q0 belongs to Q)I is the initial state top symbolF is a set of accepting statesProblemConstruct PDA for a(n+m)bmcn n, m≥1.SolutionSo, the strings which are generated by the given language are −L={aabc, aaaabccc, aaaaabbccc, ….}That is to add the number of b's and c's, and that will equal the number of a's.For every b's and c's we will pop a's from ... Read More

Basic Properties of the Turing Machine

Bhanu Priya
Updated on 15-Jun-2021 14:22:10

3K+ Views

Turing machines are more powerful than both finite automata (FA) and pushdown automata (PDA). They are as powerful as any computer we have ever built.The main improvements from PDAs in Turing machine are explained below −Infinite “all” accessible memory (in the form of a tape) – option to read and write to it.A read/write head can move to the left and to the right on the input tape (or don’t change a position).The TM works on an infinite tape divided into cells (infinite in both directions), each of which contains either a symbol from an alphabet or the blank symbol. ... Read More

Distinguish Between DPDA and NPDA in TOC

Bhanu Priya
Updated on 15-Jun-2021 14:18:46

6K+ Views

Similar to the finite automata (FA), push-down automata (PDA) can be either deterministic or non-deterministic.A deterministic push down automata (DPDA) never has a choice of the next step −It has the possible output for every combination of state, input character and stack character, as compared to the deterministic finite automata (DFA).We need to be careful about every combination of state and stack character. Only one of the transactions is allowed either for the empty symbol ∧ or for an input symbol. Or there can be no transaction at all.ExampleA non-deterministic push-down automaton (NPDA) can contain the following instructions, but a ... Read More

Design a Push Down Automaton for L = { wwR | w ∈ a,b+ }

Bhanu Priya
Updated on 15-Jun-2021 13:40:41

9K+ Views

A pushdown automaton is used to implement a context-free grammar in the same way that we use a technique to design DFA for a regular grammar. A DFA work on a finite amount of information, where as a PDA works on an infinite amount of information.Generally, a pushdown automaton is −"Finite state machine" + "a stack"A pushdown automaton consist of three components −an input tape, a control unit, anda stack with infinite size.Now consider a problem that how to design push down automata for a given language −ProblemDesign a push down automaton which recognizes even length palindromes for L = ... Read More

String Acceptance and Rejection by NPDA

Bhanu Priya
Updated on 15-Jun-2021 13:25:44

393 Views

A string is accepted by an Non-deterministic Push down Automata (NPDA), if there is some path (i.e., sequence of instructions) from the start state to a final state that consumes all the letters of the string. Otherwise, the string is rejected by the NPDA.The language of an NPDA is the set of all strings that it accepts.An input string rejected by the NPDA under following conditions −If reading an input string finishes without reaching a final state.If for a current state/symbol on the stack/input symbol there is no transition.If it attempts to pop the empty stack.ExampleBuild an NPDA which recognises ... Read More

Display Count Over Bar in Matplotlib Histogram

Rishikesh Kumar Rishi
Updated on 15-Jun-2021 13:19:36

4K+ Views

To display the count over the bar in matplotlib histogram, we can iterate each patch and use text() method to place the values over the patches.StepsSet the figure size and adjust the padding between and around the subplots.Make a list of numbers to make a histogram plot.Use hist() method to make histograms.Iterate the patches and calculate the mid-values of each patch and height of the patch to place a text.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True data = [3, 5, 1, 7, 9, 5, 3, 7, 5] _, ... Read More

Replace Auto-Labelled Relative Values with Absolute Values in Matplotlib

Rishikesh Kumar Rishi
Updated on 15-Jun-2021 13:18:13

763 Views

To replace auto-labelled relayive values by absolute values in matplotlib, we can use autopct=lambda p: .StepsSet the figure size and adjust the padding between and around the subplots.Make lists of labels, fractions, explode position and get the sum of fractions to calculate the percentage.Make a pie chart using labels, fracs and explode with autopct=lambda p: .To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True labels = ('Read', 'Eat', 'Sleep', 'Repeat') fracs = [5, 3, 4, 1] total = sum(fracs) explode = (0, 0.05, 0, 0) plt.pie(fracs, explode=explode, labels=labels,   ... Read More

Make Simple Double Head Arrows on the Axes in Matplotlib

Rishikesh Kumar Rishi
Updated on 15-Jun-2021 13:17:12

3K+ Views

To make simple double head arrows on the axes in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Use annotate() method to annotate the point xy with text='Arrows'. Start the tuple and end it for positions. In arrowprops dictionary, use arrowstyle "" and color='red'.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True plt.annotate('Arrows', xy=(0.1, .1), xytext=(0.5, 0.5),             arrowprops=dict(arrowstyle='', color='red')) plt.show()Output

Advertisements