• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

GATE-CS-2005

Question 81

Consider the following C-function: C
double foo (int n)
{
    int i;
    double sum;
    if (n = = 0) return 1.0;
    else
    {
        sum = 0.0;
        for (i = 0; i < n; i++)
            sum += foo (i);
        return sum;
    }
}
Suppose we modify the above function foo() and store the values of foo (i), 0 < = i < n, as and when they are computed. With this modification, the time complexity for function foo() is significantly reduced. The space complexity of the modified function would be:
  • O(1)
  • O(n)
  • O(n!)
  • O(nn)

Question 82

Let s and t be two vertices in a undirected graph G + (V, E) having distinct positive edge weights. Let [X, Y] be a partition of V such that s ∈ X and t ∈ Y. Consider the edge e having the minimum weight amongst all those edges that have one vertex in X and one vertex in Y The edge e must definitely belong to:

  • the minimum weighted spanning tree of G

  • the weighted shortest path from s to t

  • each path from s to t

  • the weighted longest path from s to t

Question 83

Let s and t be two vertices in a undirected graph G + (V, E) having distinct positive edge weights. Let [X, Y] be a partition of V such that s ∈ X and t ∈ Y. Consider the edge e having the minimum weight amongst all those edges that have one vertex in X and one vertex in Y. Let the weight of an edge e denote the congestion on that edge. The congestion on a path is defined to be the maximum of the congestions on the edges of the path. We wish to find the path from s to t having minimum congestion. Which one of the following paths is always such a path of minimum congestion?
  • a path from s to t in the minimum weighted spanning tree
  • a weighted shortest path from s to t
  • an Euler walk from s to t
  • a Hamiltonian path from s to t

Question 84

Consider the following expression grammar. The seman­tic rules for expression calculation are stated next to each grammar production.
 E → number 	 E.val = number. val
    | E \'+\' E 	 E(1).val = E(2).val + E(3).val
    | E \'×\' E	 E(1).val = E(2).val × E(3).val
The above grammar and the semantic rules are fed to a yacc tool (which is an LALR (1) parser generator) for parsing and evaluating arithmetic expressions. Which one of the following is true about the action of yacc for the given grammar?
  • It detects recursion and eliminates recursion
  • It detects reduce-reduce conflict, and resolves
  • It detects shift-reduce conflict, and resolves the conflict in favor of a shift over a reduce action
  • It detects shift-reduce conflict, and resolves the conflict in favor of a reduce over a shift action

Question 85

Consider the following expression grammar. The seman­tic rules for expression calculation are stated next to each grammar production.
 E → number 	 E.val = number. val
    | E \'+\' E 	 E(1).val = E(2).val + E(3).val
    | E \'×\' E	 E(1).val = E(2).val × E(3).val 
Assume the conflicts in Part (a) of this question are resolved and an LALR(1) parser is generated for parsing arithmetic expressions as per the given grammar. Consider an expression 3 × 2 + 1. What precedence and associativity properties does the generated parser realize?
  • Equal precedence and left associativity; ex­pression is evaluated to 7
  • Equal precedence and right associativity; ex­pression is evaluated to 9
  • Precedence of \'×\' is higher than that of \'+\', and both operators are left associative; expression is evaluated to 7
  • Precedence of \'+\' is higher than that of \'×\', and both operators are left associative; expression is evaluated to 9

Question 86

We are given 9 tasks T1, T2.... T9. The execution of each task requires one unit of time. We can execute one task at a time. Each task Ti has a profit Pi and a deadline di Profit Pi is earned if the task is completed before the end of the dith unit of time.
Task     T1  T2	 T3  T4  T5  T6	 T7 T8  T9
Profit   15  20	 30  18  18  10	 23 16  25
Deadline 7   2 	 5   3 	 4   5 	 2  7   3 
Are all tasks completed in the schedule that gives maximum profit?
  • All tasks are completed
  • T1 and T6 are left out
  • T1 and T8 are left out
  • T4 and T6 are left out

Question 87

We are given 9 tasks T1, T2.... T9. The execution of each task requires one unit of time. We can execute one task at a time. Each task Ti has a profit Pi and a deadline di Profit Pi is earned if the task is completed before the end of the dith unit of time.
Task     T1  T2	 T3  T4  T5  T6	 T7 T8  T9
Profit   15  20	 30  18  18  10	 23 16  25
Deadline 7   2 	 5   3 	 4   5 	 2  7   3 
What is the maximum profit earned?
  • 147
  • 165
  • 167
  • 175

Question 88

Consider the following floating point format GATECS2005Q84A Mantissa is a pure fraction in sign-magnitude form. The decimal number 0.239 × 213 has the following hexadecimal representation (without normalization and rounding off :
  • 0D 24
  • 0D 4D
  • 4D 0D
  • 4D 3D

Question 89

Consider the following floating point format GATECS2005Q84A Mantissa is a pure fraction in sign-magnitude form. The normalized representation for the above format is specified as follows. The mantissa has an implicit 1 preceding the binary (radix) point. Assume that only 0\'s are padded in while shifting a field. The normalized representation of the above number (0.239 × 213) is:
  • 0A 20
  • 11 34
  • 4D D0
  • 4A E8

Question 90

Suppose n processes, P1, …. Pn share m identical resource units, which can be reserved and released one at a time. The maximum resource requirement of process Pi is Si, where Si > 0. Which one of the following is a sufficient condition for ensuring that deadlock does not occur?
  • A
  • B
  • C
  • D

There are 90 questions to complete.

Last Updated :
Take a part in the ongoing discussion