GATE 2018
65 questions
MCQ 41 · NAT 241-mark 30 · 2-mark 35
Questions 51–55 of 65
Consider the relations r(A, B) and s(B, C), where s.B is a primary key and r.B is a foreign key referencing s.B. Consider the query
Let LOJ denote the natural left outer-join operation. Assume that r and s contain no null values.
Which one of the following queries is NOT equivalent to Q?
Let LOJ denote the natural left outer-join operation. Assume that r and s contain no null values.
Which one of the following queries is NOT equivalent to Q?
Answer: (C)
Q keeps only the r-tuples whose B value is 5, joined with s.
- (A) filters after the join, which gives the same rows as Q.
- (B) Every r.B value is present in s because of the foreign key, and r has no nulls. So every r-tuple finds a match, the outer join adds no padded rows, and . Then the filter gives Q.
- (D) keeps r-tuples with B 5, and each one finds its match in s. This is Q.
- (C) keeps every r-tuple. Those with B 5 find no match in the filtered s, so they stay in the result padded with NULLs. These extra rows are not in Q.
Answer: (C)
- (A) filters after the join, which gives the same rows as Q.
- (B) Every r.B value is present in s because of the foreign key, and r has no nulls. So every r-tuple finds a match, the outer join adds no padded rows, and . Then the filter gives Q.
- (D) keeps r-tuples with B 5, and each one finds its match in s. This is Q.
- (C) keeps every r-tuple. Those with B 5 find no match in the filtered s, so they stay in the result padded with NULLs. These extra rows are not in Q.
Answer: (C)
Consider the following four relational schemas. For each schema, all non-trivial functional dependencies are listed. The underlined attributes are the respective primary keys.
Schema I: Registration (rollno, courses)
Field 'courses' is a set-valued attribute containing the set of courses a student has registered for.
Non-trivial functional dependency:
rollno → courses
Schema II: Registration (rollno, courseid, email)
Non-trivial functional dependencies:
rollno, courseid → email
email → rollno
Schema III: Registration (rollno, courseid, marks, grade)
Non-trivial functional dependencies:
rollno, courseid → marks, grade
marks → grade
Schema IV: Registration (rollno, courseid, credit)
Non-trivial functional dependencies:
rollno, courseid → credit
courseid → credit
Which one of the relational schemas above is in 3NF but not in BCNF?
Schema I: Registration (rollno, courses)
Field 'courses' is a set-valued attribute containing the set of courses a student has registered for.
Non-trivial functional dependency:
rollno → courses
Schema II: Registration (rollno, courseid, email)
Non-trivial functional dependencies:
rollno, courseid → email
email → rollno
Schema III: Registration (rollno, courseid, marks, grade)
Non-trivial functional dependencies:
rollno, courseid → marks, grade
marks → grade
Schema IV: Registration (rollno, courseid, credit)
Non-trivial functional dependencies:
rollno, courseid → credit
courseid → credit
Which one of the relational schemas above is in 3NF but not in BCNF?
Answer: (B)
Let us check each schema one by one:
- I: A set-valued attribute breaks 1NF.
- II: The keys are (rollno, courseid) and (email, courseid). In email rollno, email is not a superkey. But rollno is a prime attribute so this is allowed in 3NF but not in BCNF. True
- III: marks grade is a transitive dependency and grade is a non-prime attribute so it is not in 3NF.
- IV: courseid credit is a partial dependency so it is not in 2NF.
Answer: Schema II
- I: A set-valued attribute breaks 1NF.
- II: The keys are (rollno, courseid) and (email, courseid). In email rollno, email is not a superkey. But rollno is a prime attribute so this is allowed in 3NF but not in BCNF. True
- III: marks grade is a transitive dependency and grade is a non-prime attribute so it is not in 3NF.
- IV: courseid credit is a partial dependency so it is not in 2NF.
Answer: Schema II
Let G be a graph with 100! vertices, with each vertex labelled by a distinct permutation of the numbers 1,2,...,100. There is an edge between vertices u and v if and only if the label of u can be obtained by swapping two adjacent numbers in the label of v. Let y denote the degree of a vertex in G, and z denote the number of connected components in G. Then, y+ 10z = _____.
Answer: 109
Let us check each part:
- Degree: a permutation of 100 numbers has 99 adjacent pairs that can be swapped y = 99.
- Swapping adjacent numbers can reach every permutation (as in bubble sort), so the graph is connected z = 1.
y + 10z = 99 + 10 = 109
Answer: 109
- Degree: a permutation of 100 numbers has 99 adjacent pairs that can be swapped y = 99.
- Swapping adjacent numbers can reach every permutation (as in bubble sort), so the graph is connected z = 1.
y + 10z = 99 + 10 = 109
Answer: 109
Consider Guwahati (G) and Delhi (D) whose temperatures can be classified as high (G), medium (M) and low (L). Let P() denote the probability that Guwahati has high temperature. Similarly, P() and P( ) denotes the probability of Guwahati having medium and low temperatures respectively. Similarly, we use P(),P() and P() for Delhi.
The following table gives the conditional probabilities for Delhi's temperature given Guwahati's temperature.
Consider the first row in the table above. The first entry denotes that if Guwahati has high temperature () then the probability of Delhi also having a high temperature () is 0.40; i.e., (|) = 0.40. Similarly, the next two entries are P(| )= 0.48 and P(|) = 0.12. Similarly for the other rows. If it is known that P()= 0.2, P()= 0.5, andP()= 0.3, then the probability (correct to two decimal places) that Guwahati has high temperature given that Delhi has high temperature is _______
The following table gives the conditional probabilities for Delhi's temperature given Guwahati's temperature.
Consider the first row in the table above. The first entry denotes that if Guwahati has high temperature () then the probability of Delhi also having a high temperature () is 0.40; i.e., (|) = 0.40. Similarly, the next two entries are P(| )= 0.48 and P(|) = 0.12. Similarly for the other rows. If it is known that P()= 0.2, P()= 0.5, andP()= 0.3, then the probability (correct to two decimal places) that Guwahati has high temperature given that Delhi has high temperature is _______
Answer: 0.6 to 0.62
Total probability of high temperature in Delhi:
Using Bayes' theorem:
Answer: 0.60
Using Bayes' theorem:
Answer: 0.60
Consider the following program written in pseudo-code. Assume that x and y are integers.
Count(x,y) {
if (y != 1){
if (x != 1) {
print("*");
Count(x/2, y);
}
else {
y = y-1;
Count(1024, y);
}
}
} The number of times that the print statement is executed by the call Count(1024,1024) is _____.Answer: 10230
Take each value of y from 1024 down to 2. For each one, x is halved from 1024 to 1, and the program prints one star at every halving. That gives 10 stars. After that, y is reduced by 1 and x is set back to 1024. The recursion stops when y = 1.
Total stars = 10 1023 = 10230
Answer: 10230
Total stars = 10 1023 = 10230
Answer: 10230