CSE355_SP24_mid1sol
.pdf
keyboard_arrow_up
School
Arizona State University *
*We aren’t endorsed by this school
Course
355
Subject
Computer Science
Date
Apr 3, 2024
Type
Pages
7
Uploaded by DrTree7011
CSE 355
Page 2
M
idterm
1 - S
ample
S
olutions
Question 1-5: Determine whether the given statement is True or False. If it is true, give a brief reasoning as
to why, otherwise give a
counter-example
. ALL of the points are for the reasoning; each is worth
2 points
1. (T
/
F) If
R
is a regular expression, (
RR
⇤
[
R
)
⇤
R
=
R
+
TRUE
:
RR
⇤
is
R
+
, then
RR
⇤
[
R
=
R
+
because
R
⇢
R
+
. Then, it follows that (
R
+
)
⇤
is
R
⇤
. Finally,
R
⇤
R
evaluates to
R
+
.
Common mistake is just saying (
RR
⇤
[
R
) evaluates to
R
without explaining.
2. (T
/
F) A subset of a regular language is regular.
FALSE
: Every nonregular language is a subset of the regular language
⌃
⇤
.
3. (T
/
F) Let
L
1
=
L
2
L
3
. If
L
2
is regular and
L
3
is not regular,
L
1
is never regular.
FALSE
: Let
L
2
=
L
(1
⇤
) and it is surely regular. Let
L
3
=
{
1
n
|
n
is a prime number
}
, which is not
regular (proved in the problem set for PL). The concatenation of
L
2
and
L
3
is
L
1
=
L
(111
⇤
). It is
surely regular because it is expressed in a regular expression.
4. (T
/
F)
L
1
is an infinite regular language. Every DFA
M
where
L
(
M
)
=
L
1
, contains at least one cycle
in its state diagram.
TRUE
: If
L
1
is infinite regular language and
M
is a DFA that recognizes
L
1
, there always is a string
w
2
L
1
, where
|
w
|
>
=
|
Q
|
,
(
Q
is the finite set of states in
M
), otherwise
L
1
is finite. In the accepted
computation of
w
on
M
, there must be exactly
|
w
|
many transitions (
|
w
|
+
1 states are visited) or at least
as many transitions as
|
Q
|
. By pigeon hole principle, there must be at least one state that is visited
multiple times, there must be a cycle in
M
.
Common mistake is just mentioning infinite language
must go through loop. Pigeon hole principle must be used to compare the length of string and the
numbber of states to receive credit.
5. (T
/
F) The intersection of a nonregular language and a regular language cannot be regular.
FALSE
: The intersection of every nonregular language and the regular language
;
is
;
.
2
Copyright c 2024 Heewook Lee
CSE 355
Page 3
M
idterm
1 - S
ample
S
olutions
Q5-10
: Determine whether the given statement is True or False. Write ‘T’ if true, ‘F’ otherwise.
6. If you used the method shown in lecture to convert (01
[
10)
⇤
into an equivalent NFA, how many total
states and accept states would the machine have? [
C
]
(a) 8 total states, 5 accept states
(b) 6 total states, 3 accept states
(c) 10 total states, 3 accept states
(d) 9 total states, 5 accept states
(e) None of the above
7. Let
L
=
{
www
|
w
2
{
0
,
1
}
⇤
}
. Which of the following is true? [
C
]
(a)
L
is nonregular because 0
p
10
p
cannot be pumped.
(b)
L
is regular because the regular expression
⌃
⇤
⌃
⇤
⌃
⇤
describes the language.
(c)
L
is nonregular because 0
p
10
p
10
p
1 cannot be pumped.
(d)
L
is regular because a finite automaton can be built to recognize it.
(e) Both (a) and (c)
8. If
L
1
=
{
a
n
|
n
≥
0
}
and L
2
=
{
b
n
|
n
≥
0
}
, consider
I.
L
1
·
L
2
is regular language.
II.
L
1
·
L
2
=
{
a
n
b
n
|
n
≥
0
}
Which one of the following is correct? [
A
]
(a) Only I
(b) Only II
(c) Both I and II
(d) Neither I nor II
9. To show that a language is regular, one could give a DFA for it. One could also [
D
]
(a) give a regular expression.
(b) use the pumping lemma for regular languages.
(c) use closure properties.
(d) (a) or (c)
(e) (a), (b), or (c)
10.
L
=
{
(
ab
)
n
:
n
≥
0
}
[
E
]
(a) not regular because you cannot remember
n
.
(b) not regular because (
ab
)
p
cannot be pumped.
(c) not regular because (
ab
)
p
cannot be pumped.
(d) regular because it is
a
⇤
b
⇤
.
(e) regular because it is (
ab
)
⇤
.
3
Copyright c 2024 Heewook Lee
CSE 355
Page 4
M
idterm
1 - S
ample
S
olutions
Question L-1: (
25 points total
) Assume
⌃
=
{
0
,
1
}
. Let
⌃
=
0
,
1 and consider the following DFA
M
3
given
as its state diagram and its language
L
.
q
0
q
1
q
2
0
0
1
1
0
1
(a) Describe the language
L
of the given DFA in plain English (
3 points
).
All strings that end with 10.
“Ending with 10” needed for any credit. Every error results in -1.
(b) Describe
L
in plain English and directly provide a regular expression that expresses
L
(
L
is a comple-
ment language of
L
). (
3 points
).
All strings that does not end with 10.
Regex:
"
[
0
[
(0
[
1)
⇤
(00
[
1)
1pt for description
1pt for handling “ending with 00” and “ending with 1”
1pt for handling “
"
” and “0”
(c) Describe the reversal language
L
R
in plain English and directly draw a 4-state DFA
M
0
3
that recognizes
L
R
(
4 points
).
q
0
0
;
q
0
1
q
0
2
1
0
1
0
0,1
0,1
1pt for having a 4-state DFA
2pt for handling “the transition from start to accept with 0-1 transition”
-1pt for every error
This question continues on next page.
4
Copyright c 2024 Heewook Lee
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
L2= {1010 10ª | a ≥ 0}
5. () Using L₂ from the previous problem, is L₂ € Eo? Circle the appropriate answer and justify
your answer.
YES or NO
6. () Using L₂ from the previous problem, is L₂ E₁? Circle the appropriate answer and justify
your answer.
YES or NO
arrow_forward
12. Simplify the following Boolean function F, together with the don’t-care conditions d :
arrow_forward
The set of premises and a conclusion are given. Use the valid
argument forms to deduce the conclusion from the premises, giving a
reason for each step. Assume all variables are statement variables.
a. p>9
b. rVs
c. ~s >-t
d. ~q Vs
C.
e. ~S
f. ~pAr>u
g. w Vt
h. uAw
arrow_forward
Let p, q, and r represent the following statements:
p: The first ball is red.
q: The second ball is white.
r: The third ball is blue.
Which would be the correct English statement for the symbolic form (¬¬p ∧∧ q) →→ r ?
Group of answer choices
A .If the first ball is red or the second ball is white, then the third ball is blue.
B. If the first ball is not red or the second ball is white, then the third ball is blue.
C .If the first ball is not red and the second ball is white, then the third ball is blue.
D. If the first ball is red and the second ball is white, then the third ball is blue.
arrow_forward
Question 37
The correct statements are:
If both L and ¬L are in D, then L must be also in SD.
If both L and ¬L are in D, then ¬L must be also in SD.
If both L and ¬L are in SD, then L must be also in D.
If both L and ¬L are in SD, then ¬L must be also in D.
arrow_forward
Definition of 3SAT : In the 3SAT problem, the input is a Boolean expression formed by m clause and n variables (each variable x can have a positive literal x and negative literal x). Each clause formed by disjunction of threeliterals and the formula is formed by the conjunction of the m clauses. For example, the following formulais an instance of the 3SAT problem: (x1 ∨ x2 ∨ x3) ∧ (x1 ∨ x2 ∨ x3) ∧ (x1 ∨ x2 ∨ x3), which is formed by 3 variables x1, x2, x3 and three clauses. The objective is to find an assignment of Boolean values to variables to satisfy the formula. In the example above, one possible satisfying assignment is to let x1 to be false and x2, x3 to be true.
Problem : A 2SAT formula is a conjunction of clauses like a 3SAT formula, except that each clause is a disjunction of 2 literals (rather than 3). For example (x1 ∨ x2) ∧ (x2 ∨ x3) ∧ (x3 ∨ x1) is a 2SAT formula.Use consistency model to provide a 2SAT formula consistent with the following labelled data (or specifythat…
arrow_forward
No. 2 question only.
arrow_forward
Objective: The objective of this discussion is to be aware of the field of logic.
Problem Statement: Consider the statement:
"There is a person x who is a student in CSEN 5303 and has visited Mexico"
Explain why the answer cannot be 3r (S(x)→ M(x)).
arrow_forward
Please answer with explanations.
arrow_forward
Quadratic Root Solver
For a general quadratic equation y = ax? + bx + c, the roots can be classified into
three categories depending upon the value of the discriminant which is given by
b2 - 4ac
First, if the discriminant is equal to 0, there is only one real root. Then, if the discriminant
is a positive value, there are two roots which are real and unequal. The roots can be
computed as follows:
-b+ Vb? – 4ac
2a
Further, if the discriminant is a negative value, then there are two imaginary roots. In
this case, the roots are given by
b
ь? - 4ас
2a
2a
Programming tasks:
A text file, coeff.txt has the following information:
coeff.txt
3
4
4
4
1
4
Each line represents the values of a, b and c, for a quadratic equation. Write a program
that read these coefficient values, calculate the roots of each quadratic equation, and display
the results. Your program should perform the following tasks:
• Check if the file is successfully opened before reading
• Use loop to read the file from main…
arrow_forward
1. Suppose that a bank only permits passwords that are strings from the
alphabets = {a,b.c, d, 1, 2, 3, 4). The passwords follow the rules
(a) The length can be 5 or more.
(b) The first alphabet must be from {a,b,c,d}.
(c) The last two alphabets must be from {1,2,3,4}
Give a regular expression for this language.
arrow_forward
help me to solve the problem
arrow_forward
Solve in C# please..
Kinly provide correct solution
Objective
In this problem, you need to find the maximum number of cities that Jeff can visit on his way from West to East.
As Jeff travels from West to East, he has two rules:
He can only travel to cities in lexicographic order (e.g. Jeff cannot travel from Berkeley to Albany nor can he travel from City2 to City100).
He can only travel to cities that are further from the West than the city he is currently at (e.g. if Jeff is at Berkeley, he cannot travel to cities that are closer to the West than Berkeley).
Implementation
Implement the method MaxCities(cities, distances) which returns the maximum number of cities that Jeff can visit.
The first input argument, cities, is an array of strings representing the city names. For example:
['Tucson', 'Albany', 'Smith', 'Westford', 'Berkeley']
The second input argument, distances, is an array of integers representing the distances from the West point to the cities. Each distance is unique…
arrow_forward
Click and drag the appropriate word, symbol, or phrase into the most appropriate blank.
Let P(x) be the statement "x can speak Russian" and let Q(x) be the statement "x knows the computer language C+t."
Consider the statement, "Every student at your school either can speak Russian, or knows C+." This statement is
k(n)
beginning of the symbolic statement is
statement, because of the word, "every." So, the appropriate quantifier to be applied at the
.We want this symbol to act on x, representing a student at your
school. The universal statement may be rewritten for clarity's sake as, "Every student at your school speaks Russian or
every student at your school knows C++." The phrases, "student at your school speaks Russian" and "student at your
school knows C++" are directly symbolized by
respectively. Finally, the word "or" requires the
statement to employ the
. Hence, the completed quantified statement is
Q(X) and P(x)
P(x) and Q(x)
universal
VX(P(x)vQ(x))
3X(P(X)AQ(x))
conditional…
arrow_forward
Refer to the following statement to answer parts (a) through (c) below,
The professor is intelligent and an overachiever, or not an overachiever
a. Write the statement in symbolic form Assign letters to simple statements that are not negated Choose the correct answer below
OA. let p=The professor is intelligent and letq= The professor is not an overachiever, (p A q)v
OB. let p= The professor is intelligent and let q= The professor is not an overachiever (p v q) A
OC. let p= The professor is intelligent and let q= The professor is an overachiever (p A q) v -q
O D. letp=The professor is intelligent and let q= The professor is an overachiever, (p v q) ^ -9
b. Construct a truth table for the symbolic statement in part (a)
PAq
(pAq) v -q
T.
arrow_forward
1. Give the unifyiing substitition for (x,y,z are variables): f(a) f(b)
2. Give the unifyiing substitition for (x,y,z are variables): g(x,x) g(f(a),f(y))
3. Give the unifyiing substitition for (x,y,z are variables): g(x,x) g(f(a0,f(b))
arrow_forward
Please answer all
arrow_forward
1. Consider the following statements:
P(z, y) = "3r €R such that Vy E R, z = 2y"
Q(z, y) = "Vz € R By ER such that z= 2y"
Explain the difference between what these two statements are claiming. Which of them is true and which
of them is false?
arrow_forward
7
arrow_forward
Part I.
Let p, q, and r be the following simple statements:
p: Sydney is the capital of Australia.
q: Thirteen is a prime number.
r: The Trinity University of Asia is in Quezon City.
Express each of the following propositions as an English sentence and determine its truth value.
Part II.
Use the truth table to determine whether the following pairs of statement are logically equivalent or not .
1. ~(p↑q)and~p↑-q
2. p↓(q↑r)and(p↑q)↓(p↑r)
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Related Questions
- L2= {1010 10ª | a ≥ 0} 5. () Using L₂ from the previous problem, is L₂ € Eo? Circle the appropriate answer and justify your answer. YES or NO 6. () Using L₂ from the previous problem, is L₂ E₁? Circle the appropriate answer and justify your answer. YES or NOarrow_forward12. Simplify the following Boolean function F, together with the don’t-care conditions d :arrow_forwardThe set of premises and a conclusion are given. Use the valid argument forms to deduce the conclusion from the premises, giving a reason for each step. Assume all variables are statement variables. a. p>9 b. rVs c. ~s >-t d. ~q Vs C. e. ~S f. ~pAr>u g. w Vt h. uAwarrow_forward
- Let p, q, and r represent the following statements: p: The first ball is red. q: The second ball is white. r: The third ball is blue. Which would be the correct English statement for the symbolic form (¬¬p ∧∧ q) →→ r ? Group of answer choices A .If the first ball is red or the second ball is white, then the third ball is blue. B. If the first ball is not red or the second ball is white, then the third ball is blue. C .If the first ball is not red and the second ball is white, then the third ball is blue. D. If the first ball is red and the second ball is white, then the third ball is blue.arrow_forwardQuestion 37 The correct statements are: If both L and ¬L are in D, then L must be also in SD. If both L and ¬L are in D, then ¬L must be also in SD. If both L and ¬L are in SD, then L must be also in D. If both L and ¬L are in SD, then ¬L must be also in D.arrow_forwardDefinition of 3SAT : In the 3SAT problem, the input is a Boolean expression formed by m clause and n variables (each variable x can have a positive literal x and negative literal x). Each clause formed by disjunction of threeliterals and the formula is formed by the conjunction of the m clauses. For example, the following formulais an instance of the 3SAT problem: (x1 ∨ x2 ∨ x3) ∧ (x1 ∨ x2 ∨ x3) ∧ (x1 ∨ x2 ∨ x3), which is formed by 3 variables x1, x2, x3 and three clauses. The objective is to find an assignment of Boolean values to variables to satisfy the formula. In the example above, one possible satisfying assignment is to let x1 to be false and x2, x3 to be true. Problem : A 2SAT formula is a conjunction of clauses like a 3SAT formula, except that each clause is a disjunction of 2 literals (rather than 3). For example (x1 ∨ x2) ∧ (x2 ∨ x3) ∧ (x3 ∨ x1) is a 2SAT formula.Use consistency model to provide a 2SAT formula consistent with the following labelled data (or specifythat…arrow_forward
- No. 2 question only.arrow_forwardObjective: The objective of this discussion is to be aware of the field of logic. Problem Statement: Consider the statement: "There is a person x who is a student in CSEN 5303 and has visited Mexico" Explain why the answer cannot be 3r (S(x)→ M(x)).arrow_forwardPlease answer with explanations.arrow_forward
- Quadratic Root Solver For a general quadratic equation y = ax? + bx + c, the roots can be classified into three categories depending upon the value of the discriminant which is given by b2 - 4ac First, if the discriminant is equal to 0, there is only one real root. Then, if the discriminant is a positive value, there are two roots which are real and unequal. The roots can be computed as follows: -b+ Vb? – 4ac 2a Further, if the discriminant is a negative value, then there are two imaginary roots. In this case, the roots are given by b ь? - 4ас 2a 2a Programming tasks: A text file, coeff.txt has the following information: coeff.txt 3 4 4 4 1 4 Each line represents the values of a, b and c, for a quadratic equation. Write a program that read these coefficient values, calculate the roots of each quadratic equation, and display the results. Your program should perform the following tasks: • Check if the file is successfully opened before reading • Use loop to read the file from main…arrow_forward1. Suppose that a bank only permits passwords that are strings from the alphabets = {a,b.c, d, 1, 2, 3, 4). The passwords follow the rules (a) The length can be 5 or more. (b) The first alphabet must be from {a,b,c,d}. (c) The last two alphabets must be from {1,2,3,4} Give a regular expression for this language.arrow_forwardhelp me to solve the problemarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education