GATE 2020
64 questions
MCQ 41 · NAT 231-mark 29 · 2-mark 35
Questions 41–45 of 64
Consider the following languages.
Which one of the following is TRUE?
Which one of the following is TRUE?
Answer: (A)
is regular. Let a string be with non-empty, and let c be the last symbol of x, so . Then the string is , which is with and non-empty. Conversely, a string of this form is in with . So the length of x does not matter and is the set of strings of the form (non-empty) c (non-empty) c with one bit c:
.
is context-free. It consists of the even-length strings whose two halves are different, so some position i in the first half has a different symbol from position i in the second half. Such a string is (or the same with a and b swapped) with and ; the a and the b are then exactly half the length apart. A grammar for it: . (A PDA can do the same by guessing the mismatch.)
Answer: (A)
.
is context-free. It consists of the even-length strings whose two halves are different, so some position i in the first half has a different symbol from position i in the second half. Such a string is (or the same with a and b swapped) with and ; the a and the b are then exactly half the length apart. A grammar for it: . (A PDA can do the same by guessing the mismatch.)
Answer: (A)
Consider the productions and . Each of the five non-terminals A,P,Q,X, and Y has two attributes: s is a synthesized attribute, and i is an inherited attribute. Consider the following rules.
Rule 1: P.i=A.i+2, Q.i=P.i+A.i, and A.s=P.s+Q.s
Rule 2: X.i=A.i+Y.s and Y.i=X.s+A.i
Which one of the following is TRUE?
Rule 1: P.i=A.i+2, Q.i=P.i+A.i, and A.s=P.s+Q.s
Rule 2: X.i=A.i+Y.s and Y.i=X.s+A.i
Which one of the following is TRUE?
Answer: (B)
A rule is L-attributed when each inherited attribute depends only on the inherited attributes of the parent and on attributes of siblings to its left.
- Rule 1: P.i depends on A.i. Q.i depends on P.i (a left sibling) and A.i. So Rule 1 is L-attributed.
- Rule 2: X.i depends on Y.s, but Y sits to the right of X. So Rule 2 is not L-attributed.
Answer: Only Rule 1 is L-attributed
- Rule 1: P.i depends on A.i. Q.i depends on P.i (a left sibling) and A.i. So Rule 1 is L-attributed.
- Rule 2: X.i depends on Y.s, but Y sits to the right of X. So Rule 2 is not L-attributed.
Answer: Only Rule 1 is L-attributed
Each of a set of n processes executes the following code using two semaphores a and b initialized to 1 and 0, respectively. Assume that count is a shared variable initialized to 0 and not used in CODE SECTION P.
What does the code achieve?
CODE SECTION P
wait(a); count=count+1;
if (count==n) signal(b);
signal(a); wait(b); signal(b);
CODE SECTION QWhat does the code achieve?
Answer: (A)
Semaphore a is used to guard count. Semaphore b starts at 0.
- Every process adds 1 to count after it finishes CODE SECTION P, and then it waits on b.
- Only the n-th (last) process does signal(b). After that, each process that gets past wait(b) does signal(b) again, so the next process can pass.
So no process goes into CODE SECTION Q until all n processes have finished P. This works as a barrier.
Answer: No process executes CODE SECTION Q before every process has finished CODE SECTION P
- Every process adds 1 to count after it finishes CODE SECTION P, and then it waits on b.
- Only the n-th (last) process does signal(b). After that, each process that gets past wait(b) does signal(b) again, so the next process can pass.
So no process goes into CODE SECTION Q until all n processes have finished P. This works as a barrier.
Answer: No process executes CODE SECTION Q before every process has finished CODE SECTION P
Consider the following five disk access requests of the form (request id, cylinder number) that are present in the disk scheduler queue at a given time.
(P,155),(Q,85),(R,110),(S,30),(T,115)
Assume the head is positioned at cylinder 100. The scheduler follows Shortest Seek Time First scheduling to service the requests.
Which one of the following statements is FALSE?
(P,155),(Q,85),(R,110),(S,30),(T,115)
Assume the head is positioned at cylinder 100. The scheduler follows Shortest Seek Time First scheduling to service the requests.
Which one of the following statements is FALSE?
Answer: (B)
SSTF order, head at 100:
R (110, seek 10) T (115, 5) Q (85, 30) S (30, 55) P (155, 125)
- T before P: True
- "Q after S but before T": Q is served before S and after T FALSE
- Head reverses between Q and P (down to S, then up to P): True
- R before P: True
Answer: Q is serviced after S, but before T
R (110, seek 10) T (115, 5) Q (85, 30) S (30, 55) P (155, 125)
- T before P: True
- "Q after S but before T": Q is served before S and after T FALSE
- Head reverses between Q and P (down to S, then up to P): True
- R before P: True
Answer: Q is serviced after S, but before T
Consider a relational table R that is in 3NF, but not in BCNF. Which one of the following statements is TRUE?
Answer: (A)
A relation in 3NF can have where X is not a superkey, but only if A is a prime attribute. BCNF does not allow this.
So a relation that is in 3NF but not in BCNF must have such an FD, with A prime. The other options talk about 3NF/2NF violations or a 1NF violation.
Answer: X A where X is not a superkey and A is a prime attribute
So a relation that is in 3NF but not in BCNF must have such an FD, with A prime. The other options talk about 3NF/2NF violations or a 1NF violation.
Answer: X A where X is not a superkey and A is a prime attribute