Javatpoint Logo
Javatpoint Logo

49) Let G be a complete undirected graph on 4 vertices, having 6 edges with weights being 1, 2, 3, 4, 5, and 6. The maximum possible weight that a minimum weight spanning tree of G can have is __________.

  1. 5
  2. 6
  3. 7
  4. 8

Answer: C

Explanation:

Gate 2016 CS set 1

According to rule a graph of 4 vertices, would have a spanning tree of 3 edges. Here an edge with weights 1 and 2 must be included in MST, and we are left to choose one edge with weights remaining as 3,4,5 and 6. According to the question we have to make the weight of MST maximum. So we select edge with weight 3 such that it forms a cycle and hence it is rejected. Now we select edge with weight 4 that can be included in MST of this graph. Hence, maximum possible weight is 1+2+4 = 7.

Therefore option (C) will be the correct answer.


50) G = (V, E) is an undirected simple graph in which each edge has a distinct weight, and e is a particular edge of G. Which of the following statements about the minimum spanning trees (MSTs) of G is/are TRUE?

I. If e is the lightest edge of some cycle in G, then every MST of G includes e
II. If e is the heaviest edge of some cycle in G, then every MST of G excludes e

  1. I only
  2. II only
  3. both I and II
  4. neither I nor II

Answer: B

Explanation:

Statement 1 is False. We can see in the below Graph edge weight 3 - 4 - 5 is a cycle in which 3 is the lightest edge which cannot be included in MST.

Gate 2016 CS set 1

Statement 2 is True. In the above Graph 1-2-3 is a cycle, and 3 is the heaviest edge. If the heaviest edge is in a cycle, then we will always exclude that because if Cycle is found, then it means we can have other choices of low-cost edges

Therefore option (B) will be the correct answer.


51) Let Q denote a queue containing sixteen numbers and S be an empty stack. Head(Q) returns the element at the head of the queue Q without removing it from Q. Similarly Top(S) returns the element at the top of S without removing it from S. Consider the algorithm given below.

Gate 2016 CS set 1

The maximum possible number of iterations of the while loop in the algorithm is __________.

  1. 32
  2. 64
  3. 128
  4. 256

Answer: D

Explanation:

Here while loop will run a maximum number of times when the Queue elements sorted in the descending order. Suppose the Queue elements initially are 16, 15, 14, 13, ......, 2, 1. Now according to question 16 will be first pushed into the stack, So, stack top is 16 and Head(Q) is 15. Thus, 16 will be popped out of the stack and enqueued into the Queue. After two iterations the Queue elements will be: 15, 14, 13,....., 2, 1, 16 and stack will be empty.

Similarly, each of the remaining elements 15,14,13,......,2 will be pushed into the stack and then immediately popped out from the stack and also enqueue into the queue. After 30 iterations the stack will be empty, and the Queue contains elements like 1, 16, 15, 14,......, 2. Now 1 will be Dequeued from the queue and pushed into the stack. Once 1 is pushed into the stack, it cannot be popped again. Since currently no element present in the Queue which is less than 1, there is no way to pop 1. Here total iteration is 31 so after 31 iterations Queue is = 16, 15, 14,....., 2 and stack contains 1.

Again using the similar logic we can see that after another 29 iterations, i.e. Total = 31+29, Queue will be like 16, 15, 14,......, 3 and stack contain 1,2. Here 2 is the stack top element which will remain in the stack forever.

Doing the above step in a similar way we can see that, after 31+29+27+25+....+1 Iterations Queue will be empty. Thus, this is in A.P. series with d = 2.

Hence, Sum = (16∗(1+31))/2 = 16∗32/2 = 256. Therefore option (D) will be the right answer.


52) Consider the following context-free grammars:

G1 : S → aS | B, B → b | bB
G2 : S → aA | bB, A → aA |B | ε, B → bB | ε

Which one of the following pairs of languages is generated by G1 and G2 , respectively?

  1. {am bn |m > 0 or n > 0} and { am bn |m > 0 and n > 0}
  2. { am bn |m > 0 and n > 0} and {am bn |m > 0 or n ≥ 0}
  3. { am bn |m ≥ 0 or n > 0} and { am bn |m > 0 and n > 0}
  4. { am bn |m ≥ 0 and n > 0} and { am bn |m > 0 or n > 0}

Answer: D

Explanation:

