Skip to content

Commit 8fdf397

Browse files
authored
Merge pull request #6 from virtual-labs/dev
Format for tests got fixed
2 parents 1d4e8e3 + fde2292 commit 8fdf397

File tree

2 files changed

+164
-92
lines changed

2 files changed

+164
-92
lines changed

experiment/posttest.json

Lines changed: 82 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,158 @@
11
{
2-
"version": "2.0",
2+
"version": 2.0,
33
"questions": [
44
{
5-
"id": 1,
6-
"difficulty": "beginner",
75
"question": "What is the first step in Thompson's construction?",
8-
"options": {
6+
"answers": {
97
"a": "Convert to DFA",
108
"b": "Create basic NFAs for individual symbols",
119
"c": "Remove epsilon transitions",
1210
"d": "Minimize the automaton"
1311
},
14-
"correct": "b",
15-
"explanation": "Correct: The first step in Thompson's construction is to create basic NFAs for individual symbols in the regular expression."
12+
"explanations": {
13+
"a": "Incorrect: Converting to DFA is not the first step in Thompson's construction.",
14+
"b": "Correct: The first step in Thompson's construction is to create basic NFAs for individual symbols in the regular expression.",
15+
"c": "Incorrect: Removing epsilon transitions is not part of Thompson's construction.",
16+
"d": "Incorrect: Minimizing the automaton is not the first step in Thompson's construction."
17+
},
18+
"correctAnswer": "b",
19+
"difficulty": "beginner"
1620
},
1721
{
18-
"id": 2,
19-
"difficulty": "beginner",
2022
"question": "How are concatenated expressions handled in Thompson's construction?",
21-
"options": {
23+
"answers": {
2224
"a": "By creating parallel paths",
2325
"b": "By connecting accept state of first NFA to start state of second NFA",
2426
"c": "By merging states",
2527
"d": "By creating new transitions"
2628
},
27-
"correct": "b",
28-
"explanation": "Correct: In Thompson's construction, concatenation is handled by connecting the accept state of the first NFA to the start state of the second NFA with an epsilon transition."
29+
"explanations": {
30+
"a": "Incorrect: Parallel paths are used for union, not concatenation.",
31+
"b": "Correct: In Thompson's construction, concatenation is handled by connecting the accept state of the first NFA to the start state of the second NFA with an epsilon transition.",
32+
"c": "Incorrect: States are not merged for concatenation.",
33+
"d": "Incorrect: New transitions alone do not handle concatenation properly."
34+
},
35+
"correctAnswer": "b",
36+
"difficulty": "beginner"
2937
},
3038
{
31-
"id": 3,
32-
"difficulty": "beginner",
3339
"question": "What is the purpose of epsilon transitions in the constructed NFA?",
34-
"options": {
40+
"answers": {
3541
"a": "To make the NFA faster",
3642
"b": "To allow state changes without consuming input",
3743
"c": "To reduce memory usage",
3844
"d": "To make the NFA deterministic"
3945
},
40-
"correct": "b",
41-
"explanation": "Correct: Epsilon transitions allow the NFA to change states without consuming any input symbol, which is essential for implementing operations like concatenation and union."
46+
"explanations": {
47+
"a": "Incorrect: Epsilon transitions do not make the NFA faster.",
48+
"b": "Correct: Epsilon transitions allow the NFA to change states without consuming any input symbol, which is essential for implementing operations like concatenation and union.",
49+
"c": "Incorrect: Epsilon transitions do not reduce memory usage.",
50+
"d": "Incorrect: Epsilon transitions make the NFA non-deterministic, not deterministic."
51+
},
52+
"correctAnswer": "b",
53+
"difficulty": "beginner"
4254
},
4355
{
44-
"id": 4,
45-
"difficulty": "intermediate",
4656
"question": "How is the union operation (|) implemented in Thompson's construction?",
47-
"options": {
57+
"answers": {
4858
"a": "By creating a single path",
4959
"b": "By creating parallel paths with epsilon transitions",
5060
"c": "By merging states",
5161
"d": "By creating new symbols"
5262
},
53-
"correct": "b",
54-
"explanation": "Correct: The union operation is implemented by creating parallel paths with epsilon transitions from a new start state to both NFAs and from both NFAs to a new accept state."
63+
"explanations": {
64+
"a": "Incorrect: A single path cannot represent union of two expressions.",
65+
"b": "Correct: The union operation is implemented by creating parallel paths with epsilon transitions from a new start state to both NFAs and from both NFAs to a new accept state.",
66+
"c": "Incorrect: States are not merged for union operation.",
67+
"d": "Incorrect: New symbols are not created for union operation."
68+
},
69+
"correctAnswer": "b",
70+
"difficulty": "intermediate"
5571
},
5672
{
57-
"id": 5,
58-
"difficulty": "intermediate",
5973
"question": "What is the purpose of the stack in Thompson's construction?",
60-
"options": {
74+
"answers": {
6175
"a": "To store the input string",
6276
"b": "To keep track of NFAs being built",
6377
"c": "To store the final result",
6478
"d": "To store intermediate calculations"
6579
},
66-
"correct": "b",
67-
"explanation": "Correct: The stack in Thompson's construction is used to keep track of the NFAs being built, allowing for proper handling of nested expressions and operators."
80+
"explanations": {
81+
"a": "Incorrect: The stack does not store the input string.",
82+
"b": "Correct: The stack in Thompson's construction is used to keep track of the NFAs being built, allowing for proper handling of nested expressions and operators.",
83+
"c": "Incorrect: The stack does not store the final result.",
84+
"d": "Incorrect: The stack does not store intermediate calculations."
85+
},
86+
"correctAnswer": "b",
87+
"difficulty": "intermediate"
6888
},
6989
{
70-
"id": 6,
71-
"difficulty": "intermediate",
7290
"question": "How is the Kleene star (*) operation implemented in Thompson's construction?",
73-
"options": {
91+
"answers": {
7492
"a": "By creating a single path",
7593
"b": "By creating a loop with epsilon transitions",
7694
"c": "By merging states",
7795
"d": "By creating new symbols"
7896
},
79-
"correct": "b",
80-
"explanation": "Correct: The Kleene star operation is implemented by creating a loop with epsilon transitions, allowing for zero or more repetitions of the subexpression."
97+
"explanations": {
98+
"a": "Incorrect: A single path cannot represent the Kleene star operation.",
99+
"b": "Correct: The Kleene star operation is implemented by creating a loop with epsilon transitions, allowing for zero or more repetitions of the subexpression.",
100+
"c": "Incorrect: States are not merged for the Kleene star operation.",
101+
"d": "Incorrect: New symbols are not created for the Kleene star operation."
102+
},
103+
"correctAnswer": "b",
104+
"difficulty": "intermediate"
81105
},
82106
{
83-
"id": 7,
84-
"difficulty": "advanced",
85107
"question": "What is the space complexity of the NFA constructed using Thompson's construction?",
86-
"options": {
108+
"answers": {
87109
"a": "O(n²)",
88110
"b": "O(n³)",
89111
"c": "O(n)",
90112
"d": "O(2ⁿ)"
91113
},
92-
"correct": "c",
93-
"explanation": "Correct: The space complexity of the NFA constructed using Thompson's construction is O(n), where n is the length of the regular expression."
114+
"explanations": {
115+
"a": "Incorrect: The space complexity is not quadratic.",
116+
"b": "Incorrect: The space complexity is not cubic.",
117+
"c": "Correct: The space complexity of the NFA constructed using Thompson's construction is O(n), where n is the length of the regular expression.",
118+
"d": "Incorrect: The space complexity is not exponential."
119+
},
120+
"correctAnswer": "c",
121+
"difficulty": "advanced"
94122
},
95123
{
96-
"id": 8,
97-
"difficulty": "advanced",
98124
"question": "Why is Thompson's construction important in compiler design?",
99-
"options": {
125+
"answers": {
100126
"a": "It makes compilers faster",
101127
"b": "It provides a way to convert regular expressions to NFAs for lexical analysis",
102128
"c": "It reduces memory usage",
103129
"d": "It makes code more readable"
104130
},
105-
"correct": "b",
106-
"explanation": "Correct: Thompson's construction is important in compiler design because it provides a way to convert regular expressions to NFAs, which are used in lexical analysis to recognize tokens."
131+
"explanations": {
132+
"a": "Incorrect: Thompson's construction does not directly make compilers faster.",
133+
"b": "Correct: Thompson's construction is important in compiler design because it provides a way to convert regular expressions to NFAs, which are used in lexical analysis to recognize tokens.",
134+
"c": "Incorrect: Thompson's construction does not directly reduce memory usage.",
135+
"d": "Incorrect: Thompson's construction does not make code more readable."
136+
},
137+
"correctAnswer": "b",
138+
"difficulty": "advanced"
107139
},
108140
{
109-
"id": 9,
110-
"difficulty": "advanced",
111141
"question": "What is the relationship between the number of states in the final NFA and the length of the regular expression?",
112-
"options": {
142+
"answers": {
113143
"a": "The number of states is always equal to the length",
114144
"b": "The number of states is at most twice the length",
115145
"c": "The number of states is at most three times the length",
116146
"d": "The number of states is exponential in the length"
117147
},
118-
"correct": "b",
119-
"explanation": "Correct: In Thompson's construction, the number of states in the final NFA is at most twice the length of the regular expression, as each symbol and operator can create at most two new states."
148+
"explanations": {
149+
"a": "Incorrect: The number of states is not always equal to the length.",
150+
"b": "Correct: In Thompson's construction, the number of states in the final NFA is at most twice the length of the regular expression, as each symbol and operator can create at most two new states.",
151+
"c": "Incorrect: The number of states is not three times the length.",
152+
"d": "Incorrect: The number of states is not exponential in the length."
153+
},
154+
"correctAnswer": "b",
155+
"difficulty": "advanced"
120156
}
121157
]
122158
}

0 commit comments

Comments
 (0)