GATE 2015 (Session 3)
65 questions
MCQ 45 · NAT 201-mark 30 · 2-mark 35
Questions 11–15 of 65
Consider the following C program segment.
#include <stdio.h>
int main()
{
char s1[7] = "1234", *p;
p = s1 + 2;
*p = '0';
printf("%s", s1);
} What will be printed by the program?Answer: (C)
The pointer p = s1 + 2 holds the address of s1[2], which is the character '3'. The statement *p = '0' replaces that character with '0'.
So s1 now reads "1204". The string still stops at the original '\0'.
Answer: 1204
So s1 now reads "1204". The string still stops at the original '\0'.
Answer: 1204
Suppose U is the power set of the set S={1,2,3,4,5,6}. For any TU, let |T| denote the number of elements in T and T' denote the complement of T. For any T,RU, let T\R be the set of all elements in T which are not in R. Which one of the following is true?
Answer: (D)
Use .
For option (D): . So for every and .
The other options are false:
- (A): take . Then but .
- (B): two subsets with 5 elements each, from a set of only 6 elements, must share at least one element (5 + 5 = 10 is more than 6), so .
- (C): it says every and have and . Take , which already has .
Answer: (D)
For option (D): . So for every and .
The other options are false:
- (A): take . Then but .
- (B): two subsets with 5 elements each, from a set of only 6 elements, must share at least one element (5 + 5 = 10 is more than 6), so .
- (C): it says every and have and . Take , which already has .
Answer: (D)
Consider the relation X(P,Q,R,S,T,U) with the following set of functional dependencies
F= {{P,R}{S,T}, {P,S,U}{Q,R} }
Which of the following is the trivial functional dependency in , where is closure of F ?
F= {{P,R}{S,T}, {P,S,U}{Q,R} }
Which of the following is the trivial functional dependency in , where is closure of F ?
Answer: (C)
A dependency is trivial if its right side is a subset of its left side.
- (A) : are not in , so it is not trivial. It is a given FD.
- (B) : is on the left but is not, so it is not trivial.
- (C) : , so it is trivial.
- (D) : is not on the left, so it is not trivial.
Answer: (C)
- (A) : are not in , so it is not trivial. It is a given FD.
- (B) : is on the left but is not, so it is not trivial.
- (C) : , so it is trivial.
- (D) : is not on the left, so it is not trivial.
Answer: (C)
The maximum number of processes that can be in Ready state for a computer system with n CPUs is
Answer: (D)
The number of CPUs decides only how many processes can be running at one time. The ready queue can hold any number of waiting processes.
Answer: Independent of n
Answer: Independent of n
Among simple LR (SLR) , canonical LR, and look-ahead LR (LALR), which of the following pairs identify the method that is very easy to implement and the method that is the most powerful , in that order?
Answer: (C)
SLR builds its table from LR(0) items and uses FOLLOW sets. This makes it the easiest method to implement. Canonical LR(1) has the largest number of states. It accepts the biggest class of grammars, so it is the most powerful. LALR is in the middle of the two.
Answer: SLR, canonical LR
Answer: SLR, canonical LR