Q1
Show answer without attempting
Answer: D
GATE CS · 11 February 2017 · Slot 2 · 65 questions
Every question from the GATE CS 2017 CS-2 paper held on 11 February 2017, in the order it was printed, with the official answer key. Pick an option, or type the number for numerical-answer questions, and it is marked straight away with GATE marking: 1 or 2 marks, −⅓ or −⅔ for a wrong MCQ, no negative marks for MSQ and NAT.
Answer: D
static char var;m = malloc(10); m = NULL;char *ptr[10];register int var1;Answer: A
| Algorithm | Time complexity |
|---|---|
| (P) Towers of Hanoi with disks | (i) |
| (Q) Binary search given sorted numbers | (ii) |
| (R) Heap sort given numbers at the worst case | (iii) |
| (S) Addition of two matrices | (iv) |
Answer: C
Answer: B
Answer: C
Answer: A
Answer: B
Answer: D
Answer: C
Answer: C
Answer: A
Answer: C
Answer: B
void printxy(int x, int y) {
int *ptr;
x = 0;
ptr = &x;
y = *ptr;
*ptr = 1;
printf("%d,%d", x, y);
}printxy(1, 1) isAnswer: C

Answer: D
Answer: C
Answer: C
connect function has already been called. Which of the following statements is/are CORRECT?connect function again for an already connected UDP socket.Answer: B
| P | Q |
|---|---|
| 2 | 2 |
| 3 | 8 |
| 7 | 3 |
| 5 | 8 |
| 6 | 9 |
| 8 | 5 |
| 9 | 8 |
| R | S |
|---|---|
| 2 | 2 |
| 8 | 3 |
| 3 | 2 |
| 9 | 7 |
| 5 | 7 |
| 7 | 2 |
Answer: 0.0
Answer: 9.0

Answer: -0.01 to 0.01
Answer: 2.0
Answer: 16.0
Answer: 8.0
Answer: 8.0
Answer: A
Answer: C
Answer: A
Answer: A
Answer: B
Answer: B
Answer: C
| Process | Current Allocation | Maximum Requirement |
|---|---|---|
| P1 | 3 | 7 |
| P2 | 1 | 6 |
| P3 | 3 | 5 |
Answer: B
Answer: A
Answer: D
Answer: B
while (r >= y) {
r = r - y;
q = q + 1;
}Answer: C
int fun(int n) {
int i, j;
for (i = 1; i <= n; i++) {
for (j = 1; j < n; j += i) {
printf(" %d %d", i, j);
}
}
}fun in terms of notation isAnswer: C
Answer: C
Answer: D
Answer: D
| 0 | 0 | 0 | 1 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 |
Answer: B
swap(&x, &y) exchanges the contents of and .int main() {
int array[] = {3, 5, 1, 4, 6, 2};
int done = 0;
int i;
while (done == 0) {
done = 1;
for (i=0; i<=4; i++) {
if (array[i] < array[i+1]) {
swap(&array[i], &array[i+1]);
done = 0;
}
}
for (i=5; i>=1; i--) {
if (array[i] > array[i-1]) {
swap(&array[i], &array[i-1]);
done = 0;
}
}
}
printf("%d", array[3]);
}Answer: 3.0
Answer: 54.0
| Cache | Read access time (in nanoseconds) | Hit ratio |
|---|---|---|
| I-cache | 2 | 0.8 |
| D-cache | 2 | 0.9 |
| L2-cache | 8 | 0.9 |
Answer: 4.72
top_scorer.| player | country | goals |
|---|---|---|
| Klose | Germany | 16 |
| Ronaldo | Brazil | 15 |
| G Müller | Germany | 14 |
| Fontaine | France | 13 |
| Pelé | Brazil | 12 |
| Klinsmann | Germany | 11 |
| Kocsis | Hungary | 11 |
| Batistuta | Argentina | 10 |
| Cubillas | Peru | 10 |
| Lato | Poland | 10 |
| Lineker | England | 10 |
| T Müller | Germany | 10 |
| Rahn | Germany | 10 |
SELECT ta.player FROM top_scorer AS ta
WHERE ta.goals > ALL (SELECT tb.goals
FROM top_scorer AS tb
WHERE tb.country = 'Spain')
AND ta.goals > ANY (SELECT tc.goals
FROM top_scorer AS tc
WHERE tc.country = 'Germany')Answer: 7.0
Answer: 15.0
Answer: 54.0
Answer: 52.0
| Character | Probability |
|---|---|
| P | 0.22 |
| Q | 0.34 |
| R | 0.17 |
| S | 0.19 |
| T | 0.08 |
| Total | 1.00 |
Answer: 225.0
| Process | Arrival Time | Burst Time | Priority |
|---|---|---|---|
| 0 | 11 | 2 | |
| 5 | 28 | 0 | |
| 12 | 2 | 3 | |
| 2 | 10 | 1 | |
| 9 | 16 | 4 |
Answer: 29.0
Answer: 5.0
Answer: 18.0
#include <stdio.h>
int main() {
int m = 10;
int n, n1;
n = ++m;
n1 = m++;
n--;
--n1;
n -= n1;
printf("%d", n);
return 0;
}Answer: 0.0
#include <stdio.h>
#include <string.h>
int main() {
char* c = "GATECSIT2017";
char* p = c;
printf("%d", (int)strlen(c+2[p]-6[p]-1));
return 0;
}Answer: 2.0
Answer: D
Answer: B
Answer: A
Answer: B
Answer: D
Answer: B
Answer: B
Answer: A
Answer: C

Answer: C
0/650 correct0 marks