Professional Documents
Culture Documents
1
www.gategenie.com CS GATE 2004 with GateGenie Solutions
What is the height if the binary search tree ( the height is the
maximum distance of a leaf node from the root)
(1) 2 (2) 3 (3) 4 (4) 6
Answer: (2)
Explanation:
2
www.gategenie.com CS GATE 2004 with GateGenie Solutions
1
\
3
\
5
After insertion of 15:
10
/ \
1 15
\
3
\
5
3
www.gategenie.com CS GATE 2004 with GateGenie Solutions
1 15
| |
|-----| |-----|
3 12 16
|
|------|
5
The height of the tree is the distance from the root(10) to the
node at the bottom of the tree (5 in this case). Thus height is
3.
Answer: (2)
Explanation:
Of the data structures given in the choices, only Stack is a LIFO
(Last In First Out) structure. The problem of verifying balanced
parentheses requires checking whether each left parenthesis has
a right parenthesis.
7. Given the following input 4322, 1334, 1471, 9679, 1989, 6171, 6173, 4199
and the hash function x%10, which of the following statements
are true?
4
www.gategenie.com CS GATE 2004 with GateGenie Solutions
5
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Answer: (3)
Explanation: The linker resolves the references to external
symbols using symbol table information from the object files.
10. Consider the grammar rule E → E1 − E2 for arithmetic ex-
pressions. The code generated is targeted to a CPU having a
single user register. The subtraction operation requires the first
operand to be in the register. If E1 and E2 do not have any com-
mon subexpression, in order to get the shortest possible code
(1) E1 should be evaluated first
(2) E2 should be evaluated first
(3) Evaluation of E1 and E2 should necessarily be interleaved
(4) Order of evaluation of E1 and E2 is of no consequence
Answer: (2)
Explanation: If E2 is evaluated first, the value of E2 may be
stored in a temporary variable in memory. E1 can then be evalu-
ated and the value will be available in the user-register. The re-
striction on the subtraction operation mentioned in the problem
is that the first operand should be in the user-register, which is
what we now have. The subtraction operation can then be done
between an operand in the user-register and another operand in
memory.
11. Consider the following statements with respect to user level
threads and kernel-level threads.
(i) Context switch is faster with kernel-supported threads.
6
www.gategenie.com CS GATE 2004 with GateGenie Solutions
(ii) For user-level threads, a system call can block the entire
process
(iii) Kernel-supported threads can be scheduled independently
(iv) User-level threads are transparent to the kernel
Answer: (1)
7
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Answer: (1)
8
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Answer: (1)
Answer: (4)
Explanation: Use minimization using K-map method.
19. If 73x (in base-x number system) is equal to 54y (in base-y num-
ber system), the possible values of x and y are
(1) 8, 16 (2) 10, 12 (3) 9, 13 (4) 8, 11
Answer: (4)
9
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Explanation:
7∗x+3=5∗y+4
7∗x−5∗y =1
Answer: (2)
10
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Explanation:
Total bits transmitted for each 8-bit character = 8 + 1 + 2 +
1 = 12 bits.
9600 baud serial line , so 9600/12 = 800 characters per second
can be transmitted.
23. Identify the correct translation into logical notation of the fol-
lowing assertion.
Some boys in the class are taller than all the girls
Answer: (2)
Explanation:
11
www.gategenie.com CS GATE 2004 with GateGenie Solutions
12
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Answer: (3)
Explanation:
Refer to any Algorithms text for the chapter on Sorting.
30. The problems 3-SAT and 2-SAT are
(1) both in P
(2) both NP-complete
(3) NP-complete and in P respectively
(4) undecidable and NP-complete respectively
Answer: (2)
Explanation:
There is a polynomial time algorithm to solve the 2-SAT prob-
lem. In the case of 3-SAT, given a solution it can be verified
in polynomial time if it is indeed a solution. Also, it is known
that it is NP-hard. Given these two facts, 3-SAT is therefore
NP-complete.
int f(int n)
{ static int i = 1;
if (n >=5 ) return n;
13
www.gategenie.com CS GATE 2004 with GateGenie Solutions
n = n + i;
i++;
return f(n);
}
Answer: (3)
Explanation: When n = 1, f(1) is called giving
i = 1, n = 1 + 1 => n = 2; i + + => i = 2
When n = 2, f(2) is called resulting in i retaining its values
between two different invocations of the function f.
n = 2, i = 2; n = 2 + 2 = 4; i + + => i = 3;
When f (4) is called;
n = 4, i = 3; n = 4 + 3 = 7; i + + => i = 4; 7 >= 5,
so 7 is returned. Therefore value returned is 7.
32. Consider the following program fragment for reversing the digits
in a given integer to obtain a new integer. Let n = d1d2 . . .dm .
int n, rev;
rev = 0;
while (n > 0) {
rev = rev * 10 + n % 10;
n = n / 10;
}
14
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Explanation:
After the ith iteration, n contains the first m − i digits in the
representation of d1d2 . . .dm . rev contains the last i digits in
reversed order. so the correct answer is (A).
33. Consider the following C program segment:
char p[20];
char *s = "string";
int length = strlen(s);
for (i = 0; i < length; i++)
p[i] = s[length - i];
printf("%s", p);
15
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Employee
|
------------------------------------
| | |
Manager Engineer Secretary
Answer: (2)
36. A circular linked list is used to represent a Queue. A single
variable p is used to access the Queue. To which node should p
point such that both the operations enQueue and deQueue be
16
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Front Rear
p
?
Answer: (1)
Explanation: If p points to the rear node, EnQueue can be
done in constant time by adding a node after the node pointed
to by p. DeQueue can also be done in constant time by remov-
ing the next node to the node pointed to by p.
37. The elements 32, 15, 20, 30, 12, 25, 16, are inserted one
by one in the given order into a maxHeap. The resultant
maxHeap is
32
30 25
15 12 20 16
(A)
32
25 30
12 15 20 16
(B)
17
www.gategenie.com CS GATE 2004 with GateGenie Solutions
32
30 25
15 12 16 20
(C)
32
25 30
12 15 16 20
(D)
Answer: (1)
38. Assume that the operators +,-,× are left associative and ı̂s right
associative. The order of precedence (from highest to lowest) is
ˆ , ×, +,-. The postfix expression corresponding to the infix
expression a + b × c − d ˆ e ˆ f is
(1) abc × +def ˆ ˆ (2) abc × +de ˆ fˆ−
(3) ab + c × d − e ˆ fˆ (4) − + a × bc ˆ ˆ def
Answer: (2)
Explanation: Since ˆ is right associative, the given expression
actually means:
a + b × c − (d ˆ e) ˆ f . (B) in infix also means the same thing.
18
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Answer: (4)
Explanation: The time complexity only depends on the al-
gorithm and not the access mechanism. The question tries to
mislead by the fact that the elements can be accessed faster if
the storage is row-major.
main()
{ int x, y, m, n;
scanf("%d %d", &x, &y);
/* Assume x > 0 and y > 0 */
m = x; n = y;
while ( m != n )
{ if (m > n)
m = m - n;
else
n = n - m;
}
printf("%d", n);
}
19
www.gategenie.com CS GATE 2004 with GateGenie Solutions
x = m;
y = 1;
while ( x - y > $\in$)
{ x = (x + y) / 2;
y = m / x;
}
print (x);
Answer: (3)
43. Consider the following C program segment.
struct CellNode {
struct CellNode *leftChild;
int element;
struct CellNode *rightChild;
};
int DoSomething(struct CellNode *ptr)
{
int value = 0;
20
www.gategenie.com CS GATE 2004 with GateGenie Solutions
if (ptr != NULL)
{ if (ptr->leftChild != NULL)
value = 1 + DoSomething (ptr->leftChild);
if (ptr->rightChild != NULL)
value = max(value,
1 + DoSomething (ptr->rightChild));
}
return (value);
}
1 4 2
6
P S 1
2
3
7
T U
2
21
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Compute E.value for the root of the parse tree for the expres-
sion: 2#3 & 5#6 & 4.
(1) 200 (2) 180 (3) 160 (4) 40
Answer: (3)
Explanation:
From the syntax rules, it can be seen that translation occurs in
such a way that # has more preference than &.
So, the expression is calculated as (2#(3&5))#(6&4) = (2*(3+5))*(6+4)
= 16*10 = 160
46. Consider the following set of processors, with the arrival times
and the CPU-burst
P1 0 5
P2 1 3
P3 2 3
P4 4 1
22
www.gategenie.com CS GATE 2004 with GateGenie Solutions
algorithm?
(1) 5.50 (2) 5.75 (3) 6.00 (4) 6.25
Answer: (1)
Explanation:
The processes will be scheduled as follows:
Time Process
0 P1
1 P2
2 P2
3 P2
4 P4
5 P3
6 P3
7 P3
8 P1
9 P1
10 P1
11 P1
12
23
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Answer: (4)
Explanation:
Let p be the page fault probability; p = 0.0001
Total instruction execution time = CPU time + (p × pagefault
handling time) + number of memory accesses × memory access
time
24
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Answer: (4)
49. A Unix-style i-node has 10 direct pointers and one single, one
double and one triple indirect pointers. Disk block size is 1Kbyte,
disk block address is 32 bits, and 48-bit integers are used. What
is the maximum possible file size?
(1) 224 bytes (2) 232 bytes (3) 234 bytes (4) 248 bytes
Answer: (3)
Explanation:
Number of disk block pointers that can fit in one block is 1024/4
= 256.
File size due to direct pointers = 10 * 1K = 10KBytes
File size due to single indirection pointers = 256 * 1K = 256K
= 218 bytes
File size due to double indirection pointer = 256 * 256 * 1K =
226 bytes
File size due to triple indirection pointer = 256 * 256 * 256 *
1K = 234 bytes
Total file size 234 bytes (approx)
25
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Answer: (1)
51. Consider the relation Student (name, sex, marks), where the
primary key is shown underlined, pertaining to the students in
a class that has at least one boy and one girl. What does the
following relational algebra expression produce? (Note: ρ is the
rename operator).
Πname(σsex=f emale(Student)) −
Πname(Student o n(sex=f emale∧x=male∧marks≤m) ρn,x,m (Student))
(1) names of girl students with the highest marks
(2) names of girl students with more marks than some boy student
(3) names of girl students with marks not less than some boy student
(4) names of girl students with more marks than all the boy students
Answer: (4)
Explanation:
Πname(Student o n(sex=f emale∧x=male∧marks≤m) ρn,x,m (Student)) gives
the set of all female students who secured at least as many marks
as some male student. Subtracting this set from the set of all fe-
male students gives the names of all female students with more
marks than all the male students.
Answer: (3)
A B + tree node with k children can hold (k − 1) search key
fields.
k*6 + (k-1)*14 = 512 => k = 26.3 . The correct answer is
26
www.gategenie.com CS GATE 2004 with GateGenie Solutions
therefore (C).
53. The employee information in a company is stored in the relation
Employee (name, sex, salary, deptName).
select deptName
from Employee
where sex=’M’
group by deptName
having avg(salary) >
(select avg(salary) from Employee)
Answer: (1)
27
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Explanation: The fact that A won the first back-off race does
not have any effect on the second back-off race. The probability
for each of A or B winning a back-off race is equal to 0.5.
55. The routing table of a router is shown below:
A: 1000 bytes
28
www.gategenie.com CS GATE 2004 with GateGenie Solutions
B: 100 bytes
C: 1000 bytes
56. Assuming that the packets are correctly delivered, how many
bytes, including headers are delivered to the IP layer at the des-
tination for one application message, in the best case? Consider
only data packets.
(1) 200 (2) 220 (3) 240 (4) 260
Answer: (4)
Explanation: The IP layer of A hands over a packet of 220
(180 data bytes+ 20 TCP header bits + 20 IP header bits) to
its data link layer. The IP layer of B receives this 220 byte
packet, strips off the IP header and gets the data payload of
200 bytes. Since no packet can be of size more than 100 bytes
in the network B, maximum amount of payload data(i.e. with-
out headers) that can be held by the packet is 80 bytes. The 200
bytes thus get divided into 3 packets, two with 80 data bytes
each and the third with 40 bytes. To each of this data, a header
of 20 bytes is attached and IP packets of 100, 100 and 60 bytes
are transferred to the IP layer at C. Thus the IP layer at C
receives 100 + 100 + 60 = 260 bytes.
57. What is the rate at which application data is transferred to host
HC ? Ignore errors, acknowledgments, and other overheads.
(1) 325.5 Kbps (2) 354.4 Kbps
(3) 409.6 Kbps (4) 512.0 Kbps
29
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Answer: (2)
Explanation:
260 bytes of data is transferred to HC on a 512 kbps link.
Time taken to transmit 260 bytes of data = 260*8/512000 sec
260 bytes of data contains 180 bytes of application data
So time taken to transmit 180 bytes of application data is 260*8/512000
seconds
Transmission rate for application data = 180*8/260*8 * 512000
= 354.46 Kbps.
Answer: (2)
Explanation: Let A,B,C,D denote the 4 bit inputs to the com-
binational circuit.
A B C D Output
0 0 0 0 0
0 0 0 1 0
0 0 1 0 0
0 0 1 1 0
0 1 0 0 0
0 1 0 1 1
0 1 1 0 1
0 1 1 1 1
1 0 0 0 1
1 0 0 1 1
30
www.gategenie.com CS GATE 2004 with GateGenie Solutions
59. Which are the essential prime implicants of the following Boolean
function? f (a, b, c) = a0 c + ac0 + b0 c
(1) a0 c and ac0 (2) a0 c and b0c
(3) a0 c only (4) ac0 and bc0
Answer: (3)
Explanation: Only a0 c is an essential prime implicant. On
drawing the K-map we observe that the only way we can group
the min-term a0 bc is by grouping it with a0 b0 c. This means that
the prime implicant obtained here is the essential prime impli-
cant. All other min-terms can be covered by more than one
prime implicants and hence are not essential.
31
www.gategenie.com CS GATE 2004 with GateGenie Solutions
T2 Q2 X T1 Q1
MSB LSB
CLK
Answer: (4)
Explanation: Set X to Q1 ⊕ Q2 and it can be verified that
counter steps through the given sequence.
62. A 4-bit carry lookahead adder, which adds two 4-bit numbers, is
designed using AND, OR, NOT, NAND, NOR gates only. As-
suming that all the inputs are available in both complemented
and uncomplemented forms and the delay of each gate is one
time unit, what is the overall propagation delay of the adder?
Assume that the carry network has been implemented using
two-level AND-OR logic.
(1) 4 time units (2) 6 time units
(3) 10 time units (4) 12 time units
Answer: (2)
Explanation: 1 gate delay for generate and propagate func-
tions of each level.
C3 = G3 + P3 G2 + P3 P2 G1 + P3 P2 P1 G0 + P3 P2 P1 Cin
Thus, for calculation of each of the carry outs, we need 2 gate
delays after generate and propagate are calculated.
Calculation of sum using AND-OR circuit requires calculation
of NOT of each of the carry bits. This takes 1 gate delay. The
32
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Q. 63-64
Answer: (4)
Explanation: Each word is 32 bits, that is 4 bytes. After the
interrupt is serviced, execution returns to the next location after
the halt instruction. Thus, return address will point to 1000 +
7*4 = 1028
64. Let the clock cycles required for various operations be as follows:
33
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Answer: (2)
Explanation: For all the instructions, the time taken for fetch
and decode = 7 words * 2 clock cycles per word. = 14 cycles
8, 12, 0, 12,8
Answer: (3)
Explanation: There are 2 sets each with 2 blocks. One of the
sets can contain any of the even numbered blocks, the other can
contain the odd numbered blocks. All the blocks used in the
problem are even numbered, so all of them can be in the same
set (not all at once though).
8 causes a cache miss.
12 causes a cache miss
0 causes a cache miss, by LRU the block containing 8 is replaced
by 0.
34
www.gategenie.com CS GATE 2004 with GateGenie Solutions
66. Let A = 1111 1010 and B = 0000 1010 be two 8-bit 20s comple-
ment numbers. Their products in 20s complement is
(1) 1100 0100 (2) 1001 1100 (3) 1010 0101 (4) 1101 0101
Answer: (1)
Explanation:
A = −6
B = 10
A × B = −60 ⇒ 11000100
Load
Control
Address Register
Increment
Control
Memory
MUX 13
Status bits 8
35
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Answer: (4)
Explanation:
For transferring, the DMA requires 20 × 103/107 seconds = 2000
microseconds.
The processor participates in the transfer for 1200 clock cycles
= 1200 ∗ 1/(600 ∗ 106) seconds = 2 microseconds
Therefore the percentage of the processor time consumed for the
transfer = 2/(2000+2) * 100 0.1 %
69. A 4-stage pipeline has the stage delays as 150, 120, 160 and 140
nanoseconds respectively. Registers that are used between the
stages have a delay of 5 nanoseconds each. Assuming constant
clocking rate, the total time taken to process 1000 data items
on this pipeline will be
36
www.gategenie.com CS GATE 2004 with GateGenie Solutions
71. How many solutions does the following system of linear equa-
tions have?
−x + 5y = −1
x−y = 2
x + 3y = 3
37
www.gategenie.com CS GATE 2004 with GateGenie Solutions
* e a b c
e e a b c
a a b c e
b a b c e
b
c
38
www.gategenie.com CS GATE 2004 with GateGenie Solutions
these two sets are added then every subset of elements will have
a GLB and an LUB.
74. An examination paper has 150 multiple-choice questions of one
mark each, with each question having four choices. Each incor-
rect answer fetches -0.25 mark. Suppose 1000 students choose
all their answers randomly with uniform probability. The sum
total of the expected marks obtained marks by all these students
is
(1) 0 (2) 2550 (3) 7525 (4) 9375
Answer: (4)
Explanation: There are 150 questions and 1000 students. The
probability of choosing a correct answer is 1/4. The probability
of choosing the wrong answer is 3/4.
Thus weight for each answer: 1/4*1 - 3/4*0.25 = 1/16 (0.25 is
penalty for incorrect answer)
So sum of expected marks = 1000*150*1/16 =9375
75. Mala has a coloring book in which each English letter is drawn
two times. She wants to paint each of these 52 prints with one of
k colors, such that the color-pairs used to color any two letters
are different. Both prints of a letter can also be colored with
the same color. What is the minimum value of k that satisfies
this requirement?
(1) 9 (2) 8 (3) 7 (4) 6
Answer: (4)
Explanation: There are k distinct colors. So there are k 2 color
pairs. In order to be able to color such that color-pairs used for
any two letters are different, k 2 ¿ number of letter pairs.
k 2 > 26 ⇒ k > 5.09
Therefore minimum value of k is 6.
39
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Figure 2: Fig: Q. 77
Answer: (3)
Explanation:
It is known that any planar graph can be colored using not more
than 4 colors. As the given graph is a planar graph it can be
colored using 4 colors. But we also have to check the graph to
see whether it can be colored using only 3 colors. By simple
checking it is clear that coloring with 3 colors is not possible.
The coloring is as follows, a,b,c,d are distinct colors:
78. Two n bit binary strings, S1 and S2 are chosen randomly with
the uniform probability. The probability that the Hamming dis-
40
www.gategenie.com CS GATE 2004 with GateGenie Solutions
c d
a
a
d c
Figure 3: Explanation Q. 77
Answer: (1)
Explanation:
Probability that ith bit in S1 and S2 matches is p = 1/2 There-
fore, using binomial distribution, the probability that it matches
in d positions is,
P (X = d) = C(n, d)((1/2)d)((1/2)(n−d)) ⇒ C(n, d)/2n
79. How many graphs on n labeled vertices exist which have at least
(n2 − 3n)/2 edges?
P(n2 −3n)/2
(1) C((n2 − n)/2, (n2 − 3n)2) (2) C((n2 − n), k)
P k=0
n
(3) C((n2 − n)/2, n) (4) 2
k=0 C((n − n)/2, k)
Answer: (4)
Explanation:
Total number of edges in a graph with n labeled vertices is
n(n − 1)/2 = (n2 − n)/2
The number of ways of choosing k edges from (n2 − n)/2 edges
= C((n2 − n)/2, k). This is also the number of graphs having k
edges.
Number of graphs with at least k edges = Number of graphs
41
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Answer: (4)
Explanation:
If u represent a point by (x,y) then p2 = x2 +R y 2R
1 2
The sum of this function over this area is = 0 0 x2 + y 2 dx dy
i.e.10/3.
Therefore, expected value=(10/3)/area of the rectangle i.e.5/3.
81. Let G1 = (V, E1) and G2 = (V, E2) are two connected graphs on
the same vertex set V with more than two vertices. If G1 ∩ G2
= (V, E1 ∩ E2) is not a connected graph, then the graph G1 ∩ G2
= (V, E1 ∩ E2)
(1) cannot have a cut vertex
(2) must have a cycle
(3) must have a cut-edge (bridge)
(4) has chromatic number strictly greater than those G 1 and G2
Answer: (2).
Explanation:
Since the intersection is not connected G1 and G2 should have
42
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Answer: (3)
Explanation:
If you observe this program, this first calculates consecutive
number of 1’s in the array and calls the function with the num-
ber of 1’s it found. It calls the function for every segment of 1’s.
Because the array can have at max n 1’s, the complexity of the
program is equal to θ(n).
83. The time complexity of the following C function is (assume n >
0)
int recursive (int n) {
if (n == 1)
return 1;
else
return(recursive(n-1) + recursive(n-1));
}
(1) O(n) (2) O(n log n) (3) O(n2 ) (4) O(2n)
43
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Answer: (4)
Explanation:
Recurrence relation for the C programs is,
T(n)=1 when n=1
T(n)=2T(n-1)+1
On solving this recursion we get
T (n) = 2k T (n − k) + 2(k−1) + ...... + 1
recursion stops when n-k=1 i.e.k=n-1.
T (n) = 2(n−1).1 + 2(n−2) − 1 (By reducing the last terms as they
form a GP series)
Therefore T (n) = O(2n ).
Answer: (1)
Explanation:
Using the concept of generating functions we get,
Fx = 2Fx−1 − n
x2 − 2x = 0
x = 2, therefore solution is α2n + an where an = cn + d
substituting an in Fx = 2Fx−1 + 1 we get,
c=-1 and d=-2
Therefore, T (n) = α2n − n − 2
substituting this in T (1) = 1 we get α = 2
Therefore T (n) = 2(n+1) − n − 2.
85. A program takes as input a balanced binary search tree with n
leaf nodes and computes the value of a function g(x) for each
node x. If the cost of computing g(x) is min { no. of leaf-nodes
in the left-subtree of x, no. of leaf-nodes in the right-subtree of
44
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Answer: (1)
Explanation:
The tree has n leaves, therefore it has n − 1 internal nodes.So
in total it has 2n − 1 nodes.
Calculating the number of leaves for every node has in its sub-
tree takes time equal to O(2n-1)i.e, O(n), if we do it in bottom
wise. Calculating g(x ) also takes O(1) for each node, therefore
it also takes O(n). Therefore total complexity of calculating
becomes θ(n).
86. The following finite state machine accepts all those binary strings
in which the number of 10 s and 00 s are respectively
(1) divisible by 3 and 2 (2) odd and even
(3) even and odd (4) divisible by 2 and 3
1
1 1
0 0 0 0 0 0
1 1
Answer: (1)
Explanation:
45
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Answer: (2)
Explanation:
First of all it is not regular as it has to remember the sum of
number of a’s and b’s.
It is context free as we can design a PDA which pushes X when
it sees a or b and pops X when it sees c.
88. Consider the following grammar G:
S → bS | aA | b
A → bA | aB
B → bB | aS | a
Let Na (w) and Nb(w) denote the number of a’s and b’s in a
string w respectively. The language L(G) ⊂ {a, b}+ generated
by G is
(1) {w|Na (w) > 3Nb(w)}
(2) {w|Nb (w) > 3Na(w)}
(3) {w|Na (w) = 3k, k ∈ {0, 1, 2, ...}}
(4) {w|Nb (w) = 3k, k ∈ {0, 1, 2, ...}}
Answer: (3)
Explanation:
By simple checking with an example it is clear that C is the
answer.
Grammar doesn’t accept aaaab or abbbb or abbb, therefore a,b,
or d are not the answers, whereas machine accepts aaab which
tells us that c is the answer.
89. L1 is a recursively enumerable language over Σ. An algorithm
A effectively enumerates its words as w1, w2, w3, . . .. Define an-
other language L2 over Σ ∪ {#} as {wi#wj : wi, wj ∈ L1 , i <
j}. Here # is a new symbol. Consider the following assertions:
46
www.gategenie.com CS GATE 2004 with GateGenie Solutions
47
www.gategenie.com CS GATE 2004 with GateGenie Solutions
Answer: (4)
48