COMPT Assignment
COMPT Assignment
i)
“0011”
ii)
∑ = {0, 1, Ꜫ }
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)
Step 1:
Step 2:
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
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.