GATE 2017 (Session 2)
65 questions
MCQ 45 · NAT 201-mark 30 · 2-mark 35
Questions 21–25 of 65
Let p, q, r denote the statements "It is raining ," It is cold", and " It is pleasant," respectively. Then the statement "It is not raining and it is pleasant, and it is not pleasant only if it is raining and it is cold" is represented by
Answer: (A)
Look at each part of the statement:
- "It is not raining and it is pleasant" gives
- "It is not pleasant only if it is raining and cold": "A only if B" is written as , so this part becomes
The two parts are joined by "and", which gives . This is (A).
(B) has , which reads "if raining and cold, then not pleasant", the reverse of "only if". (C) and (D) join the two parts with (or), but the statement uses "and". (D) also has , which is a different claim.
Answer: (A)
- "It is not raining and it is pleasant" gives
- "It is not pleasant only if it is raining and cold": "A only if B" is written as , so this part becomes
The two parts are joined by "and", which gives . This is (A).
(B) has , which reads "if raining and cold, then not pleasant", the reverse of "only if". (C) and (D) join the two parts with (or), but the statement uses "and". (D) also has , which is a different claim.
Answer: (A)
Given the following binary number in 32-bit (single precision) IEEE-754 format:
00111110011011010000000000000000
The decimal value closest to this floating- point number is
00111110011011010000000000000000
The decimal value closest to this floating- point number is
Answer: (C)
Sign bit is 0. Exponent bits are 01111100, which is 124 .
Mantissa is 1.1101101 1.85.
Value: . This is closest to .
Answer:
Mantissa is 1.1101101 1.85.
Value: . This is closest to .
Answer:
A circular queue has been implemented using a single linked list where each node consists of a value and a single pointer pointing to the next node. We maintain exactly two external pointers FRONT and REAR pointing to the front node and the rear node of the queue, respectively. Which of the following statements is/are CORRECT for such a circular queue, so that insertion and deletion operation can be performed in O (1) time ?
I. Next pointer of front node points to the rear node.
II. Next pointer of rear node points to the front node.
I. Next pointer of front node points to the rear node.
II. Next pointer of rear node points to the front node.
Answer: (B)
New nodes go in after REAR, and nodes are removed from FRONT. To do both in time, the next pointer of the rear node has to point to the front node. This is what makes the list circular. The next pointer of the front node points to the second node, not to the rear node.
Answer: II only
Answer: II only
Consider the following function implemented in C:
void printxy (int x, int y) {
int *ptr ;
x = 0;
ptr = &x;
y = * ptr;
*ptr = 1;
printf ("%d, %d,", x, y);
} The output of invoking printxy (1,1) isAnswer: (C)
First x is set to 0, and ptr gets the address of x: ptr = x. Then y = *ptr gives y = 0. Next, *ptr = 1 writes through the pointer, so x becomes 1.
The program prints x, y = 1, 0.
Answer: 1,0
The program prints x, y = 1, 0.
Answer: 1,0
The Breadth First Search (BFS) algorithm has been implemented using the queue data structure. Which one of the following is a possible order of visiting the nodes in the graph below?
Answer: (D)
In BFS, all neighbours of the start vertex are visited first, then the vertices next to them, and so on. The edges are M-N, M-Q, M-R, N-O, N-Q, O-Q, O-P, Q-P.
(A) MNOPQR: the start is M, whose neighbours are N, Q, R. The third vertex, O, is not a neighbour of M, while Q and R are still unvisited. Not BFS.
(B) NQMPOR: the start is N, whose neighbours are M, O, Q. P comes fourth, but O (a neighbour of N) is still unvisited. Not BFS.
(C) QMNROP: the start is Q, whose neighbours are M, N, O, P. R comes fourth, but O and P (neighbours of Q) are still unvisited. Not BFS.
(D) POQNMR: the start is P, whose neighbours are O and Q, visited next. The new neighbour of O is N, and the new neighbour of Q is M. Then M adds R. This order is a valid BFS.
Answer: (D)
(A) MNOPQR: the start is M, whose neighbours are N, Q, R. The third vertex, O, is not a neighbour of M, while Q and R are still unvisited. Not BFS.
(B) NQMPOR: the start is N, whose neighbours are M, O, Q. P comes fourth, but O (a neighbour of N) is still unvisited. Not BFS.
(C) QMNROP: the start is Q, whose neighbours are M, N, O, P. R comes fourth, but O and P (neighbours of Q) are still unvisited. Not BFS.
(D) POQNMR: the start is P, whose neighbours are O and Q, visited next. The new neighbour of O is N, and the new neighbour of Q is M. Then M adds R. This order is a valid BFS.
Answer: (D)