GATE 2015 (Session 1)
65 questions
MCQ 45 · NAT 201-mark 30 · 2-mark 35
Questions 61–65 of 65
Consider the following relations:
Consider the following SQL query.
The number of rows that will be returned by the SQL query is _____________.
Consider the following SQL query.
SELECT S.Student_Name, sum(P.Marks)
FROM Student S, Performance P
WHERE S.Roll_No = P.Roll_No
GROUP BY S.Student_NameThe number of rows that will be returned by the SQL query is _____________.
Answer: 2
The query uses GROUP BY on Student_Name. Two distinct names appear: Raj, who has roll 1 and roll 3, and Rohit. This gives 2 groups.
The output rows are: Raj, 310 and Rohit, 140.
Answer: 2
The output rows are: Raj, 310 and Rohit, 140.
Answer: 2
What is the output of the following C code? Assume that the address of x is 2000 (in decimal) and an integer requires four bytes of memory.
int main () {
unsigned int x[4][3] ={{1,2,3},{4,5,6},{7,8,9},{10,11,12}};
printf("%u, %u, %u", x+3, *(x+3), *(x+2)+3);
}Answer: (A)
One row has 3 ints, so it is 12 bytes.
- x + 3 is the address of row 3: 2000 + 3 12 = 2036
- *(x + 3) is the address of x[3][0]: 2036
- *(x + 2) + 3 is the address of x[2][0] plus 3 ints: 2024 + 12 = 2036
Answer: 2036, 2036, 2036
- x + 3 is the address of row 3: 2000 + 3 12 = 2036
- *(x + 3) is the address of x[3][0]: 2036
- *(x + 2) + 3 is the address of x[2][0] plus 3 ints: 2024 + 12 = 2036
Answer: 2036, 2036, 2036
The graph shown below has 8 edges with distinct integer edge weights. The minimum spanning tree (MST) is of weight 36 and contains the edges: {(A, C), (B, C), (B, E), (E, F), (D, F)}. The edge weights of only those edges which are in the MST are given in the figure shown below. The minimum possible sum of weights of all 8 edges of this graph is ___________.
Answer: 69
MST edge weights: AC = 9, BC = 2, BE = 15, EF = 4, DF = 6 (sum 36). Weights are distinct, so each non-MST edge must exceed the largest MST edge on its cycle.
- AB: cycle A-C-B, largest is 9 AB 10
- CD: path C-B-E-F-D, largest is 15 CD 16
- DE: path D-F-E, largest is 6 DE 7
Least total = 36 + 10 + 16 + 7 = 69
Answer: 69
- AB: cycle A-C-B, largest is 9 AB 10
- CD: path C-B-E-F-D, largest is 15 CD 16
- DE: path D-F-E, largest is 6 DE 7
Least total = 36 + 10 + 16 + 7 = 69
Answer: 69
Consider the following C function.
int fun1(int n){
int i,j,k,p,q=0;
for (i=1; i < n; ++i) {
p=0;
for (j=n; j > 1; j=j/2)
++p;
for (k=1; k < p; k=k*2)
++q;
}
return q;
} Which one of the following most closely approximates the return value of the function fun1?Answer: (D)
In each of the n passes of the outer loop:
- the j loop runs and sets p to
- the k loop doubles k until it reaches p, so q grows by
So in total, q is
Answer:
- the j loop runs and sets p to
- the k loop doubles k until it reaches p, so q grows by
So in total, q is
Answer:
Consider the following pseudo code, where x and y are positive integers.
begin
q := 0
r := x
while r >= y do
begin
r := r - y
q := q + 1
end
end The post condition that needs to be satisfied after the program terminates isAnswer: (B)
Each pass of the loop takes y away from r and adds 1 to q. So the program is dividing x by y. The invariant is x = qy + r. The loop ends when r is y.
Answer: {x = qy + r r y}
Answer: {x = qy + r r y}