Documente Academic
Documente Profesional
Documente Cultură
You can now join our Facebook group for GATE CSE
discussions.
Let $A$ be array of $n$ integers, sorted so that $A[1] \leq A[2] \leq
\dots A[n]$. Suppose you are given a number $x$ and you wish to
find out if there exist indices $k, \: l$ such that $A[k]+A[l] = x$.
Selected Answer
Selected Answer
Option B) We can move from right to left, while keeping a note of
the maximum element so far (let's call it current_max).
Selected Answer
Since array is binary, the max sum will go until $n$ and so the sum
difference of the two arrays can vary between $-n$ and $n$. We
use array start to keep the starting index of each possible sum
(hence of size $2n+1$) and array end to keep the ending index
(these two arrays work like hash tables and since we have only
$2n+1$ possible keys, we can do a perfect hashing). So, our
required solution will be max(end[i]-start[i]) provided both are
assigned values.
}
if(savei >= 0)
{
printf("The largest span is from %d to %d\n", start[savei]+(savei != n), end[savei]);
//when sum zero is having the largest span, span starts from first element itself.
//Else, the span starts from the next element from which the span does not change
}
else
{
printf("No span\n");
}
}
A. 501
B. 1023
C. 2011
D. 10079
E. None of the above.
tifr2011 algorithms algorithm-design
Selected Answer
top
Selected Answer
(3) Dynamic
(A) All pairs shortest path
Programming
(4) Divide and and
(B) Quick Sort
Conquer
(C) Minimum weight
(1) Greedy
spanning tree
(D) Connected Components (2) Depth-First search
https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm#
https://en.wikipedia.org/wiki/Quicksort#Algorithm
https://en.wikipedia.org/wiki/Minimum_spanning_tree#Algorithms
https://en.wikipedia.org/wiki/Connected_component_(graph_theory
top
Match the following:
P. Prim's algorithm for minimum
i. Backtracking
spanning tree
Q. Floyd-Warshall algorithm for all ii. Greedy
pairs shortest paths method
iii. Dynamic
R. Mergesort
programming
iv. Divide and
S. Hamiltonian circuit
conquer
Selected Answer
Option C
top
Selected Answer
Answer: C
-- Rajarshi Sarkar (36.4k points)
16 votes
top
Selected Answer
Selected Answer
Selected Answer
Only B is false
If $T_1 = O(1)$, give the correct matching for the following pairs:
(M) $T_n = T_{n-1} + n$ (U) $T_n = O(n)$
(N) $T_n = T_{n/2} + n$ (V) $T_n = O(n \log n)$
(O) $T_n = T_{n/2} + n \log n$ (W) $T = O(n^2)$
(P) $T_n = T_{n-1} + \log n$ (X) $T_n = O(\log^2 n)$
(P) Like in (M), here we are adding the log of the first n natural
numbers. So,
$=\log(n!)$
$f(n) = 3n^{\sqrt{n}}$
$g(n) = 2^{\sqrt{n}{\log_{2}n}}$
$h(n) = n!$
A. $h(n)$ is $O(f(n))$
B. $h(n)$ is $O(g(n))$
C. $g(n)$ is not $O(f(n))$
D. $f(n)$ is $O(g(n))$
Selected Answer
$n = 256$ $n=65536$
$256!$ $65536!$
$= $=
$h(n) = n!$
O\left(\left(2^8\right)^{256}\right)$ O\left(\left(2^{16}\right)^{65536}\right)$
$=O\left(2^{2048}\right)$ $=O\left(2^{1M}\right)$
Case of h(n) is given only by an upper bound but factorial has
higher growth rate than exponential.
http://math.stackexchange.com/questions/351815/do-factorials-
really-grow-faster-than-exponential-functions
f(n) and g(n) are having same order of growth as f(n) is simply 3
g(n) (we can prove this by taking log also). So, (d) is correct and all
other choices are false.
1. $f(n) = 3n^{\sqrt{n}}$
2. $g(n) = 2^{\sqrt{n}{\log_{2}n}} = (2^{\log_{2}n})^\sqrt{n}
= (n^{\log_{2}2})^\sqrt{n} = n^{\sqrt{n}} $
3. $h(n) = n! = o(n^n)$
Let $f(n) = n^2 \log n$ and $g(n) = n(\log n)^{10}$ be two positive
functions of $n$. Which of the following statements is correct?
Selected Answer
http://cse.unl.edu/~choueiry/S06-235/files/Asymptotics-
HandoutNoNotes.pdf
Or
and
Option B.
$f(n)$ $g(n)$
$n = $10 \ast 2^{10} $2^{10}
2^{10}$ \ast 2^{10}$ \ast 10^{10}$
$n = $256 \ast 2^{256} $2^{256}
2^{256}$ \ast 2^{256}$ \ast 256^{10}$
B choice.
A. I and II
B. I and III
C. II and III
D. I, II, and III
gate2003 algorithms asymptotic-notations normal
Selected Answer
so TRUE
so TRUE
$2^{2n} = {2^n}^2$
so FALSE
Answer is (D)
h(n)=Ωf(n)
So d is false
-- Pooja Palod (34.3k points)
13 votes
A. $T(n)=O(n^2)$
C. $T(n)=\Omega(n^2)$
Selected Answer
Hence answer is C.
$f(n) = 2^n$
$g(n) = n!$
A. $f\left(n\right)=O\left(g\left(n\right)\right);
g\left(n\right)=O\left(h\left(n\right)\right)$
B. $f\left(n\right) = \Omega\left(g\left(n\right)\right); g(n) =
O\left(h\left(n\right)\right)$
C. $g\left(n\right) = O\left(f\left(n\right)\right);
h\left(n\right)=O\left(f\left(n\right)\right)$
D. $h\left(n\right)=O\left(f\left(n\right)\right); g\left(n\right) =
\Omega\left(f\left(n\right)\right)$
Selected Answer
answer = option D
So, growth rate is highest for $g(n)$ and lowest for $h(n)$. Option
D.
-- Arjun Suresh (346k points)
14 votes
a. $n^{1/3}$
b. $e^n$
c. $n^{7/4}$
d. $n \log^9n$
e. $1.0000001^n$
A. a, d, c, e, b
B. d, a, c, e, b
C. a, c, d, e, b
D. a, c, d, b, e
gate2008-it algorithms asymptotic-notations normal
Selected Answer
E<B
and
Thus A is correct.
-- Arjun Suresh (346k points)
27 votes
$f_1(n) = 2^n$
$f_2(n) = n^{3/2}$
$f_3(n) = n \log_2 n$
$f_4(n) = n^{\log_2 n}$
A. $f_3, f_2, f_4, f_1$
B. $f_3, f_2, f_1, f_4$
C. $f_2, f_3, f_1, f_4$
D. $f_2, f_3, f_4, f_1$
gate2011 algorithms asymptotic-notations normal
Selected Answer
[EDIT]
answer A
Let $W(n) $ and $A(n)$ denote respectively, the worst case and
average case running time of an algorithm executed on an input of
size $n$. Which of the following is ALWAYS TRUE?
Selected Answer
Worst case complexity can never be lower than the average case
complexity, but it can be higher. So, (C) is the answer.
$$A(n) = O(W(n)) $$
I. $\Theta(n^4)$
II. $\Theta(n^5)$
III. $O(n^5)$
IV. $\Omega(n^3)$
A. Only I
B. Only II
C. I or III or IV but not II
D. II or III or IV but not I
gate2015-3 algorithms asymptotic-notations normal
Selected Answer
Let $f(n) = n$ and $g(n) = n^{(1 + sin \: n)}$ where $n$ is a positive
integer. Which of the following statements is/are correct?
I. $f(n) = O(g(n))$
II. $f(n) = \Omega(g(n))$
A. Only I
B. Only II
C. Both I and II
D. Neither I nor II
gate2015-3 algorithms asymptotic-notations normal
Selected Answer
Since the value of $sin(n)$ will always range from $-1$ to $+1$,
hence $g(n)$ can take values $1$, $n$, $n^2$.
Selected Answer
$10$ - constant. Growth rate is $0$.
$10$,Constant
$\sqrt{n}$,Square root
$n$, polynomial
$\log_{2}n$, Logorithmic
$\frac{100}{n}$. Constant division by polynomial (clearly less
than constant for every value of n >100)
tifr2011 asymptotic-notations
Selected Answer
Since exponentials grow faster than polynomials, $h(n) > g(n)$ for
large $n$.
Selected Answer
Ans will be C
Take $n=2^{1024}$
Just one value is not enough to confirm growth rate. So, take $n =
1024$.
$n^{\frac{1}{3}}\approx 2^{3}$
So, as $n$ increases the gap between second and third function
increases and also the second function overtakes the first. So, $f1
< f2 < f3$.
A. $e^{n}/n$.
B. $e^{n-0.9 \log n}$.
C. $2^{n}$.
D. $\left(\log n\right)^{n-1}$.
E. None of the above.
tifr2014 algorithms asymptotic-notations
Selected Answer
$$\def\d{\displaystyle\,}
\begin{array}{l|ll}
a. & e^{n} / n & = \dfrac{e^{\d n}}{e^{\d(\ln n)}} & = e^{\d (n - \ln
n)}\\[1em]
b. & e^{n - 0.9 \ln n} &&= e^{\d (n - 0.9 \ln n)}\\[1em]
c. & 2^n &= \left (e^{\d\ln 2} \right )^{\d n} &= e^{\d (n \ln 2)}\\[1em]
d. & (\ln n)^{n-1} &= \left (e^{\d\ln \ln n} \right )^{\d n-1} &= e^{\d (n
\ln \ln n - \ln\ln n)}
\end{array}$$
This implies that $e^{\d (n \ln \ln n - \ln\ln n)}$ grows the fastest,
and hence, $(\ln n)^{n-1}$ grows the fastest.
tifr2016 asymptotic-notations
Selected Answer
Let $N = 2^{256}$
$(\log \log N)! = 8!$
$(\log \log N)^{\log N} = (8)^{256} = 2^{768}$
$(\log \log N)^{\log\log \log N} = 8^{3}=512$
$(\log N)^{\log\log N} = (256)^{8}=2^{64}$
$2^{\sqrt{\log \log N}} = 2^{2\sqrt 2}$
Let $N = 2^{16}$
A. $0$
B. $1$
C. $n!$
D. $\frac{1} {n+1} .^{2n}C_n$
gate2011 bst normal
Selected Answer
Here we are already given one such structure therefore only $1$
tree possible.
Which of the following is valid for $2 \leq i \leq n$, and $a_i \leq j
\leq W$?
Selected Answer
Case (2) Or we do not consider the item(in this case the element
ai) in which case we only consider the solution to previous
subproblem.
which is A[i-1][J]
Now Since here in the given question we are given a boolean array
X[n][W+1]
(1) EIther we can ignore it and still get our possible sum
Which is X[i-1][j]
OR
(2) We could include element ai and then get our required sum.
Which is X[i-1][j-ai]
And finally, to get X[i][j], we take logical or of the above two cases.
Reference :
A. $X[1, W]$
B. $X[n, 0]$
C. $X[n, W]$
D. $X[n-1, n]$
gate2008 algorithms normal dynamic-programming
Selected Answer
ANS is C.
If LAST ROW and LAST COLUMN entry is $1$, then there exists
subset whose elements sum to $W$.
Selected Answer
Answer is C.
Selected Answer
else
L[i][j] = max(L[i-1][j], L[i][j-1]);
}
}
A. $max(Y, a_0+Y)$
B. $max(Y, a_0+Y/2)$
C. $max(Y, a_0 +2Y)$
D. $a_0+Y/2$
gate2010 algorithms dynamic-programming normal
Selected Answer
$$\begin{align}
S &= \langle a_0, S_1 \rangle\\
S_1 &= \langle a_1, a_2, a_3 \ldots a_{n-1} \rangle
\end{align}$$
Two possible cases arise:
1. $a_0$ is included in the max weight subsequence of $S$:
= 20+20+8 = 48
X is 54, a0 is 30 and Y is 48
Selected Answer
http://stackoverflow.com/questions/1065433/what-is-dynamic-
programming
And the algorithm is not divide and conquer as we are not dividing
the problem and then merging the solution as in the case of merge
sort (where merge is the conquer step).
https://en.wikipedia.org/wiki/Divide_and_conquer_algorithms
If $p=10, q=100, r=20, s=5$ and $t=80$, then the minimum number
of scalar multiplications needed is
A. 248000
B. 44000
C. 19000
D. 25000
gate2011 algorithms dynamic-programming normal
Selected Answer
Answer is C.
$\text{ Ordering: }\\ \text{ First Multiply } M_2 \times M_3. \text{
This requires 100*20*5 multiplications.}$ $\text{ Then Multiply }
M_1 \times (M_2 \times M_3). \text{ This requires 10*100*5
multiplications. }$ $\text{ Then Multiply } (M_1 \times (M_2 \times
M_3)) \times M_4. \text{ This requires 10*5*8 multiplications. }$
$\text{ Total 19000 Multiplications.}$
The last 2 are having $qt$ terms which are the highest terms by far
and hence we can avoid them from consideration $qt = 8000$
multiplied by one other term would be larger than any value in
choice. So, just find the value of first 3 terms.
1. $pqr + rst + prt = 20000 + 8000 + 16000 = 44000$
2. $qrs + pqs + pst = 10000 + 5000 + 4000 = 19000$ - smallest
value in choice, we can stop here.
3. $pqr + prs + pst$
So, we can fill the following table starting with the diagonals and
moving upward diagonally. Here $k < j$ but $\geq i.$
j=1 j=2 j=3 j=4
$\min(18000+ p_0p_1p_4,
$\min(10000+p_0p_1p_3,
$p_0p_1p_2 = \\20000+8000+p_0+p_2+p_4,
i=1 0 \\20000+p_0+p_2p_3)
\\ 20000$ \\15000+p_0p_3p_4) =
\\=15000$
\\19000$
$\min(10000 + p_2p_3p_4),
i=2 0 $p_1p_2p_3 = 10000$
\\p_1p_3p_4) = 18000$
i=3 0 $p_2p_3p_4 = 8000$
i=4 0
Selected Answer
34
"qprr"
"Pqrr"
"qpqr"
In first string
If we want to get 4 as max len den lcs should end with either "rr"
or "qr"
"qpqr"
"qqrr"
"pqrr"
"qprr"
Suppose you want to move from $0$ to $100$ on the number line. In
each step, you either move right by a unit distance or you take a
shortcut. A shortcut is simply a pre-specified pair of integers $i,\:j
\:\text{with}\: i <j$. Given a shortcut $i,j$ if you are at position $i$ on
the number line, you may directly move to $j$. Suppose $T(k)$
denotes the smallest number of steps needed to move from $k$ to
$100$. Suppose further that there is at most $1$ shortcut involving
any number, and in particular from $9$ there is a shortcut to $15$.
Let $y$ and $z$ be such that $T(9) = 1 + \min(T(y),T(z))$. Then the
value of the product $yz$ is _____.
Selected Answer
There are only two such values where we can reach from $9$ , one
is simple step to right on number line , i.e $10$ and another is $15$
(given shortcut)
A. Greedy paradigm.
B. Divide-and-conquer paradigm.
C. Dynamic Programming paradigm.
D. Neither Greedy nor Divide-and-Conquer nor Dynamic
Programming paradigm.
Selected Answer
Selected Answer
Answer is 1500 !
Answer is 1500.
Selected Answer
Blanks spaces are to be filled with $b$, $c$, $d$, $e$ such that $b$
comes before $c$, and $d$ comes before $e$..
Number of ways to arrange $b$, $c$, $d$, $e$ such that
$b$ comes before $c$ and $d$ comes before $e$. will be =
$4!/(2!*2!) = 6$
In topological sorting all nodes are like tasks and edges show the
dependency among the tasks.
C. Given the prefix and postfix walks over a binary tree, the binary
tree cannot be uniquely constructed.
Selected Answer
Answer: B
A. True.
B. False.
C. True.
D. True.
Selected Answer
Why so ?
-for REC we have Halting Turing machine.
Enumeration procedure for REC-
I can give each string in HTM and wait for some time, either HTM
will accept it or reject it. If accept it then print string and move on
to next string, if reject then move to next string without printing.
Of course i can give strings in lexicographic order and this
procedure will enumerate in the same order in which i give input.
Can we use same procedure for RE ? (again RE means "RE but not
REC")
NO!, this procedure won't work for RE, Why?
I have one idea, not sure if this works or not, Let's see-
-I give all strings to TM simultaneously, and as soon as one string
is accepted by TM, It will print.
Say, 1st string is taking 500 steps and 2nd string is taking 5 steps
then after 5 steps it will print 2nd string, and after 500 steps it will
print 1st string.
Seems like it will work and will enumerate strings of RE language,
but How can i give all strings simultaneously?
-If i modify the procedure mentioned above then it will pretend like
all strings are given simultaneously.
$\tilde{M}$ genrates first string $w_1$
M executes first step on $w_1$
$\tilde{M}$ genrates second string $w_2$
M executes first step on $w_2$
Second step on $w_1$
$\tilde{M}$ genrates third string $w_3$
M executes first step on $w_3$
M executes second step on $w_2$
Third step on $w_1$
And So on....
Selected Answer
L1 being recursive, we have a TM M for L1 which accepts all words
in L1 and rejects all words in L1'. So, this TM also works for L1' by
changing the accept and reject states. Thus L1' is recursive.
A. regular
B. context-free
C. context-sensitive
D. recursive
gate2008 theory-of-computation easy isro2016 recursive-and-recursively-enumerable-languages
Selected Answer
(D) recursive
Selected Answer
Selected Answer
Selected Answer
Selected Answer
So, the first 3 options are correct. Option (D) is false, as B is not
recursively enumerable doesn't guarantee A is not recursively
enumerable.
For any two languages $L_{1}$ and $L_{2}$ such that $L_{1}$ is
context-free and $L_{2}$ is recursively enumerable but not recursive,
which of the following is/are necessarily true?
A. I only
B. III only
C. III and IV only
D. I and IV only
gate2015-1 theory-of-computation recursive-and-recursively-enumerable-languages normal
Selected Answer
D.
Selected Answer
B) The complement of every recursively enumerable sets is
recursively enumerable.
because RE language are not closed under complement.
-- Umang Raman (16k points)
9 votes
Selected Answer
e. False. NOT halt on empty, yes ans not possible. Only no ans is
there. So it will be non r.e. while its complement is r.e. but not
recursive.
(A) r(*) = r*
(C) (r + s)* = r* + s*
(D) r*s* = r* + s*
gate1992 theory-of-computation regular-expressions
Selected Answer
B is only correct
why not A?
Selected Answer
Set of all binary strings having two consecutive $0$s and two
consecutive $1$s
$(0+1)^*00(0+1)^*11(0+1)^*+(0+1)^*11(0+1)^*00(0+1)^*$
$(0+1)^*(00(0+1)^*11 +11(0+1)^*00)(0+1)^*$
So Option B is Ans
Neither they said Both are immediate nor they give a predefined
order, so it should be as above
Give a regular expression over the alphabet $\{0, 1\}$ to denote the
set of proper non-null substrings of the string $0110$.
gate1987 theory-of-computation regular-expressions
Choose the correct alternatives (more than one may be correct) and
write the corresponding letters only.
Selected Answer
ans is A and C
c) Same as option A.
02. Choose the correct alternatives (more than one may be correct)
and write the corresponding letters only:
(b) $(r^*s^*)=(r+s)^*$
Selected Answer
(d) LHS contains all strings where after an $s$, no $r$ comes. RHS
contains all strings of either $r$ or $s$ but no combination of
them. So, RHS $\subset$ LHS.
-- Arjun Suresh (346k points)
25 votes
Selected Answer
$L=0^*1^*$
A. $(L + D)^+$
B. $(L.D)^*$
C. $L(L + D)^*$
D. $L(L.D)^*$
gate1995 theory-of-computation regular-expressions easy isro2017
Selected Answer
It is C
gate1996 theory-of-computation regular-expressions easy
Selected Answer
C.
A is false because you cannot have single 0 in ii). same for option
B. In D you are forced to have single 0 in iv) whereas not in iii).
-- Gate Keeda (19.8k points)
20 votes
(a) $0^*(1+0)^*$
(b) $0^*1010^*$
(c) $0^*1^*01^*$
(d) $0^*(10+1)^*$
gate1997 theory-of-computation regular-expressions normal
Selected Answer
(a) 110*(0 + 1)
(b) 1(0 + 1)*101
(c) (10)*(01)*(00 + 11)*
(d) (00 + (11)*0)*
gate1998 theory-of-computation regular-expressions easy
Selected Answer
(a) $A \subset B$
(b) $B \subset A$
(c) $A$ and $B$ are incomparable
(d) $A = B$
gate1998 theory-of-computation regular-expressions normal
Selected Answer
Give a regular expression for the set of binary strings where every 0
is immediately followed by exactly $k$ 1's and preceded by at least
$k$ 1’s ($k$ is a fixed integer)
gate1998 theory-of-computation regular-expressions easy
Selected Answer
$1^*1^k(01^k)^* + 1^*$
PS: The question assumes a fixed $k$, and we should expand the
given expression for that $k$ to get a valid regular expression.
-- Akash (49.5k points)
19 votes
Selected Answer
A. $(1^*0)^*1^*$
B. $0+(0+10)^*$
C. $(0+1)^*10(0+1)^*$
D. None of the above
gate2003 theory-of-computation regular-expressions easy
Selected Answer
(A) is the answer. Both (A) and the given expression generates all
strings over $\Sigma$.
A. (a* + b* + c*)*
B. (a*b*c*)*
C. ((ab)* + c*)*
D. (a*b* + c*)*
gate2004-it theory-of-computation regular-expressions normal
Selected Answer
Selected Answer
(B). Infinite set (because of *) of finite strings. A string is defined
as a FINITE sequence of characters and hence can never be
infinite.
Selected Answer
Well A is answer
s1 is start state
s2 = s1a = (a+b)*a
Which one of the regular expressions given below defines the same
language as defined by the regular expression R?
Selected Answer
R = (a+b)*(aa+bb)(a+b)*
having NFA
Equivalent DFA :
which is equivalent Transition graph [ by removing transition from
q1 to q2 and q2 to q1 but does not effect on language ..be careful ]
so option C is answer.
A. (0 + 1) * 11(0 + 1) *
B. 0 * 110 *
C. 0 * 10 * 10 *
D. (0 + 1) * 1(0 + 1) * 1 (0 + 1) *
gate2008-it theory-of-computation regular-expressions easy
Selected Answer
Let $L=\{ w \in \:(0+1)^* \mid w\text{ has even number of }1s \}$.
i.e., $L$ is the set of all the bit strings with even numbers of $1$s.
Which one of the regular expressions below represents $L$?
A. $(0^*10^*1)^*$
B. $0^*(10^*10^*)^*$
C. $0^*(10^*1)^*0^*$
D. $0^*1(10^*1)^*10^*$
gate2010 theory-of-computation regular-expressions normal
Selected Answer
(C) - between the second and third 1's a 0 is not allowed (eg,
011011)
I. $0^*1(1+00^*1)^* $
II. $0^*1^*1+11^*0^*1 $
III. $(0+1)^*1$
A. I and II only
B. I and III only
C. II and III only
D. I, II and III
gate2014-1 theory-of-computation regular-expressions finite-automata easy
Selected Answer
The length of the shortest string NOT in the language (over $\Sigma
= \{a, b\})$ of the following regular expression is _______.
$$a^*b^*(ba)^*a^*$$
gate2014-3 theory-of-computation regular-expressions numerical-answers easy
Selected Answer
R = a*b*(ba)*a*
for finding shortest string that is not in language it is better to look
strings of length 0, then of length 1 and so on
length0 { ∊} is in L
length1 {a, b} all belong to L
length2 {aa, ab, ba, bb} all belong to L
length 3 {aaa, aab, aba, abb, baa, bab, bba, bbb} bab does not belong to
L
Selected Answer
Selected Answer
$C \rightarrow c$
gate1990 descriptive theory-of-computation regular-languages regular-grammar grammar
Selected Answer
Given grammar
G: S→aB
B→bC
C→xB | c
B → bxB | bc
S → aB
S = a(bx)*bc
Hence the corresponding regular expression is : a(bx)*bc
S → bS | aA | ϵ
A → aS | bA
Selected Answer
Option A is correct.
So, here
First ,Convert the Given Right Linear Regula Grammar into DFA.
There are two states named S and A.(As shown in pragy's ans)
So option A is Ans.
$X_0 = 1 X_1$
A. 10(0*+(10)*)1
B. 10(0*+(10)*)*1
C. 1(0+10)*1
D. 10(0+10)*1 +110(0+10)*1
gate2015-2 theory-of-computation regular-grammar normal
Selected Answer
Proof :
R= PR+ Q
= PPR+PQ+Q
= PPPR+PPQ+PQ+Q
or Another way
R=PR+Q
= P(P*Q) + Q (by putting R = P*Q)
So Equation is Proved .
X0 = 1 X1 ( Equation 1)
X0 =1(0+10)*1 option C
Let $R_{1}$ and $R_{2}$ be regular sets defined over the alphabet
$\Sigma$ Then:
Selected Answer
1. Intersection
2. Union
3. Complement
4. Kleen-Closure
-- pC (24.4k points)
14 votes
Selected Answer
(b), (c) and (d) are true. But the strongest answer would be (d) a
regular language. It is trivial to say that a finite set of strings (finite
language) can be accepted using a finite set of states. And regular
language context-free context-sensitive Turing recognizable,
would imply that regular language is the strongest answer.
Selected Answer
Selected Answer
Selected Answer
a. Given that $A$ is regular and $(A \cup B)$ is regular, does it
follow that $B$ is necessarily regular? Justify your answer.
b. Given two finite automata $M1, M2$, outline an algorithm to
decide if $L(M1) \subset L(M2)$. (note: strict subset)
Selected Answer
draw a DFA using M1 and M2 where start state is, say, p0q0
(where p0 is start state in M1 and q0 is start state in M2)
if L(M1) ⊆ L (M2)
Then final state of M1 will come together with final state of M2,
while Final state of M2 can come alone.
Selected Answer
Because if we draw the minimal dfa for each of them, we will get
two states each.
Whereas, {an| n>=0} requires only one state.
Selected Answer
DFA For S1 :
Till 1 push in stack after that pop from stack for every 0.
-- Anirudh Singh (60.4k points)
11 votes
A. Only L1 and L2
B. Only L2, L3 and L4
C. Only L3 and L4
D. Only L3
gate2001 theory-of-computation normal regular-languages
Selected Answer
L1={ww∣w∈{a,b}∗} CSL
If s is a string over (0+1)* then let n0(s) denote the number of 0’s
in s and n1(s) the number of 1’s in s. Which one of the following
languages is not regular?
Selected Answer
A. There are only finite $3$ digit primes. Let the largest of them be
$X$. Now we need $X+2$ states in our DFA (including one for
$count =0$ and one for $count > X$). We do not need a change of
state for any $1$.
1. $\#0 - \#1 = 0$
2. $\#0 - \#1 = 1$
3. $\#0 - \#1 = 2$
4. $\#0 - \#1 = -1$
5. $\#0 - \#1 = -2$
$\#0 - \#1 = 1$
$\#0 - \#1 = 2$
$\#0 - \#1 = 3$
$\#0 - \#1 = 4$
$\#0 - \#1 = 5$
$\vdots$
$\#0 - \#1 = 1000$
$\vdots$
Selected Answer
A. Both I and IV
B. Only I
C. Only IV
D. Both II and III
gate2006-it theory-of-computation normal regular-languages
Selected Answer
refer
https://gateoverflow.in/3637/gate2006-it_81
-- Praveen Saini (55.2k points)
9 votes
a. Both I and IV
b. Only 1
c. Only IV
d. Both II and III
A. $(a + b)^*$
B. $\{ϵ, a, ab, bab\}$
C. $(ab)^*$
D. $\{a^nb^n \mid n \geq 0\}$
gate2006-it theory-of-computation normal regular-languages
Selected Answer
http://www.cs.odu.edu/~toida/nerzic/390teched/regular/reg-
lang/non-regularity.html [example 2]
http://www.public.asu.edu/~ccolbou/src/355hw2sols09.pdf [2(a)]
http://www.public.asu.edu/~ccolbou/src/355hw2sols09.pdf [2(b)]
https://www.complang.tuwien.ac.at/lkovacs/ATCSHW/hw4-sol.pdf
[4.2(a)]
A is answer.
note : for option B L = {ϵ, a, ab, bab} , Repeat(L) = { ϵ, aa,abab, babbab} is regular
C.suffix (L) = {v | ∃u uv ∊ L}
So option A is Ans
Selected Answer
A. CFL
B. CFL
D. CFL
http://gatecse.in/wiki/Identify_the_class_of_the_language
Selected Answer
If we take a CFL which is not regular, and takes union with its
complement (complement of a CFL which is not regular won't be
regular as regular is closed under complement), we
get $\Sigma^*$ which is regular. So, (C) is false.
So, D is false.
L1 = {0m1n | 0 ≤ m ≤ n ≤ 10000}
L2 = {w | w reads the same forward and backward}
L3 = {w ∊ {0, 1} * | w contains an even number of 0's and an even
number of 1's}
A. L2 and L3 only
B. L1 and L2 only
C. L3 only
D. L2 only
Selected Answer
L3 is also regular.. we can make DFA for L3.. states will represent
mod 2 for 0 and mod 2 for 1, which is finite
so option (d)
-- Vicky Bajoria (5.2k points)
20 votes
A. I and IV only
B. I and III only
C. I only
D. IV only
Selected Answer
Answer is A.
(A) $P \cap Q$
(B) $P-Q$
(C) $\Sigma^*-P$
(D) $\Sigma^*-Q$
Selected Answer
1. $ abaabaaabaa$
2. $ aaaabaaaa$
3. $ baaaaabaaaab$
4. $ baaaaabaa$
(A) 1, 2 and 3
(B) 2, 3 and 4
(C) 1, 2 and 4
(D) 1, 3 and 4
Selected Answer
L = {ab,aa,baa}
1. abaabaaabaa = ab aa baa ab aa belong to L*
(combinations of strings in L )
2. aaaabaaaa = aa aa baa aa belong to L*
3. baaaaabaaaab = baa aa ab aa aa b does not belong to L*
4. baaaaabaa = baa aa ab aa belong to L*
Consider the languages $L_1 = \phi$ and $L_2 = \{a\}$. Which one
of the following represents $L_1 {L_2}^* \cup {L_1}^*$ ?
(A) $\{\epsilon\}$
(B) $\phi$
(C) $a^*$
Selected Answer
Concatenation of empty language with any language will give the empty
language and ${L_1}^ * = \phi^* = \epsilon$.
Therefore,
$L_1L_2^* \cup L_1^* $
$=\phi.(L_2)^* \cup \phi^ *$
$= \phi \cup \{\epsilon\} \left(\because \phi \text{ concatenated
with anything is } \phi \text{ and }\phi^* = \{\epsilon\} \right) $
$= \{\epsilon \} $.
Selected Answer
(A) is CFL and (B) and (D) are CSL. (C) is regular and regular
expression for (C) would be $$a^*b(a^*ba^*ba^*b)^+a^*$$
-- Arjun Suresh (346k points)
19 votes
A. Only I
B. Only II
C. Both I and II
D. Neither I nor II
gate2014-2 theory-of-computation normal regular-languages
Selected Answer
Option A.
$L_1 = \{ \varepsilon, a, aa, aaa, aaaa, \ldots \}$
$\begin{align}
L_1 \cdot L_2 &= \left \{ \begin{array}{c} \varepsilon , \\ a, &b,\\ aa,
&ab, &bb\\ aaa, &aab, &abb, &bbb,\\ aaaa, &aaab, &aabb, &abbb,
&bbbb, & \ldots \end{array}\right \}\\[1em]
L_1 \cdot L_2 &= a^*b^*
\end{align}$
(Also, since both $L_1$ and $L_2$ are Regular, their concatenation
has to be Regular since Regular languages are closed under
concatenation)
That was just an intuitive explanation. Now I say that L contains all
binary strings starting with 11. Yes, if a binary string starts with 11,
it can never have more no. of 011 than 110.
$L_1: \left\{ wxw^R \mid w, x \in \{a, b\} ^* \text{ and } |w|, |x| >
0\right\}, w^R \text{ is the reverse of string } w$
$L_2: \left\{ a^nb^m \mid m \neq n \text { and } m, n \geq 0 \right\}$
Selected Answer
Ans A.
L1: all strings of length 3 or more with same start and end letter-
because everything in middle can be consumed by x as per the
definition of L.
L2: We need to compare number of a's and b's and these are not
bounded. So, we need at least a DPDA.
Selected Answer
Answer is C
$S_1\rightarrow aS_1b|\epsilon$
$S_2\rightarrow abS_2|\epsilon$
Let $L$ and $L'$ be languages over the alphabet $\Sigma $. The left
quotient of $L$ by $L'$ is
Selected Answer
A) False because - L = a*b*, L' = a^nb^n Here L/L' = a*. L/L' is regular,
but L' is not.
C) False L' = Empty set. Then L/L' is Empty set whatever L is. Here L
can be say a^nb^n. See defination of L/L' to see why L/L' should be
empty set.
Answer :- B.
-- Akash (49.5k points)
8 votes
Selected Answer 2
L = { 0^ m2 : m>= 3}
0120 : 016 016 016 09 09 09 09 09 09 09 09
0121 : 016 016 016016016016025
0122 : 016 016 09 09 09 09 09 09 09 09 09 09
0123 : 016 016 016 025 025 025
0125 :025 025 025025 025
0126 : 018018018018018018018 {018 can be generated as 09 09 }
0127 : 016 016 016 016 09 09 09 09 09 09 09
0128 : 016 016 016 016 016 016 016 016
Selected Answer
i) False
Regular Languages are not closed under Infinite Union and
Intersection
For example :
${ab} \cup {aabb} \cup {aaabbb} \cup {aaaabbbb} \cup \dots$
$= (L1' \cup L2' \cup L3' \cup L4' \cup \dots)'$
ii) False.
$a^*b^*$ is regular
$a^*$ is regular
iii) False
tifr2015 regular-languages
Selected Answer
$L_1$ is non-regular.
(It seems CFL to me as I think it can be implement with the help of PDA , as stack
can ensure $(m=n \vee n = p)$ and we can also ensure $(m+n+p \geq 10)$ with
minimum states changes along with transitions. )
$L_2$ is actually {$c^p$ | $p \leq 10$} $\cup$ {$abc^p$ | $p \leq 8$} $\cup$ {$a^2b^2c^p$ | $p
\leq 6$}$\cup$ {$a^3b^3c^p$ | $p \leq 4$} $\cup${$a^4b^4c^p$ | $p \leq 2 $}
$\cup${$a^5b^5$}$\cup$ {$a^p$ | $p\leq 10$} $\cup$ {$a^pbc$ | $p\leq 8$}
$\cup$ {$a^pb^2c^2$ | $p\leq 6$} $\cup$ {$a^pb^3c^3$ | $p\leq 4$} $\cup$ {$a^pb^4c^4$ |
$p\leq 2$} $\cup$ {$b^5c^5$ | $p\leq 10$}
$X$: Given a Turing machine $M$ over $\Sigma$ and any word $w
\in \Sigma$, does $M$ loop forever on $w$?
Selected Answer
Selected Answer
(a) M erases its input w and simulate the moves of M' on x. Thus if
M' halts on x, M accepts any input ($\Sigma^*$) and if M' doesn't
halt on x, M accepts no string ($\phi$)
(c) M halting on all inputs w is the key property relating to M' which
is halting on a given input x
-- Arjun Suresh (346k points)
4 votes
A single tape Turing Machine M has two states q0 and q1, of which
q0 is the starting state. The tape alphabet of M is {0, 1, B} and its
input alphabet is {0, 1}. The symbol B is the blank symbol used to
indicate end of an input string. The transition function of M is
described in the following table.
0 1 B
q0 q1, 1, R q1, 1, R Halt
q1 q1, 1, R q0, 1, L q0, B, L
The table is interpreted as illustrated below.
Selected Answer
Selected Answer
Both $L$ and $Lʼ$ are undecidable and not even semi-decidable
(not recursively-enumerable). Because halting problem can be
solved with both $L$ and $Lʼ$.
PS: If the bit part of the triplet is absent then $L_0$ is halting
problem and $L_1$ is its complement and $L_0 \cup L_1 =
\Sigma^*$, which is regular. Lets see how it happens.
Let the alphabet set be $\{0,1\}$. Now for any string like
$0010101$ there are only two options- belong to $L$ or belong to
$L'$ as this is what complement says. Now, lets take the case for
$L_0$ and a string $001\dots10-01-1$, ("-" shown for notation
purpose only) where the first component describes a TM $M$
followed by input "$w = 01$" and last bit "1". Now suppose $M$
halts on "01". Still the given input is not in $L_0$ as the last bit is
"1" and not "0" as required by $L_0$. So, this input must be in
$L_0'$. But since $M$ halts on $w$, this input is not in $L_1$
either. Similarly, we can get an infinite set of strings which does not
belong to both $L_0$ and $L_1$ and this makes their union not
$\Sigma^*$ but an irregular (not r.e. as proved earlier) set. If the
last bit is removed from the definition of $L_0$ and $L_1$, then any
string should be present in either $L_0$ or $L_1$ and their union
would be $\Sigma^*$.
Selected Answer
$S_1$ is TRUE.
$S_2$ is TRUE.
PS: For the second part, the given construction can fail if $L_1$
happens to be a finite language (more specifically if $L_1$ is
empty). But all finite languages are anyway decidable.
-- Arjun Suresh (346k points)
23 votes
Selected Answer
There are only a finite number of strings of length 2014. So, we can
give all those strings to TM simulating each string for 1 step, then
2 step and so on (dovetailing), and if the TM accepts any of them
("yes" case of TM), we can say "yes". So, L is recursively
enumerable.
http://gatecse.in/wiki/Rice%27s_Theorem_with_Examples
Selected Answer
$L_3$ is not recursive as it asks if $L(M)$ contains $\epsilon$
which is a non-trivial property of r.e. languages and hence
undecidable as per Rice's theorem.
$L_1$ and $L_2$ are slightly trickier as these are not describing
properties of recursively enumerable languages, but rather of
Turing machines. So, we can see if there is some procedure for
deciding these.
⟹ Length of input string is less than 2016. (If i can decide for
these strings then L2 is Recursive otherwise not Recursive)
And there are finite strings having length less than 2016.
Now my task reduces to : "Take each string in this finite set and
run M for finite number of steps"
(If we can decide for all inputs then we can also decide for some
inputs therefore L1 is also recursive (Reduction), but we can think
of L1 as an independent problem)
L1, L2 Recursive
C is answer.