CS 154, CS 154 Quiz 4-7, CS 154 Mid, Regular Language + Pushdown automatA
In formal languages, pick all true statements. (A). The prefix of ab can be a. (B). The suffix of ab can be b. (C). The suffix and prefix of ab can be lambda. (D). None.
A, B, and C
Let w be in E*, pick all true statements. (A). lambda is a prefix of w. (B). w is a suffix of w (C). lambda is a suffix of w. (D). None
A, B, and C
If L1 and L2 are regular languages, pick all regular languages: (A) (L1 - L2)* n L1* (B) L1* - L2* (C) L2 L1 L2 (D) None
A, B, and C are regular languages because all operations on regular languages produce a regular language.
Let L = {}, pick all true statements. (A). L can be a formal language. (B). L = phi (C). L* = lambda (D). None
A, B. L* would be a set containing lambda, but is not lambda itself so cannot be C.
Pick all true statements: (A) A loop is a cycle (B) A walk is a path if no vertices are repeated (C) All simple cycles are a path (D) A loop is a simple cycle
A, C, and D
Pick all true statements. (A). A loop is a simple cycle. (B). A walk is a path if no vertices are repeated. (C). A cycle is a path from a vertex to itself. (D). A cycle is a loop.
A, and C
If A n B = A, pick all true statements: (A) A is a subset of B (B) B is a subset of A (C) B = phi (D) None
A. If A is a subset of B, their intersection would only yield A since B can be equal to A or contain more elements than A.
If L1 and L2 are regular languages, pick all regular languages: (A) (L1 u L2)* (B) L1* u L2 (C) (L1 - L2)^R (D) None
All are correct because all operations on regular languages produce regular languages
What is the definition of a set?
An unordered collection of distinct objects
What is the constraint of DFAs?
At any given timeframe, there cannot be more than one transition.
What is the definition of deterministic automaton?
At any timeframe, there is no more than one transition
Pick all TRUE statements: (A) A n B = A (B) A n A' = phi (C) A u A' = U (D) None
B and C
Pick all true statements: (A) Every state of a DFA must have at least one outgoing transition for every element of alphabet (B) Transition function of DFAs must be "total function" (C) Every state of a DFA must have one and only one outgoing transition for every element of alphabet (D) None
B and C
Pick all condition(s) for TMs to reject a string. (A) Not consuming all input symbols (B) Halting in non-accepting state (C) Being stuck in an infinite loop (D) None
B and C are correct. Since TMs reject a string when they are not halted, the infinite loop counts as a rejection.
Which of the following statements make A u B = A true statements? Pick all applicable (A) A is a subset of B (B) B is a subset of A (C) B is phi (D) None
B and C are true. If B is a subset of A, B must be smaller or equal to A and thus their union would not change A. If B is empty, then the same result happens.
If A u B = A, pick all true statements (A) A is a subset of B (B) B is a subset of A (C) B is phi (D) None
B and C. Choice (A) doesn't work because it doesn't hold all the time
Pick all label(s) that can be a lambda transition for NPDAs (A) lambda, a ; w (B) lambda, lambda ; w (C) lambda, lambda ; lambda (D) a, lambda ; lambda
B and C. For NPDAs, a lambda transition means the input and top of the stack are lambda.
Pick all true statements: (A) phi^0 = phi (B) phi^0 = {lambda} (C) phi^0 is not valid (D) None
B is true. Phi^0 is the set containing lambda.
Pick all statements that we are sure about their truth: (A) Every formal language has an associated automaton (B) Every machine has an associated language (C) There is no association between the set of automata and the set of formal languages (D) None
B only. We don't know that every formal language has an associated automaton.
Pick all true statements: (A). A n B = A (B). A n U = A (C). A n U = U (D). None
B.
In formal languages, pick all true statements. (A). | lambda | = 1 (B). lambda = " " (C). | lambda | = 0 (D). None.
C only. Quotations is not empty string in formal languages.
Pick all true statements: (A). A u B = A (B). A u U = A (C). A u U = U (D). None
C.
When do TMs accept a string? (A) Consuming all input symbols (B) having finite sequence of transitions (C) halting in an accepting state (D) None
C. TMs must halt on an accepting state in order for it to accept a string. Consumption is meaningless for TMs
Y = {x : x in Z, x > 15 v x < 11} (A). Y is finite. (B). Y is not a set. (C). Y is infinite. (D). None.
C. Z is the set of all integers including negative numbers.
A formal language is a nonempty set of strings. True or False?
False. A formal language can be empty.
The (automata) class A is more powerful than class B iff the set of languages accepted by class A is a proper subset of the set of languages accepted by class B
False. A is more power than B if A can accept more languages (i.e. B's accepted languages is a proper subset of A's)
If A and B are sets, then A x B = B x A (Cartesian product) is always a wrong statement. True or False?
False. A x B = B x A when either A or B are phi or A = B.
All regular languages are finite. True or False?
False. All finite languages are regular, but it is not guaranteed that all regular languages are finite.
All infinite languages are non-regular. True or False?
False. All non-regular languages are infinite, but it is not guaranteed that all infinite languages are non-regular.
A short-circuit in deterministic machines is an edge without any symbol.
False. An edge without any symbols (aka lambda symbol) is a short-circuit for NON-deterministic machines
Two machines are equivalent iff both accept the same language. True or False?
False. Both machines' associated languages must be the same
NFAs are more powerful than DFAs.
False. NFAs and DFAs have the same power.
NFAs must have at least one final state. True or False?
False. NFAs have same building blocks as DFAs and should behave the same except for the "two violations"
In formal languages, a finite, nonempty sequence of symbols is called a string.
False. Strings can be empty.
An NFA always initiates a new process when encountering a lambda transition.
False. The NFA initiates a new process when it encounters a lambda transition only when it has no choice but to make the lambda transition.
The associated language to an NFA is nondeterministic. True or False?
False. The associated language to an NFA is regular.
What are the main topics of the "theory of computation?"
Formal languages, automata, computability, complexity
Every state of a DFA must have an outgoing transition for every symbol of alphabet. True or False?
True.
A path from a vertex to itself is called a cycle. True or False?
True. A cycle is defined as a path from a vertex to itself.
An edge from a vertex to itself is called a loop. True or False?
True. A loop is defined as an edge from a vertex to itself.
In formal languages, a string is a finite sequence of symbols. True or False?
True. A string is a finite (not infinite) sequence of symbols.
All non-regular languages are infinite. True or false?
True. All non-regular languages are infinite.
In formal languages, an alphabet is a nonempty and finite set of symbols. True or False?
True. An alphabet cannot be empty and cannot be infinite.
A function is called "Turing-computable" if there exists a TM that implements it. True or false?
True. If a TM exists for a function, that function is Turing-computable.
NFAs are interesting because their transition graphs are simpler than DFAs'. True or False?
True. NFAs have simpler transition graphs than DFAs
NPDAs halt when the conditions for the next transition are not satisfied. True or False?
True. NPDAs halt when there are no transitions (i.e. the transition conditions fail).
TMs are more powerful than NPDAs because they can accept more languages. True or false?
True. TMs are more powerful than NPDAs because they can accept more languages with their RAM
TMs halt when the condition(s) for the next transition is (are) not satisfied. True or false?
True. TMs halt when the conditions for the next transition are not satisfied.
The associated language to a DFA is regular. True or False?
True. The associated language to DFAs and NFAs are regular.
The input tape of DFAs is read-only. True or False?
True. The input tape of DFAs is read-only.
We need a new class of automata like NPDAs to accept more complex languages like ww^R. True or False?
True. ww^R cannot be done with DFAs and NFAs.
Let A = {0, 1} and B = {1, 2, 3}. A x B = ?
{ (0, 1), (0, 2), (0, 3), (1, 1), (1, 2), (1, 3) }
What is the power set of A = {0, 1}?
{ {}, {0}, {1}, {0, 1} }
Let L = {a^(n + 2)b^n : n >= 0}. Represent it by roster method (first four members)
{aa, aaab, aaaabb, aaaaabbb}
If L1 = {a, b} and L2 = {c, a, b}, then what would be L1L2?
{ac, aa, ab, bc, ba, bb}
Write the first 5 members of {1}*
{lambda, 1, 11, 111, 1111}
The size of the power set of A and its relationship to size of A
| 2^A | = 2^|A|
Let A = {823, 843, 833, 893, 833, 823, 893}. What is |A|?
|A| = 4. Duplicates are only counted once.
Y = {x : x in Z, x < 5, x > 1} (A) Y is not a set (B) Y = {2, 3, 4} (C) Y is infinite (D) None
(B) is correct since Z is set of all integers.
In formal languages, pick all true statements. (A) String can be infinite sequence of symbols (B) String must be finite sequence of symbols (C) String must be finite sequence of symbols but cannot be empty (D) None
(B). Strings cannot be infinite, but can be empty.
In what condition(s) does DFA reject string w? (A) Machine halts (B) Some symbols of w are not consumed (C) The machine halts in non-accepting state (D) B or C
(D). Choice (A) is not correct because a machine can halt in an accepting state and w is accepted.
If a set has 10 members, what would be the size of its power set?
2^10 = 1024
If A has 5 elements, then its power set has (A) 8 elements (B) 32 elements (C) 1 element (D) 16 elements
32 elements since 2^5 is 32
Pick all true statements: (A) DFAs must have one and only one "initial state" (B) DFAs may have several "accepting states" (C) DFAs must have at least one "accepting state" (D) None
A and B
Pick all sets that represents "empty set" (A) {x : x in U'} (B) {x : F} where F = logical "False" (C) {phi} (D) None
A and B are true. U represents the universal set. Thus, its complement is the empty set. Anything false in the description of set-builder results in the empty set.
Pick all required condition(s) that NPDAs need for transition: (A) Top of the stack (B) Input symbol (C) The string to be pushed (D) None
A and B. PDAs check the input symbol and top of the stack as the conditions for transition.
Pick all regular languages: (A) {a^n bb: n >= 0} (B) {ww: w in E*} (C) {a^n b^n: n <= 0} (D) None
A and C are regular languages. B is not because it requires storing string w.
Pick the condition(s) for a process of NPDAs that can reject a string. (A) halting while all input symbols are not consumed (B) halting while the stack is not empty (C) halting in a non-accepting state (D) None
A and C. NPDAs reject strings if they halt while input symbols are not consumed OR they halt in a non-accepting state OR they have not yet halted
Pick all condition(s) for one process of NPDAs to accept a string. (A) all input symbols are consumed (B) stack should be empty (C) halt in accepting state (D) None
A and C. The stack doesn't necessarily need to be empty for an NPDA to accept a string.
What is the definition of "formal language"
A formal language over alphabet E is any subset of E*
What is a total function?
A function that has all elements of its domain defined.
What is a partial function?
A function that has at least one element in the domain that is undefined.
Pick all true statements: (A) Short-circuit is the same as lambda transition (B) NFAs always initiate a process when they encounter short-circuit (C) The symbol lambda means empty string when we put it on edge of NFAs (D) None
A only. Not B because NFAs don't always initiate new process during lambda transition
Pick all true statements: (A). {} is a finite set. (B). {a, b, . . ., z} is an infinite set. (C). {phi} represents the empty set (D). None.
A only. Phi itself is already a set. A set consisting of another set is not empty.
In formal languages, pick all true statements. (A). aabba^0 = aabb (B). aabba^0 = lambda (C). (aabba)^0 = " " (D). A and C are correct.
A only. Think PEMDAS. Empty string is lambda not " ".
What is "computation"?
A sequence of configurations from when machine starts until it halts
What is a finite set?
A set whose cardinality can be expressed by a natural number.
What is an infinite set?
A set whose cardinality cannot be expressed by a natural number.
In formal languages, pick all true statements (A) aabba^0 = aabba (B) aabba^0 = lambda (C) (aabba)^0 = "" (D) None
D is true. Quotation marks do not mean lambda.
In what condition(s) DFAs accept string w? (A). The machine halts. (B). All symbols of w are consumed. (C). The machine halts in an accepting state. (D). B and C
D.
Pick all true statements: (A). A n B = A (B). A n U = phi (C). A n U = U (D). None.
D.
In what condition(s) does a process of an NFA reject a string w? (A) The machine does not halt (B) Some symbols of w are not consumed (C) The machine is in a non-accepting state. (D) A or B or C (E) A and B and C
D. A process of an NFA rejects a string as long as the machine does not halt, not all symbols are consumed, and the machine is not in an accepting state.
Pick all non-regular languages: (A) {a^n bb: n >= 0} (B) {a^n b^m: n >= 0, m >= 0} (C) {w u: w, u in E*} (D) None
D. All of the listed languages are regular.
In what condition(s) does a process of an NFA accept a string w? (A) The machine halts. (B) All symbols of w are consumed (C) A or B or E (D) A, B, and E (E) The machine is in an accepting state
D. All three conditions must be true.
Pick all valid strings over E = {a, b} (A) "aabb" (B) "babb" (C) bcbaba (D) None
D. Quotes are not part of strings
DFA stands for
Deterministic Finite Automata
In what condition(s) does an NFA halt? (A) All symbols are consumed (B) A and D (C) The machine is in a non-accepting state (D) It has zero transitions (E) A or D
E. When all symbols are consumed, the NFA has nowhere to go so it halts. When the NFA has zero transitions, it also has nowhere to go.
Every state of an NFA must have one and only one outgoing transition for every symbol of the alphabet. True or False?
False
Let L = {c, a, b}. What is L^2?
L^2 = {cc, ca, cb, ac, aa, ab, bc, ba, bb}
Let L = {lambda, 11, 1111}, L^R = ?
L^R = {lambda, 11, 1111}
What is the definition of regular languages?
Languages that DFAs and NFAs can accept/recognize
NPDA stands for
Nondeterministic Pushdown Automata
In formal languages, pick all true statements (A) Alphabet must be nonempty but can be infinite (B) Alphabet can be infinite, nonempty set of symbols (C) Alphabet must be finite set of symbols and can be empty (D) None
None
Pick all strings that are equal to abbbba: (A). (phi)abbbba (B). a(phi)bb(phi)bba (C). abbbba(phi) (D). None
None. Phi represents the empty set, not the empty string. The empty string is lambda.
Pick all valid strings over E = {a, b} (A). "aabb" (B). "babb" (C). bcbaba (D). None
None. Quotations should not be considered unless it's part of the alphabet.
Pick all regular languages: (A) {a^n bbw: n >= 0, w in E-star} (B) {a^n wb^n: n >= 10, w in E-star} (C) {ww: w in E-star} (D) None
Only A is correct. B and C are non-regular because you cannot construct a DFA/NFA for them. They require memory/counter
Pick all regular languages: (A) {1^m + 1^n = 1^(m + n): n >= 1, m >= 1} (B) {ww^R: w in E*} (C) {1^(2k): k >= 0} (D) None
Only C is correct. A and B are non-regular languages because you cannot construct a DFA/NFA for them. They require memory/counter
What is the definition of a universal set?
The set of all objects under consideration
What is the associated language of a DFA?
The set of all strings that the DFA can accept
When are two machines M1 and M2 equivalent?
When L(M1) = L(M2) When their associated languages are the same.