0% found this document useful (0 votes)
9 views

Design FA With

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Design FA With

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

ADDIS ABABA University

INSTITUTE OF TECHNOLOGY
School Of Information Technology
and Engineering

Compiler Design
Finite Automation

Asignment

Prepared By: -
1. Emebet Sisay ID ATE/8784/12
2. Minasie Simon ID ATE/0818/12
3. Sefesilasse Hailu ID ATE/7785/12
4. Tamrat Demeke ID ATE/9737/12
5. Yonas Buzuayehu ID ATE/6357/12

Submitted to : Yared Y.

August 2024
1. Design FA with ∑ = {0, 1} accepts even number of 0's and even number of 1’s.
∑ = {0, 1}, that accepts:
1. Odd number of 0’s or even number of 1’s
2. Odd number of 0’s and even number of 1’s
3. Either odd number of 0’s or even number of 1’s but not the both together
Solution – Let first design two separate machines for the two conditions:
 Accepting only odd number of 0’s
 Accepting only even number of 1’s
Odd number of 0’s and even number of 1’s: This machine accept that languages which
contains odd no. of 0’s and even no. of 1’s. As we know that q1 indicates odd no. of 0’s
and q2 indicates even no. of 1’s. So, the final states of the required DFA will contain both
q1 and q2. .’. Final state = {(q1q2)}
2. Design a Finite Automaton (FA) that accepts strings over the alphabet Σ={a,b}

where the string contains the substring "ab" exactly twice, and no other substring

"ab".

Given a binary string S, the task is to write a program for DFA Machine that accepts a set of all
strings over w ∈ (a, b)* which contains “aba” as a substring.

Examples : Input-1 : ababa

Output : Accepted

Explanation : "ababa" consists "aba"

Input-2 : abbbb

Output : Not accepted

Explanation : "abbbb" does not consist "aba"

Approach : Below is the designed DFA Machine for the given problem. Construct a transition
table for DFA states and analyze the transitions between each state. Below are the steps –
Desired Language:

L = {aba, baba, abab, aababbb.....}

Explanation:

1. Firstly, there will be 4states.(say q0, q1, q2, q3) , with q0 being initial state and q3
being final state.
2. Initially we will be in q0 state, now we start reading the given string.
 When we read ‘b’, we will remain in the same state
 If we read ‘a’, then it transits to state q1.

3. Assuming that now we are in q1 state.

 When we read ‘a’, we will remain in the same state.


 If we read ‘b’, we will transits to state q2.

4. Assuming that now we are in q2 state.

 If we read ‘a’, it transits to state q3.


 If we read ‘b’, it transits to state q0.

5. Assuming we are in final state(q3)

 We remain in the same state, when we read ‘a’ or ‘b’.

6. All strings which are accepted by this DFA will have “aba” as its substring.

Transition Table :

Current State Final State


a b
q0 q1 q0
q1 q1 q2
q2 q3 q0
q3 q3 q3

3. Design a Finite Automaton (FA) that accepts strings over the alphabet Σ={0,1}
where the string contains an even number of 0's and an odd number of 1's, and

the substring "101" appears at least once.

Construct DFA for the language accepting strings starting with ‘101’

 All strings start with substring “101”.


 Then the length of the substring = 3.

Therefore, Minimum number of states in the DFA = 3 + 2 = 5.

The minimized DFA has five states.

The language L= {101,1011,10110,101101,.........}

The transition diagram is as follows –


 Step 1 − q0 is an initial state on input ‘1’ goes to q1 and on input ‘0’ leads to a dead state.
 Step 2 − q1 on input ‘0’ goes to q2 and on ‘1’ goes to dead state.
 Step 3 − q2 on input ‘1’ goes to qf which is the final state, and on ‘0’ goes to dead state.
 Step 4 − qf is the final state, on input ‘1’ and ‘0’ it goes to qf itself.
4. Design a Finite Automaton (FA) that accepts strings over the alphabet Σ={0,1}
where the number of 0's and 1's are both equal, and the string ends with the
substring "110".
Given binary string str, the task is to build a DFA that accepts the string if the string either starts
with “01” or ends with “01”.
Input: str = “010000”
Output: Accepted
Explanation:
The given string starts with “01”.
Input: str = “1100111”
Output: Not Accepted
Explanation:
The given string neither starts with nor ends with “01”.
Transition table and Transition rules of the above DFA:
State Input (0) Input (1)
>A B D
B E C
C* C C
D E D
E E F
F* E D

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy