Presentation is loading. Please wait.

Presentation is loading. Please wait.

MATH 224 – Discrete Mathematics

Similar presentations


Presentation on theme: "MATH 224 – Discrete Mathematics"— Presentation transcript:

1 MATH 224 – Discrete Mathematics
Deterministic Finite Automata Finite State Machines Set of States Q Start State q0  Q Accepting States qf  Q Alphabet  e.g, {0, 1} Transitions  (, qi)  qj q1 q2 q3 q0 qf1 qf2 qi qj 4/25/2017

2 MATH 224 – Discrete Mathematics
DFA Represented by a Directed Graph Multitasking in an operating System Time slice expired Start Ready Queue Running Dequeued Finished with resource and ready to run Blocked waiting for a resource, e.g. data from a disk Blocked Waiting 4/25/2017

3 MATH 224 – Discrete Mathematics
DFA for Multiples of 3 in binary Start q0 Example 1 46 remainder 1 string States Example 2 51 remainder 0 string States qf-3 1 1 1 1 q1 q2 4/25/2017

4 MATH 224 – Discrete Mathematics
DFA to Recognize Floating Point 0 - 9 Start 0 - 9 q0 . q2 qf-0 +, – 0 - 9 e, E 0 - 9 q5 q1 q3 +, – 0 - 9 q4 0 - 9 Qf-1 0 - 9 4/25/2017

5 MATH 224 – Discrete Mathematics
Crossing the Bridge in Minimum Time 1, 2, 5 and 10 minutes 5 &10 q6 Start Only 2 of the final states are shown here, one of the two shortest and one of the next shortest. q0 2 &10 q5 1 & 2 2 & 5 1&10 What would the longest time be? 2 minutes 1 & 5 q1 q4 q3 1 2 q2 5 minutes 3 minutes 1 19 minutes q7 q8 5 5 &10 q10 6 minutes qf17 q9 1 &10 q11 q12 q15 13 minutes 16 minutes 1 & 2 1 2 q16 1 & 2 17 minutes q13 qf14 15 minutes 17 minutes 4/25/2017

6 MATH 224 – Discrete Mathematics
Other DFAs Construct a DFA that recognizes legal identifier names in C++ using α to represent letters and δ to represent the digits 0 through 9. Construct a DFA to recognize even numbers in binary. Construct a DFA to recognize multiples of four in binary. Construct a DFA to recognize multiples of 5 in binary. Construct a DFA to recognize multiples of 5 in decimal. 4/25/2017

7 MATH 224 – Discrete Mathematics
Representing a DFA in a Computer Program Probably the simplest way to represent a DFA in a program is to use a 2-dimensional array, where each column corresponds to a character in the alphabet and each row corresponds to a state. So for example here is the DFA that recognizes multiples of 3 in binary. 1 Blank 3 Halt 2 qf-3 4/25/2017

8 MATH 224 – Discrete Mathematics
DFA for Multiples of 6 in binary Start q0 qf-6 q3 1 1 1 1 1 q1 q2 4/25/2017


Download ppt "MATH 224 – Discrete Mathematics"

Similar presentations


Ads by Google