Javatpoint Logo
Javatpoint Logo

GATE 2016 CS Set 2

25) N items are stored in a sorted doubly linked list. For a delete operation, a pointer is provided to the record to be deleted. For a decrease-key operation, a pointer is provided to the record on which the operation is to be performed. An algorithm performs the following operations on the list in this order: Θ(N) delete, O(log N) insert, O(log N) find, and Θ(N) decrease-key. What is the time complexity of all these operations put together?

  1. O(log2N)
  2. O(N)
  3. O(N2 )
  4. Θ(N2 log N)

Answer: C

Explanation:

Given,
Delete - Θ(1)
Insert - O(N)
Find - Θ(N)
Decrease key - Θ(N)
Now, from using above information, we get
Θ(N) ∗ Θ(1) + O(logN) ∗ O(N) + O(logN) ∗ Θ(N) + Θ(N) ∗ Θ(N)
Again, by using the property of asymptotic notation, and after removing lower terms, we get O(N2)


26) The number of states in the minimum sized DFA that accepts the language defined by the regular expression (0 + 1)∗ (0 + 1)(0 + 1)∗ is ______________.

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

Answer: D

Explanation:

Given, (0 + 1)∗ (0 + 1)(0 + 1)∗
(0 + 1) (0 + 1)∗ (Since, R∗ . R∗ = R∗)
(0 + 1 )+

Now, if we draw DFA, then we need only two states. Hence DFA will be:

Gate 2016 CS Set 2

Therefore option (D) is the right answer.


27) Language L1 is defined by the grammar: S1 → aS1b|ε

Language L2 is defined by the grammar: S2 → abS2

Consider the following statements:

P: L1 is regular
Q: L2 is regular

Which one of the following is TRUE?

  1. Both P and Q are true
  2. P is true and Q is false
  3. P is false and Q is true
  4. Both P and Q are false

Answer: C

Explanation:

S1 → aS1b|ε
Language L1 generates grammar as no of a's should be equal to no of b's. In this string all a's should precede all b's. The generated grammar is:
L1 = {anbn|n≥0}
Thus, given grammar is in a context-free language, not a regular language. Hence P is false.

S2 → abS2
Language L2 generates grammar as no of a's should be equal to no of b's. But in this created, string the order of a's and b's is different. The generated grammar is:
L2={(ab)n|n≥0}
Thus, given grammar is in a regular language having a regular expression (ab)∗. Hence Q is true.
Therefore option (C) will be the right answer.


28) Consider the following types of languages: L1: Regular, L2: Context-free, L3: Recursive, L4: Recursively enumerable. Which of the following is/are TRUE?

I. L3' ∪ L4 is recursively enumerable
II. L2' ∪ L3 is recursive
III. L1∗ ∩ L2 is context-free
IV. L1 ∪ L2' is context-free

  1. I only
  2. I and III only
  3. I and IV only
  4. I, II and III only

Answer: D

Explanation:

Statement 1: As L3 is Recursive so, L3' will also be recursive. As recursive languages are closed under union, thus L3' U L4 is also recursive.

Statement 2: As L2 is Context-Free language. L2' is not necessarily CFL, but it can be recursive. As L3 is recursive, then L2 U L3 is also recursive because recursive languages are closed under union.

Statement 3: L1∗ is regular because regular languages are closed under closure. L2 is context-free. The intersection of regular and context-free is context-free language. Thus L1∗ ∩ L2 is context-free.

Statement 4: L2' may or may not be context-free because CFL is not closed under complementation. So L1 ∪ L2' is may or may not be context-free. Thus, it is not true.

Therefore option (D) is the right answer.


29) Match the following:

Gate 2016 CS Set 2

  1. P ↔ i, Q ↔ ii, R ↔ iv, S ↔ iii
  2. P ↔ iii, Q ↔ i, R ↔ ii, S ↔ iv
  3. P ↔ ii, Q ↔ iii, R ↔ i, S ↔ iv
  4. P ↔ iv, Q ↔ i, R ↔ ii, S ↔ iii

Answer: B

Explanation:

Lexical analysis uses Regular expression.
Top-down parsing uses Left Most Derivation to generate the string.
Type checking is done at Semantic analysis phase.
Activation records loaded into stack memory at Runtime.

Therefore option (B) is the right answer.


30) In which one of the following page replacement algorithms it is possible for the page fault rate to increase even when the number of allocated frames increases?

  1. LRU (Least Recently Used)
  2. OPT (Optimal Page Replacement)
  3. MRU (Most Recently Used)
  4. FIFO (First In First Out)

Answer: D

Explanation:

According to Belady's anomaly, it proves that increasing the number of page frames results in an increase in the number of page faults when using the First in First Out (FIFO) page replacement algorithm. Hence option (D) is the right answer.


31) B+ Trees are considered BALANCED because

  1. the lengths of the paths from the root to all leaf nodes are all equal.
  2. the lengths of the paths from the root to all leaf nodes differ from each other by at most 1.
  3. the number of children of any two non-leaf sibling nodes differ by at most 1.
  4. the number of records in any two leaf nodes differ by at most 1.

Answer: A

Explanation:

A B+ tree is a self-balancing tree data structure. In B+ trees, depth (length of root to leaf) of all leaf nodes is the same. This is made possible by the insertion and deletion operations. In this, we perform insertions in a way that if we have increase height of tree after insertion, then we need to increase height from the root. Similarly, if we have to decrease height after deletion, then we need to move the root one level down. This type of insertion and deletion make sure that the depth of every leaf node is the same. Hence option (A) will be the right answer.


32) Suppose a database schedule S involves transactions T1 , . . . , Tn. Construct the precedence graph of S with vertices representing the transactions and edges representing the conflicts. If S is serializable, which one of the following orderings of the vertices of the precedence graph is guaranteed to yield a serial schedule?

  1. Topological order
  2. Depth-first order
  3. Breadth-first order
  4. Ascending order of transaction indices

Answer: A

Explanation:

We know that Serial schedule possible only if the given graph does not contain any cycle which makes sure that the schedule does not conflict serializable. Also, a graph with a topological sort must be an acyclic graph. And BFS can work with both cyclic and acyclic graphs. Hence option (A) will be the right answer.


GATE 2016 CS Set 2-1
GATE 2016 CS Set 2-2
GATE 2016 CS Set 2-3
GATE 2016 CS Set 2-5
GATE 2016 CS Set 2-6
GATE 2016 CS Set 2-7
GATE 2016 CS Set 2-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