Question Bank

Rows per page: 1025100

Showing 101–125

Discrete Structures and Algorithms Computational Logic #13

To prove a goal GG when a disjunction ABA ∨ B is known:

assume AA and prove GG then assume BB and prove GG,

assume AA and prove GG,

assume ¬A¬A and prove BB and GG.

Discrete Structures and Algorithms Computational Logic #14

Let P,Q,RP, Q, R be propositional variables. Which of the following propositional formulas correspond to the boolean function with 3 arguments that returns T\mathbb{T} when its inputs represent the binary encoding of a prime number:

PQ¬RP ∧ Q ∧ ¬R

(¬PQ)(PR)(¬P ∧ Q) ∨ (P ∧ R)

(¬PQ¬R)(((¬PQ)P)R)(¬P ∧ Q ∧ ¬R) ∨ (((¬P ∧ Q) ∨ P) ∧ R)

((¬PQ)(P¬Q)(PQ))((¬P ∧ Q) ∨ (P ∧ ¬Q) ∨ (P ∧ Q)).

Discrete Structures and Algorithms Computational Logic #15

Consider the clause set {{¬P,¬Q,R},{P,¬Q,¬R},{¬P,R},{P,¬Q,R},{¬Q,¬R}}\{\{¬P, ¬Q, R\}, \{P, ¬Q, ¬R\}, \{¬P, R\}, \{P, ¬Q, R\}, \{¬Q, ¬R\}\} . The first step in running the Davis Putnam method is:

applying the splitting rule (using the literal ¬P)

applying the pure literal rule (where the pure literal is ¬Q)

applying the resolution rule

applying the one literal rule (using the last clause).

Discrete Structures and Algorithms Formal Languages and Automata Theory #1

Let Σ={a,b,c}Σ = \{a, b, c\}, G=(S,A,B,Σ,{SAAb,AaAB,BϵcB},S)G = ({S, A, B}, Σ, \{S → AAb, A → aA | B, B → ϵ | cB\}, S), and G1G_1 be the grammar equivalent with G but without ϵ-productions. Which of the following assertions are correct?

ϵL(G)ϵ ∈ L(G)

G1G_1 has 8 productions

G1G_1 has 5 productions

G1G_1 has 3 erasing nonterminals

G1G_1 has one erasing nonterminal

Discrete Structures and Algorithms Formal Languages and Automata Theory #2

Assume you have to build push-down automaton simulating a natural language processor recognizing numerical palindromes of even length. Which of the following grammars G = (VN, VT , S, P) help you building the solution:

VN={S},VT={0,...,9},S,P={S0S01S1...9S9ϵ}V_N = \{S\}, V_T = \{0, ..., 9\}, S, P = \{S → 0S0 | 1S1 | . . . | 9S9 | ϵ\}

VN={S},VT={0,...,9},S,P={S0S01S1...9S90...9}V_N = \{S\}, V_T = \{0, ..., 9\}, S, P = \{S → 0S0 | 1S1 | . . . | 9S9 | 0 | . . . | 9\}

VN={S},VT={0,...,9},S,P={S0S01S1...9S90...9ϵ}V_N = \{S\}, V_T = \{0, ..., 9\}, S, P = \{S → 0S0 | 1S1 | . . . | 9S9 | 0 | . . . | 9 | ϵ\}

Discrete Structures and Algorithms Formal Languages and Automata Theory #3

Consider the set of all strings of balanced parentheses of two types: round and square. An example of where these strings come from is as follows. If we take expressions in C, which use round parentheses for grouping and for arguments of function calls, and use square brackets for array indexes, and drop out everything but the parentheses, we get all strings of balanced parentheses of these two types. For example, f(a[i](b[i][j],c[g(x)]),d[i])f(a[i] ∗ (b[i][j], c[g(x)]), d[i]) becomes the balanced parentheses string ([]([][][()])[])([]([][][()])[]). A grammar G={VN,VT,S,P}G = \{V_N, V_T , S, P\} for generating the strings of round and squared parentheses that are balanced is:

VN={S},VT={(,),[,]},S,P={SSS[S](S)()[]}V_N = \{S\}, V_T = \{(, ), [, ]\}, S, P = \{S → SS | [S] | (S) | () | []\} (this should be correct)

VN={S},VT={(,),[,]},S,P={S(S)[S]()[]ϵ}V_N = \{S\}, V_T = \{(, ), [, ]\}, S, P = \{S → (S) | [S] | () | [] | ϵ\} (this answer is marked correct in the book and in here)

VN={S},VT={(,),[,]},S,P={SSS(S)[S]ϵ}V_N = \{S\}, V_T = \{(, ), [, ]\}, S, P = \{S → SS | (S)| | [S] | ϵ\} (and this should be correct)

Discrete Structures and Algorithms Formal Languages and Automata Theory #4

Which of the following sets of strings are not regular languages?

The set of bitstrings with equal number of 0s and 1s.

The set of decimal strings that represent prime numbers.

The set of bitstrings with more 1s than 0s.

