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

COMPT Assignment

This document discusses an NFA to DFA conversion. It defines an NFA with 5 states and transition table. It then shows the steps to convert the NFA to a DFA. These steps include epsilon-closure, constructing the DFA transition table, and eliminating epsilon transitions. Finally, it derives the regular expression for the language as ((00*) +(11*))*.

Uploaded by

pmadoh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
96 views

COMPT Assignment

This document discusses an NFA to DFA conversion. It defines an NFA with 5 states and transition table. It then shows the steps to convert the NFA to a DFA. These steps include epsilon-closure, constructing the DFA transition table, and eliminating epsilon transitions. Finally, it derives the regular expression for the language as ((00*) +(11*))*.

Uploaded by

pmadoh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Part A

i)

“0011”

ii)

Q = {q0, q1, q2, q3, q4}

∑ = {0, 1, Ꜫ }

First State = {q0}

Final State = {q4}

Transition Table

δ 0 1 Ꜫ
q0 NULL NULL q1
q1 q2 q3 NULL
q2 q4 NULL NULL
q3 NULL q4 NULL
q4 NULL NULL q1
iii)

Convert from NFA to DFA Diagram

Step 1:

Ꜫ -closure = {q0, q1} A

Step 2:

0 {q2, q4} {q1, q2, q4} B


A {q0, q1}
1 {q3, q4} {q1, q3, q4} C

Step 3:
0 {q2, q4} {q1, q2, q4} B
B {q1, q2, q4}
1 {q3, q4} {q1, q3, q4} C

Step 4:
0 {q2, q4} {q1, q2, q4} B
C {q1, q3, q4}
1 {q3, q4} {q1, q3, q4} C

Step 5:
0 1
A B C
B B C
C B C
iv)
Regular Expression

Step 1: Original State


Step 2: Add new final state

Step 3: Eliminate self-loop in state B


Step 4: Eliminate connection of state A to state B

Step 5: Eliminate self-loop in state C


Step 6: Eliminate state B

Step 7: Eliminate state C (final step)

RE: ((00*) +(11*))*


Part B
i) Code Snippet

ii)
Time Complexity if(data.length()=5)
(if(data.length() = 0)
>6 >1
>3 >0
>3 >0

>3 >1

>1 >1
O[6] O[1]

The worst case scenario is when data.length is 0, which has time complexity of 6. For the best
case scenario is when data.length is 5, which has time complexity of 1. This is because if the
data.length is equal to 0, it has to iterate the while loop for 6 times, and if data.length is equal
to 5, it only run through the loop 1 time only.
iii)

The discard of while loop reduce the time complexity. Instead of looping, using string instead
of character in the concatenate of data.

iv)
Computability is the limit of computer to solve a problem. A function is defined as
computable if the function can be form by finite automata. Therefore, the code snippet state
above is computable, able to perform finite automata. The code above also passed the
computational standard as complete, mechanistic, and deterministic as the code given correct
output even in identical input.

v)
An algorithm or function can be defined as decidable or undecidable. Which decidable is the
machine accepts and halts on every input string, and undecidable is the machine do not have
any solution and turn into infinite loop. As the code snippet above is decidable, as given the
correct output with two different scenario which are worse case and best-case scenario and
receiving the correct output.

You might also like