Javatpoint Logo
Javatpoint Logo

25. Consider the following C program

The output of the program is __________.

  1. 0
  2. 2016
  3. 1008
  4. 2014

Answer: B

Explanation:

a and d cannot be swapped because the function mystery() doesn't change values. It means function mystery is not swapping values. It is just swapping the pointer ptra and ptrb to a location pointed by ptrb and ptra respectively which does not affect the values in the main function.

Therefore option (B) will be the correct answer.


26) Which of the following languages is generated by the given grammar?

S→ aS | bS | ε

  1. {an bm | n, m ≥ 0}
  2. {w ∈ {a, b}* | w has equal number of a's and b's }
  3. {an | n ≥ 0} ∪ {bn | n ≥ 0} ∪ {an bn | n ≥ 0}
  4. {a, b}*

Answer: D

Explanation:

Given,
   Grammar S→ aS | bS | ε
   The DFA of the given grammar is,

Gate 2016 CS set 1

The grammar generates following string ε, a, ab, abb, b, aaa, .......

Therefore, the language of the string is: {a, b}*

Hence, option (D) will be the correct answer.


27) Which of the following decision problems are undecidable?

I. Given NFAs N1 and N2 , is L( N1 ) ∩ L( N2 ) = Φ?
II. Given a CFG G = (N, Σ, P, S) and a string x ∈ Σ* , does x ∈ L(G)?
III. Given CFGs G1 and G2 , is L(G 1 ) = L( G2 )?
IV. Given a TM M, is L(M) = Φ?

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

Answer: C

Explanation:

A decision problem is undecidable if there is no algorithm available to find the solution for it. As we know that the equality problem is always undecidable in the case of CFL, CSL, RL, and RE, similarly Emptiness problem is Undecidable in the case of TM, CSL, RL. Since problem give in, III and IV have no solutions, so these are undecidable.

Therefore option (C) will be the correct answer.


28) Which one of the following regular expressions represents the language: the set of all binary strings having two consecutive 0s and two consecutive 1s?

  1. (0 + 1) * 0011(0 + 1)* + (0 + 1)* 1100(0 + 1)*
  2. (0 + 1)* (00(0 + 1)* 11 + 11(0 + 1)* 00)(0 + 1)*
  3. (0 + 1)* 00(0 + 1)* + (0 + 1)* 11(0 + 1)*
  4. 00(0 + 1)* 11 + 11(0 + 1)* 00

Answer: B

Explanation:

Analyze each option one by one:

It represents those strings which contain 0011 or 1100 as a substring.

It represents those strings in which 00 and 11 both are neither immediate, nor they give a predefined order. It provides the set of all binary strings which has two consecutive 0s and two consecutive 1s.

It represents those strings which contain 00 or 11 as a substring.

It represents those strings that start with 11 and end with 00 or start with 00 and ending with 11.

Therefore option (B) is the correct answer.


29) Consider the following code segment.

x = u - t;
y = x * v;
x = y + w;
y = t - z;
y = x * y;

The minimum number of total variables required to convert the above code segment to static single assignment form is __________.

  1. 6
  2. 8
  3. 10
  4. 12

Answer: C

Explanation:

Static Single Assignment form is used for intermediate code in compiler design. In this, each assignment to a variable should be specified with unique names.

In the given code there are two code segment assign with the same variable x:
   x = u - t;
   x = y + w;

and three code segment assign with the same variable y:
   y = x * v;
   y = t - z;
   y = x * y

So distinct assignment variable for each code segment can be specifying as below:
   x1 = u - t;
   y1 = x1 * v;
   x2 = y1 + w;
   y2 = t - z;
   y3 = x2 * y2;

So, total number of variables is 10 (x1, x2, y1, y2, y3, t, u, v, w, z).

Therefore option (C) will be the correct answer.


30) Consider an arbitrary set of CPU-bound processes with unequal CPU burst lengths submitted at the same time to a computer system. Which one of the following process scheduling algorithms would minimize the average waiting time in the ready queue?

  1. Shortest remaining time first
  2. Round-robin with time quantum less than the shortest CPU burst
  3. Uniform random
  4. Highest priority first with priority proportional to CPU burst length

Answer: A

Explanation:

Shortest Job First(SJF) gives minimum turn round time, the minimum average waiting time and high throughput thus it is optimal in all CPU Scheduling algorithms.

Again Shortest Remaining Time First (SRTF) is the pre-emptive shortest job first Scheduling algorithm. This scheduling algorithm may lead to a starvation problem because if the processes have arrived continuously in the scheduler, then the currently running process will never be able to execute as they will get pre-empted.

Thus, in the given question all the processes have arrived at the same time, so there is no issue of starvation.

Therefore option (A) will be the correct answer.


31) Which of the following is NOT a super key in a relational schema with attributes V, W, X, Y, Z and primary key V Y ?

  1. V XY Z
  2. VW XZ
  3. VW XY
  4. VW XY Z

Answer: B

Explanation:

We know,
   Super Key = Candidate Key/Primary Key + other attributes
   So option A, C, D have a Primary Key V Y, so it is a Super Key.
   Option (B) does not have a Primary Key V Y so it will not be a Super Key.
   Therefore option (B) is the right answer.


32) Which one of the following is NOT a part of the ACID properties of database transactions?

  1. Atomicity
  2. Consistency
  3. Isolation
  4. Deadlock-freedom

Answer: D

Explanation:

The ACID model is one of the most important concepts of database theory. In a database, every transaction may contain several low-level tasks and a very small unit of the program. There is a set of properties that guarantee that database transactions are processed reliably. These properties are called ACID properties which refers to the four key properties of a transaction:

A - Atomicity
C - Consistency
I - Isolation
D - Durability

Therefore option (D) 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-5
GATE 2016 CS Set 1-6
GATE 2016 CS Set 1-7
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