Discrete Structures and Algorithms Formal Languages and Automata Theory #5

Let V={S,X,Y,Y1,Y2},Σ={a,b,c}V = \{S, X, Y, Y1, Y2\}, Σ = \{a, b, c\} and the grammar G=(V,Σ,P,S)G = (V, Σ, P, S) with P={SXY,XaXb,YZaYb,Zc2Zbϵ}P = \{S → X | Y, X → aX | b, Y → Z | aY b, Z → c^2Zb | ϵ\}. What is the language generated by G?

{anbn0}{amc2pbm+pm0}\{a^nb | n ≥ 0\} ∪ \{a^mc^{2p}b^{m+p} | m ≥ 0\}.

{anbn0}{am(c2)nbpm,n0,p=m+n}\{a^nb | n ≥ 0\} ∪ \{a^m(c^2)^nb^p | m, n ≥ 0, p = m + n\}.

{abnn0}{am(c2b)nbmm,n0}\{ab^n | n ≥ 0\} ∪ \{a^m(c^2b)^nb^m | m, n ≥ 0\}.

{a(c2b)mm0}\{a(c^2b)^m | m ≥ 0\}.

Discrete Structures and Algorithms Formal Languages and Automata Theory #6

Which of the following strings are accepted by the DFA with the transition diagram:

Bitstrings that end in 1.

Bitstrings with an equal number of occurrences of 01 and 10.

Bitstrings with more 1s than 0s.

Bitstrings with an equal number of occurrences of 0 and 1.

Bitstrings with at least one 1.

None.

Discrete Structures and Algorithms Formal Languages and Automata Theory #7

Let Σ={a,b,c}Σ = \{a, b, c\} and L be the complement of the language {ambcnmn}:L=Σ{ambcnmn}\{a^mbc^n | m ≥ n\}: L = Σ^∗ − \{a^mbc^n | m ≥ n\}. Is L a regular language?

No

Yes

Discrete Structures and Algorithms Formal Languages and Automata Theory #8

Let Σ = {a, b, c}. Which of the following languages is regular?

{ambncpmp0,n0}{apcmmp0}\{a^mb^nc^p | m ≥ p ≥ 0, n ≥ 0\} ∩ \{a^pc^m | m ≥ p ≥ 0\}.

