Q1
I.
II.
III.
IV.
Show answer without attempting
Answer: D
GATE CS · 11 February 2017 · Slot 1 · 65 questions
Every question from the GATE CS 2017 CS-1 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
Answer: B
Answer: C
Answer: B
| Algorithms | Design Paradigms |
|---|---|
| (P) Kruskal | (i) Divide and Conquer |
| (Q) Quicksort | (ii) Greedy |
| (R) Floyd-Warshall | (iii) Dynamic Programming |
Answer: C
Answer: B
Answer: D
typedef struct node {
int data;
node* next;
} node;
void join(node* m, node* n) {
node* p = n;
while (p->next != NULL) {
p = p->next;
}
p->next = m;
}Answer: B
Answer: C
Answer: B
struct data {
int marks[100];
char grade;
int cnumber;
};
struct data student;Answer: D
p = a - b
q = p * c
p = u * v
q = p + qAnswer: B
#include <stdio.h>
int *assignval(int *x, int val) {
*x = val;
return x;
}
void main () {
int *x = malloc(sizeof(int));
if (NULL == x) return;
x = assignval(x, 0);
if (x) {
x = (int *)malloc(sizeof(int));
if (NULL == x) return;
x = assignval(x, 10);
}
printf("%d\n", *x);
free(x);
}Answer: D
Answer: D
Answer: B
Answer: A
Answer: C
Answer: D
Answer: 0.0
Answer: 18.0
| dc \ ba | 00 | 01 | 11 | 10 |
|---|---|---|---|---|
| 00 | X | X | ||
| 01 | 1 | X | ||
| 11 | 1 | 1 | ||
| 10 | X | X |
Answer: 1.0
Answer: 4.0
| EmpId | EmpName | DeptName |
|---|---|---|
| 1 | XYA | AA |
| 2 | XYB | AA |
| 3 | XYC | AA |
| 4 | XYD | AA |
| 5 | XYE | AB |
| 6 | XYF | AB |
| 7 | XYG | AB |
| 8 | XYH | AC |
| 9 | XYI | AC |
| 10 | XYJ | AC |
| 11 | XYK | AD |
| 12 | XYL | AD |
| 13 | XYM | AE |
SELECT AVG(EC.Num)
FROM EC
WHERE (DeptName, Num) IN
(SELECT DeptName, COUNT(EmpId) AS
EC(DeptName, Num)
FROM EMP
GROUP BY DeptName)Answer: 2.6
| Process | Arrival time | Burst time |
|---|---|---|
| P1 | 0 | 7 |
| P2 | 3 | 3 |
| P3 | 5 | 5 |
| P4 | 6 | 2 |
Answer: 3.0
Answer: 0.05
Answer: A
Answer: D
Answer: C
Answer: D
Answer: A
Answer: B
Answer: C

Answer: B
Answer: D
void fun1(int n) {
if (n == 0) return;
printf("%d", n);
fun2(n - 2);
printf("%d", n);
}
void fun2(int n) {
if (n == 0) return;
printf("%d", n);
fun1(++n);
printf("%d", n);
}Answer: A
int foo(int val) {
int x = 0;
while(val > 0) {
x = x + foo(val--);
}
return val;
}
int bar(int val) {
int x = 0;
while(val > 0) {
x = x + bar(val-1);
}
return val;
}Answer: C
Answer: B
Answer: A
Answer: A
Answer: B
Answer: D
Answer: A
stmt -> if expr then expr else expr; stmt | ε
expr -> term relop term | term
term -> id | number
id -> a | b | c
number -> [0-9]if e1 then e2 else e3Answer: 1024.0
Answer: 11.0
Answer: 86.5 to 89.5
| StudentName | CourseName |
|---|---|
| SA | CA |
| SA | CB |
| SA | CC |
| SB | CB |
| SB | CC |
| SC | CA |
| SC | CB |
| SC | CC |
| SD | CA |
| SD | CB |
| SD | CC |
| SD | CD |
| SE | CD |
| SE | CA |
| SE | CB |
| SF | CA |
| SF | CB |
| SF | CC |
Answer: 4.0
Answer: 271.0
Answer: 5.0
Answer: -16.0
Answer: 1.49 to 1.52
Answer: 76.0
Answer: 2.0
#include <stdio.h>
#include <string.h>
void printlength(char *s, char *t) {
unsigned int c = 0;
int len = ((strlen(s) - strlen(t)) > c) ? strlen(s): strlen(t);
printf("%d\n", len);
}
void main() {
char *x = "abc";
char *y = "defgh";
printlength(x,y);
}Answer: 3.0
Answer: 14.0
#include <stdio.h>
int total(int v) {
static int count = 0;
while(v) {
count += v&1;
v >>= 1;
}
return count;
}
void main() {
static int x = 0;
int i = 5;
for(; i > 0; i--) {
x = x + total(i);
}
printf("%d\n", x);
}Answer: 23.0
Answer: C
Answer: D
Answer: C
Answer: D
Answer: C
Answer: B
Answer: A
Answer: B
Answer: D

Answer: C
0/650 correct0 marks