G1 results in strings b, ab, bb, aab, abb, bbb, ... i.e ambn, m≥0 and n>0 (Because no of a's are not possible and no of a and b are independent but only b's are possible).

G2 results in strings a, b, aa, ab, bb, aaa, aab, abb, bbb, ... i.e ambn, m>0 or n>0 (Because it must have atleast 1a or 1b).

Therefore option (D) is the right answer.


53) Consider the transition diagram of a PDA given below with input alphabet Σ = {a, b} and stack alphabet Γ = {X, Z}. Z is the initial stack symbol. Let L denote the language accepted by the PDA.

Gate 2016 CS set 1

Which one of the following is TRUE?

  1. L = { an bn |n ≥ 0} and is not accepted by any finite automata
  2. L = { an |n ≥ 0} ∪ { an bn |n ≥ 0} and is not accepted by any deterministic PDA
  3. L is not accepted by any Turing machine that halts on every input
  4. L = { an |n ≥ 0} ∪ { an bn |n ≥ 0} and is deterministic context-free

Answer: D

Explanation:

Strings accepted by PDA at Ist final state are an, n≥0 and strings accepted by PDA at IInd final state are anbn, n≥0. So the language accepted by PDA is:

L = {an|n≥0}∪{anbn|n≥0}

Language is deterministic context-free(CFL) accepted by Deterministic PDA (dpda is already given) and not regular because we need a stack to implement it. Thus it cannot be accepted by FA.

Therefore option(D) will be the correct answer.


54) Let X be a recursive language and Y be a recursively enumerable but not recursive language. Let W and Z be two languages such that Y reduces to W, and Z reduces to X (reduction means the standard many-one reduction). Which one of the following statements is TRUE?

  1. W can be recursively enumerable and Z is recursive.
  2. W can be recursive and Z is recursively enumerable.
  3. W is not recursively enumerable and Z is recursive.
  4. W is not recursively enumerable and Z is not recursive.

Answer: C

Explanation:

X is recursive language, so X' is also recursive. Y is recursively enumerable, but not recursive so Y' is not recursively enumerable language.

Let W and Z two other languages such that Y' reduce to W and Z reduce to X'

Now take Y' reduce to W ( Y' --> W ): We know that recursively enumerable compliment is not recursive enumerable. So that W is not recursively enumerable.

Again Take Z to reduce to X' (Z--> X'): Since Z ≤ X' is recursive. (Rule: if Z is reducible to X', and X' is recursive, then Z is recursive.). Thus option (B) and (D) is eliminated.

Therefore option (C) is the correct answer.


55) The attributes of three arithmetic operators in some programming language are given below.

Operator Precedence Associativity Arity
+ High Left Binary
- Medium Right Binary
Low Left Binary

The value of the expression 2 - 5 + 1 - 7 ∗ 3 in this language is __________.

  1. 3
  2. 6
  3. 9
  4. 2

Answer: C

Explanation:

Given,
   Expression = 2 - 5 + 1 - 7 ∗ 3
   Now, solving the expression we get
       = 2 - 5 + 1 - 7 * 3
       = 2 - 6 - 7 * 3
       = 2 - (-1) * 3
       = 3 * 3
       = 9

Therefore option (C) will be the correct answer.


56) Consider the following Syntax Directed Translation Scheme (SDTS), with non-terminals {S, A} and terminals {a, b}.

   S - → aA { print 1 }
   S - → a { print 2 }
   A - → Sb { print 3 }

Using the above SDTS, the output printed by a bottom-up parser, for the input aab is:

  1. 1 3 2
  2. 2 2 3
  3. 2 3 1
  4. syntax error

Answer: C

Explanation:

We know that bottom-up parser builds the parse tree from bottom to up. It builds the tree from the given string to the starting symbol. In the given question, the given string is aab and starting symbol is S. So the process is to start from aab and reach S. Thus,

S→aA prints 1
A→aSb prints 3
A→aab prints 2

Now, since bottom-up parser will work in reverse order, so it will print 231. Therefore option (C) is the correct answer.


GATE 2016 CS Set 1-1
GATE 2016 CS Set 1-2
GATE 2016 CS Set 1-3
GATE 2016 CS Set 1-4
GATE 2016 CS Set 1-5
GATE 2016 CS Set 1-6
GATE 2016 CS Set 1-8






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