{wΣ\{w ∈ Σ^∗ | #a(w)=_a(w) = #b(w)}_b(w)\}

{wΣ\{w ∈ Σ∗ | #a(w)_a(w) is even, and #b(w)_b(w) is odd}\}.

Discrete Structures and Algorithms Formal Languages and Automata Theory #9

Let Σ={a,b,c,d},Γ=Σ{}Σ = \{a, b, c, d\}, Γ = Σ∪\{⊥\}, and the NPDA M=({q0,q1,q2,q3,q4},Σ,Γ,δ,q0,,q4)M = (\{q0, q1, q2, q3, q4\},Σ, Γ, δ, q0,⊥, {q4}) with transition diagram:

{ambncpdqm,n,p,q1}\{a^mb^nc^pd^q | m, n, p, q ≥ 1\}.

{ambncndmm,n1}\{a^mb^nc^nd^m | m, n ≥ 1\}.

{ambmcndnm,n1}\{a^mb^mc^nd^n | m, n ≥ 1\}.

Discrete Structures and Algorithms Formal Languages and Automata Theory #10

Which of the following strings match the regular expression abb(abba)a^∗bb(ab|ba)^∗

abbabb

aabaaaba

abbaabba

bbbaabbbbaab

cbbcbb

bbababbabbbababbab

Discrete Structures and Algorithms Formal Languages and Automata Theory #11

Let L be the language generated by the grammar G=(VN,VT,S,P)G = (V_N, V_T , S, P) where
VN={S,A,B,C,X,Y,Z}V_N = \{S, A, B, C, X, Y, Z\},
VT={a,b,c}V_T = \{a, b, c\}, and
P={SϵAXBYCZ,XϵBYCZ,YϵAXCZ,ZϵAXBY,Aa,Bb,Cc}P = \{ S → ϵ | AX | BY | CZ, X → ϵ | BY | CZ, Y → ϵ | AX | CZ, Z → ϵ | AX | BY, A → a, B → b, C → c\}.
Is L a regular language?

Yes

No

Discrete Structures and Algorithms Formal Languages and Automata Theory #12

Let L be the language generated by the grammar G=(VN,VT,S,P)G = (V_N, V_T , S, P) where
VN={S,A,B,C,X,Y,Z}V_N = \{S, A, B, C, X, Y, Z\},
VT={a,b,c}V_T = \{a, b, c\}, and
P={SϵAXBYCZ,XϵBYCZ,YϵAXCZ,ZϵAXBY,Aa,Bb,Cc}P = \{ S → ϵ | AX | BY | CZ, X → ϵ | BY | CZ, Y → ϵ | AX | CZ, Z → ϵ | AX | BY, A → a, B → b, C → c\}. How many strings of length 4 does L contain?

16

24

32

81

243

Discrete Structures and Algorithms Formal Languages and Automata Theory #13

Let L be the language generated by the grammar
G=(VN,VT,S,P)G = (V_N, V_T , S, P) where
VN={S,A,B,C,X,Y,Z},VT={a,b,c}V_N = \{S, A, B, C, X, Y, Z\}, V_T = \{a, b, c\}, and
P={SϵAXBYCZ,XϵBYCZ,YϵAXCZ,ZϵAXBY,Aa,Bb,Cc}P = \{ S → ϵ | AX | BY | CZ, X → ϵ | BY | CZ, Y → ϵ | AX | CZ, Z → ϵ | AX | BY, A → a, B → b, C → c\}.
Which of the following statements is true?

(This question is also wrong)

L={wVTL = \{w ∈ V ^∗ _T | ww does not contain consecutive identical letters}\} (this should be the correct answer)

L={wVTL = \{w ∈ V ^∗ _T | ww contains identical consecutive letters}. (this is the correct answer in the book and also marked here as correct)

L={wVTL = \{w ∈ V ^∗ _T | ww contains the substring abc}abc \}.

L={λ}L = \{λ\}.

Discrete Structures and Algorithms Formal Languages and Automata Theory #14

Let L be the language generated by the grammar G=(VN,VT,S,P)G = (V_N, V_T , S, P) where
VN={S,A,B,C,X,Y,Z}V_N = \{S, A, B, C, X, Y, Z\},
VT={a,b,c}V_T = \{a, b, c\}, and
P={SϵAXBYCZ,XϵBYCZ,YϵAXCZ,ZϵAXBY,Aa,Bb,Cc}P = \{ S → ϵ | AX | BY | CZ, X → ϵ | BY | CZ, Y → ϵ | AX | CZ, Z → ϵ | AX | BY, A → a, B → b, C → c\}.
Let sns_n be the number of strings from LL with length nn. For every n > 1, the following recursive relation holds:

sn=2sn1s_n = 2 · s_{n−1}

sn=3sn1s_n = 3 · s_{n−1}

sn=sn1+2sn2s_n = s_{n−1} + 2 · s_{n−2}

sn=3sn1+sn2s_n = 3 s_{n−1} + s_{n−2}

Discrete Structures and Algorithms Graph Theory and Combinatorics #1

Which is the rank of the permutation ⟨4, 1, 6, 2, 3, 5⟩ in lexicographic order?

376

378

380

720

Discrete Structures and Algorithms Graph Theory and Combinatorics #2

A message is a sequence of two types of signals: of type A which last for 1 second and of type B which last for 2 seconds. E.g., the message ABAABABAAB lasts 7 seconds. How many different messages last 10 seconds?

68

32

89

144

Discrete Structures and Algorithms Graph Theory and Combinatorics #3

In how many ways can be colored the following configuration by using 2 colors: red and black?

64

48

128

36

Discrete Structures and Algorithms Graph Theory and Combinatorics #4

In how many ways can we split a group of 50 persons in 49 nonempty groups?

50

1225

49

2450

19600

Discrete Structures and Algorithms Graph Theory and Combinatorics #5

In how many ways can we choose 5 fruits from a market stall if on the stall there are: 5 apples, 5 pears and 5 apricots?

21

56

120

6

30

Discrete Structures and Algorithms Graph Theory and Combinatorics #6

Which of the following recurrence relations hold for any n>k>0n > k > 0?

(nk)=(n1k)+(n1k1)\binom{n}{k} = \binom{n-1}{k} + \binom{n-1}{k-1}

{nk}={n1k}+k{n1k1}\begin{Bmatrix} n \\ k \end{Bmatrix} = \begin{Bmatrix} n-1 \\ k \end{Bmatrix} + k \begin{Bmatrix} n-1 \\ k-1 \end{Bmatrix}

{nk}=k{n1k}+{n1k1}\begin{Bmatrix} n \\ k \end{Bmatrix} = k \cdot \begin{Bmatrix} n-1 \\ k \end{Bmatrix} + \begin{Bmatrix} n-1 \\ k-1 \end{Bmatrix}

[nk]=[n1k]+(n1)[n1k1]\begin{bmatrix} n \\ k \end{bmatrix} = \begin{bmatrix} n-1 \\ k \end{bmatrix} + (n-1) \cdot \begin{bmatrix} n-1 \\ k-1 \end{bmatrix}

Discrete Structures and Algorithms Graph Theory and Combinatorics #7

Which is the minimum weight spanning tree of the following connected graph? (hint: apply the
Kruskal algorithm)

43

40

36

41

Discrete Structures and Algorithms Graph Theory and Combinatorics #8

Which is the Prüfer sequence of the following tree?

8, 3, 4, 5, 7, 6, 1, 9, 10, 11, 2

3, 4, 5, 7, 6, 1, 8, 2, 10, 11

8, 11, 9, 6, 1, 8, 8, 2, 2

8, 11, 9, 6, 1, 8, 2, 2, 8