GATE 2015 (Session 3) Computer Science and Information Technology (CS) Questions with Solutions

GATE 2015 (Session 3)

65 questions

MCQ 45 · NAT 201-mark 30 · 2-mark 35

Questions 41–45 of 65

Q41Undecidability2 marksMCQ−0.67 if wrong
Language L1L_1 is polynomial time reducible to language L2L_2. Language L3L_3 is polynomial time reducible to L2L_2, which in turn is polynomial time reducible to language L4L_4. Which of the following is/are true?
I. if L4∈PL_4 \in P, then L2∈PL_2 \in P
II. if L1∈PL_1 \in P or L3∈PL_3 \in P, then L2∈PL_2 \in P
III. L1∈PL_1 \in P, if and only if L3∈PL_3 \in P
IV. if L4∈PL_4 \in P, then L1∈PL_1 \in P and L3∈PL_3 \in P

Q42Function2 marksNAT
Consider the following C program.
 #include <stdio.h>
int f1(void);
int f2(void);
int f3(void);
int x = 10;
int main( )
{
   int x = 1;
   x += f1( ) + f2( ) + f3( ) + f2( );
   printf("%d", x);
   return 0;
}
int f1() { int x = 25; x++; return x;}
int f2() { static int x = 50; x++; return x;}
int f3() { x *= 10; return x;}
The output of the program is ________.

Q43Array and Pointer2 marksNAT
Consider the following C program.
 #include <stdio.h>
int main( )
{
static int a[ ] = {10, 20, 30, 40, 50};
static int *p[ ] = {a, a+3, a+4, a+1, a+2};
int **ptr = p;
ptr++;
printf("%d%d", ptr-p,**ptr);
}
The output of the program is ______________.

Q44Context Free Language2 marksMCQ−0.67 if wrong
Which of the following languages are context-free?
L1={ambnanbm∣m,n≥1}L_{1}=\{a^{m}b^{n}a^{n}b^{m}|m,n\geq 1\}
L2={ambnambn∣m,n≥1}L_{2}=\{a^{m}b^{n}a^{m}b^{n}|m,n\geq 1\}
L3={ambn∣m=2n+1}L_{3}=\{a^{m}b^{n}|m=2n+1\}

Q45Deadlock2 marksMCQ−0.67 if wrong
Consider the following policies for preventing deadlock in a system with mutually exclusive resources.
I. Processes should acquire all their resources at the beginning of execution. If any resource is not available, all resources acquired so far are released
II. The resources are numbered uniquely, and processes are allowed to request for resources only in increasing resource numbers
III. The resources are numbered uniquely, and processes are allowed to request for resources only in decreasing resource numbers
IV. The resources are numbered uniquely. A process is allowed to request only for a resource with resource number larger than its currently held resources
Which of the above policies can be used for preventing deadlock?