GATE 2021 (Session 2)
64 questions
MCQ 33 · MSQ 13 · NAT 181-mark 29 · 2-mark 35
Questions 41–45 of 64
Let S be the following schedule of operations of three transactions in a relational database system:
Consider the statements P and Q below:
P: S is conflict-serializable.
Q: If commits before finishes, then S is recoverable.
Which one of the following choices is correct?
Consider the statements P and Q below:
P: S is conflict-serializable.
Q: If commits before finishes, then S is recoverable.
Which one of the following choices is correct?
Answer: (B)
Conflicts:
- comes before : T1 T2
- comes before : T1 T3
- comes before : T2 T3
There is no cycle so S is conflict serializable (T1, T2, T3). P is true.
T3 reads X written by T1. If T3 commits before T1 and T1 aborts later, T3 cannot be undone so S is not recoverable. Q is false.
Answer: P is true and Q is false
- comes before : T1 T2
- comes before : T1 T3
- comes before : T2 T3
There is no cycle so S is conflict serializable (T1, T2, T3). P is true.
T3 reads X written by T1. If T3 commits before T1 and T1 aborts later, T3 cannot be undone so S is not recoverable. Q is false.
Answer: P is true and Q is false
A bag has red balls and black balls. All balls are identical except for their colours. In a trial, a ball is randomly drawn from the bag, its colour is noted and the ball is placed back into the bag along with another ball of the same colour. Note that the number of balls in the bag will increase by one, after the trial. A sequence of four such trials is conducted. Which one of the following choices gives the probability of drawing a red ball in the fourth trial?
Answer: (A)
This is Polya's urn. The chance of any particular sequence of four draws depends only on how many reds and blacks it has, not on their order. For example, with two reds and two blacks the numerators are and in every order, and the denominator is always .
So swapping the 1st and 4th results of any sequence keeps its probability. Hence .
Check for the 2nd draw: .
Option (D) is the chance of red on all four draws, not on the 4th draw only.
Answer: (A)
So swapping the 1st and 4th results of any sequence keeps its probability. Hence .
Check for the 2nd draw: .
Option (D) is the chance of red on all four draws, not on the 4th draw only.
Answer: (A)
Consider the cyclic redundancy check (CRC) based error detecting scheme having the generator polynomial . Suppose the message is to be transmitted. Check bits are appended at the end of the message by the transmitter using the above CRC scheme. The transmitted bit string is denoted by . The value of the checkbit sequence is
Answer: (C)
The generator is = 1011. Add 3 zeros at the end of the message to get 11000000. Then divide using XOR:
- 1100 1011 = 0111 bring down 0 1110
- 1110 1011 = 0101 bring down 0 1010
- 1010 1011 = 0001 bring down 0 0010 bring down 0 0100
The remainder is 100.
Answer: 100
- 1100 1011 = 0111 bring down 0 1110
- 1110 1011 = 0101 bring down 0 1010
- 1010 1011 = 0001 bring down 0 0010 bring down 0 0100
The remainder is 100.
Answer: 100
Consider the following ANSI C program:
#include <stdio.h>
#include <stdlib.h>
struct Node{
int value;
struct Node *next;};
int main( ) {
struct Node *boxE, *head, *boxN; int index=0;
boxE=head= (struct Node *) malloc(sizeof(struct Node));
head -> value = index;
for (index =1; index <= 3; index++){
boxN = (struct Node *) malloc (sizeof(struct Node));
boxE -> next = boxN;
boxN -> value = index;
boxE = boxN; }
for (index=0; index <= 3; index++) {
printf("Value at index %d is %d\n", index, head -> value);
head = head -> next;
printf("Value at index %d is %d\n", index+1, head -> value); } } Which one of the following statements below is correct about the program?Answer: (D)
The list has 4 nodes: the first node (value 0) made before the loop, and 3 more made in the loop (values 1, 2, 3). The field of the last node is never set, and malloc does not initialize memory, so it holds a garbage value.
The final for loop runs for , which is 4 passes. In each pass, is printed, then moved to the next node once, then printed again.
Passes 0, 1 and 2 move from the 1st node to the 2nd, 3rd and 4th node. In pass 3, already points to the 4th node. The statement then loads the garbage pointer, and in the next printf dereferences it. This is undefined behaviour and may crash at run time.
Why the others are wrong:
(A) The list has 4 nodes, not 5.
(B) The for loop runs a fixed 4 times, so it cannot loop forever.
(C) In C, may end without a return statement (from C99 it returns 0 by itself), so this is not a compile error.
Answer: (D)
The final for loop runs for , which is 4 passes. In each pass, is printed, then moved to the next node once, then printed again.
Passes 0, 1 and 2 move from the 1st node to the 2nd, 3rd and 4th node. In pass 3, already points to the 4th node. The statement then loads the garbage pointer, and in the next printf dereferences it. This is undefined behaviour and may crash at run time.
Why the others are wrong:
(A) The list has 4 nodes, not 5.
(B) The for loop runs a fixed 4 times, so it cannot loop forever.
(C) In C, may end without a return statement (from C99 it returns 0 by itself), so this is not a compile error.
Answer: (D)
Consider the following two statements about regular languages:
S1: Every infinite regular language contains an undecidable language as a subset.
S2: Every finite language is regular.
Which one of the following choices is correct?
S1: Every infinite regular language contains an undecidable language as a subset.
S2: Every finite language is regular.
Which one of the following choices is correct?
Answer: (C)
Let us check each statement:
- S1: An infinite language has uncountably many subsets. Only countably many of them are decidable. So at least one subset is undecidable TRUE.
- S2: A finite language is a finite union of single strings it is regular TRUE.
Answer: Both S1 and S2 are true
- S1: An infinite language has uncountably many subsets. Only countably many of them are decidable. So at least one subset is undecidable TRUE.
- S2: A finite language is a finite union of single strings it is regular TRUE.
Answer: Both S1 and S2 are true