Javatpoint Logo
Javatpoint Logo

GATE 2018 CS Set 3

41) 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

Q: r ⋈ (σ B<5 (s))

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?

  1. σ B<5 (r ⋈ s)
  2. σ B<5 (r LOJ s)
  3. r LOJ (σ B<5 (s))
  4. σ B<5 (r) LOJ s

Answer: C

Explanation:

According to the question, we have to use LOJ( left outer-join operation) by using attribute B which is the primary key of table s and the foreign key of table r.

Therefore, we need to apply condition σB<5 on left table of the join, i.e., table r because left outer join (LOJ) returns all values in the left table that do not match to the right table plus all the values from an inner join.

So, option (C) is the correct answer.


42) 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?

  1. Schema I
  2. Schema II
  3. Schema III
  4. Schema IV

Answer: B

Explanation:

rollno, courseid -> email

The rollno, courseid is a superkey, and the relationship does not have transitivity dependency. Therefore, it is in 3NF.

email -> rollno

For BCNF, every determinant should be a candidate key. Here the email is determinant but not a candidate key. Therefore, the given schema is not in BCNF.


43) 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 = _____.

  1. 110
  2. 105
  3. 107
  4. 109

Answer: D

Explanation:

Given,
y = degree of a vertex
z = number of connected components
According to the question, 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.

The set of swapping numbers will be {(1, 2), (2, 3), ......(9, 9)} which will be equals to 99 such sets. Therefore, the number of edges = 99 and each vertex will have 99 edges corresponding to it.

Suppose a graph with 3! vertices, then its vertices will be {1, 2, 3}, {1, 3, 2}, {2, 1, 3}, {2, 3, 1}....

Let's take vertex {123}, its degree will be 2 because it will be connected with two other vertices i.e. {213} and {132}.

We can conclude that for n, the degree will be n-1.

So, the degree of each vertex (y) = 99


44) Consider Guwahati (G) and Delhi (D) whose temperatures can be classified as high (H), medium (M) and low (L). Let P(H G ) denote the probability that Guwahati has high temperature. Similarly, P(M G ) and P(L G ) denotes the probability of Guwahati having medium and low temperatures respectively. Similarly, we use P(H D ), P(M D ) and P(L D ) for Delhi.

The following table gives the conditional probabilities for Delhi's temperature given Guwahati's temperature.

GATE CS Set 3

Consider the first row in the table above. The first entry denotes that if Guwahati has high temperature (HG ) then the probability of Delhi also having a high temperature (HD ) is 0.40; i.e., P(HD |HG ) = 0.40. Similarly, the next two entries are P(MD | HG ) = 0.48 and P(LD | HG ) = 0.12. Similarly for the other rows.

If it is known that P(HG ) = 0.2, P(MG ) = 0.5, and P(LG ) = 0.3, then the probability (correct to two decimal places) that Guwahati has high temperature given that Delhi has high temperature is _______.

  1. 0.5016
  2. 0.6015
  3. 0.7016
  4. 0.5012

Answer: B

Explanation:

P(HG | HD) = P(HG?HD) / P(HD)
     = P(HD | HG) * P(HG) / P(HD)
      = 0.40 * 0.2 * 1 / P(HD).

P(HD) = P(HD | HG).P(HG) + P(HD | MG).P(MG) + P(HD | LG).P(LG)
     = 0.4 * 0.2 + 0.1 * 0.5 + 0.01 * 0.3
     = 0.133

∴ P(HG | HD) = 0.40 * 0.2 * 1 / P(HD)
     = 0.080.133
     = 0.6015

Hence the correct option is (B).


45) Consider the following program written in pseudo-code. Assume that x and y are integers.

The number of times that the print statement is executed by the call Count(1024,1024) is _____.

  1. 10230
  2. 10220
  3. 11230
  4. None

Answer: A

Explanation:

n the beginning, count(1024, 1024) will be called, and x/2 will reduce the value of x. Here, '*' will be printed ten times. When count=10, the value of x will become 1. Once x reaches 1, count(1024,y-1) will be called. Now, it will be executed until the value of y becomes 1, i.e. on 1023rd call.

Here, count() is called recursively for every y and count() is called 10times for each y.

Therefore,

Number of times that the print statement is executed = 1023 * 10
                                                                                     = 10230

Hence, option (A) is the correct answer.


46) The number of possible min-heaps containing each value from {1, 2, 3, 4, 5, 6, 7} exactly once is _____.

  1. 80
  2. 90
  3. 100
  4. 110

Answer: A

Explanation:

First, set minimum element 1 as root. Now 6 elements are remaining. The left subtree will have 3 elements, and each left subtree combination can be designed in 2! ways.

Hence, total ways to design min-heap with 7-elements is,

       = 6C3 * 2! * 2!
       = (6 * 5 * 4 / 3 * 2 * 1) * 2 * 2
       = 20 * 2 * 2
       = 80


47) Consider the following undirected graph G:

GATE CS Set 3

Choose a value for x that will maximize the number of minimum weight spanning trees (MWSTs) of G. The number of MWSTs of G for this value of x is ______.

  1. 4
  2. 3
  3. 1
  4. 5

Answer: A

Explanation:

To maximize the number of minimum weight spanning trees of G, the value of x should be five because it has two more choices for corner vertex which will maximize the number of MSTs.

According to the Kruskal algorithm for MST:

First select edges with weights 1 and 3

Now, edge with weight four will create a cycle so it will not be selected.

Now, both selected vertices have 2 - 2 choices to choose the vertices. Selects edges with weights 4 and 5, it will give resultant 2*2 = 4 MSTs.

Therefore, the total number of MSTs are 2*2 = 4


48. Consider the weights and values of items listed below. Note that there is only one unit of each item.

Item number Weight (in Kgs) Value (in Rupees)
1 10 60
2 7 28
3 4 20
4 2 24

The task is to pick a subset of these items such that their total weight is no more than 11 Kgs and their total value is maximized. Moreover, no item may be split. The total value of items picked by an optimal algorithm is denoted by Vopt. A greedy algorithm sorts the items by their value-to-weight ratios in descending order and packs them greedily, starting from the first item in the ordered list. The total value of items picked by the greedy algorithm is denoted by Vgreedy.

The value of Vopt - Vgreedy is ____________.

  1. 14
  2. 16
  3. 18
  4. 20

Answer: B

Explanation:

Item Weight Value Value/Weight
1 10 60 6
2 7 28 4
3 4 20 5
4 2 24 12

As per the question sort them in descending order of Value/Weight:

Item Weight Value Value/Weight
4 2 24 12
1 10 60 6
3 4 20 5
2 7 28 4

Now, start picking items.
First Item 4 is picked, the remaining weight = 11-2 = 9kg.
Second, Item 1 cannot be picked because the weight is 10kg > 9kg.
Third, Item 3 can be picked as 4kg < 9kg, the remaining weight = 9-4 = 5kg

Again, Item 2 cannot be picked as 7kg > 5kg.

Hence, only item 3 and Item 4 are picked.

So, Vgreedy = 24+20 = 44
Voptimal - Vgreedy= 60-44 = 16 answer.


GATE 2018 CS Set 3-1
GATE 2018 CS Set 3-2
GATE 2018 CS Set 3-3
GATE 2018 CS Set 3-4
GATE 2018 CS Set 3-5
GATE 2018 CS Set 3-7
GATE 2018 CS Set 3-8
GATE Introduction





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA