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([Link]()=5)
(if([Link]() = 0)
>6 >1
>3 >0
>3 >0
>3 >1
>1 >1
O[6] O[1]
The worst case scenario is when [Link] is 0, which has time complexity of 6. For the best
case scenario is when [Link] is 5, which has time complexity of 1. This is because if the
[Link] is equal to 0, it has to iterate the while loop for 6 times, and if [Link] 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.