GATE-CS-2003


Question 1

Consider the following C function. 

C

float f(float x, int y)
{
  float p, s; int i;
  for (s=1, p=1, i=1; i < y; i ++)
  {
    p*= x/i;
    s+=p;
  }
  return s;
}  

For large values of y, the return value of the function f best approximates

Cross

x^y

Tick

e^x

Cross

ln(1 + x)

Cross

x^x



Question 1-Explanation: 

The provided function computes the sum of a Taylor series approximation for (e^x) up to the (y)th term. This function is essentially approximating the exponential function (e^x).

For large values of (y), the function will approximate (e^x) more accurately because it includes more terms of the Taylor series expansion, resulting in a better approximation.

Therefore, for large values of (y), the return value of the function (f(x, y)) will best approximate (e^x).

Now,expanding ex=1+x+x2/2+x3/3+x4/4.........

So final answer should be ex

Question 2

Assume the following C variable declaration 

C

 int *A [10], B[10][10];  

Of the following expressions :

  1. A[2] 
  2. A[2][3] 
  3. B[1]
  4. B[2][3] 

which will not give compile-time errors if used as left hand sides of assignment statements in a C program?

Tick

I, II, and IV only

Cross

II, III, and IV only

Cross

II and IV only

Cross

IV only



Question 2-Explanation: 

Among expressions I (A[2]), II (A[2][3]), III (B[1]), and IV (B[2][3]), only III (B[1]) will yield a compile-time error when used as the left-hand side of assignment statements. Arrays aren't assignable in C. The rest are valid assignments referencing pointers or specific array elements.

Question 3
Let P(E) denote the probability of the event E. Given P(A) = 1, P(B) = 1/2, the values of P(A | B) and P(B | A) respectively are
Cross
1/4, 1/2
Cross
1/2, 1/14
Cross
1/2, 1
Tick
1, 1/2


Question 3-Explanation: 
Given, P(A) = 1, P(B) = \\frac{1}{2} We need to find the conditional probability of two given events without being told about P(A\\cap B). Also it is not mentioned that they are independent events. But since P(A) is 1, it means that A covers the complete sample space. So, P(A\\cap B) = P(B) = \\frac{1}{2}  P(A|B) = \\frac{P(A\\cap B)}{P(B)} = \\frac{1/2}{1/2} = 1\\\\ P(B|A) = \\frac{P(A\\cap B)}{P(A)} = \\frac{1/2}{1} = \\frac{1}{2}
Question 4

Let A be a sequence of 8 distinct integers sorted in ascending order. How many distinct pairs of sequences, B and C are there such that (i) each is sorted in ascending order, (ii) B has 5 and C has 3 elements, and (iii) the result of merging B and C gives A?
 

Cross

256
 

Tick

56
 

Cross

30
 

Cross

2
 



Question 4-Explanation: 

Suppose you have selected 3 elements from 8 in 8C3 ways, the remaining elements are treated as another array and merging both the arrays gives the sorted array. Here, you can select either 3 or 5. 

=> 8C3 = 8C5 = 8!/(3!5!) = 7*8 = 56 Ways. 
 

Question 5
n couples are invited to a party with the condition that every husband should be accompanied by his wife. However, a wife need not be accompanied by her husband. The number of different gatherings possible at the party isGATECS2003Q4
Cross
A
Tick
B
Cross
C
Cross
D


Question 5-Explanation: 
There are three options for every couple.
1) Nobody goes to gathering
2) Wife alone goes
2) Both go
Since there are n couples, total possible ways of gathering are 3n
Question 6
Let T(n) be the number of different binary search trees on n distinct elements. Then GATECS2003Q7, where x is
Cross
n-k+1
Tick
n-k
Cross
n-k-1
Cross
n-k-2


Question 6-Explanation: 
The idea is to make a key root, put (k-1) keys in one subtree and remaining n-k keys in other subtree. A Binary Search Tree (BST) is a tree in which all the nodes follow the below-mentioned properties −
  • The left sub-tree of a node has a key less than or equal to its parent node\'s key.
  • The right sub-tree of a node has a key greater than to its parent node\'s key.
Now construction binary search trees from n distinct number- Lets for simplicity consider n distinct numbers as first n natural numbers (starting from 1) If n=1 We have only one possibility, therefore only 1 BST. If n=2 We have 2 possibilities , when smaller number is root and bigger number is the right child or second when the bigger number is root and smaller number as left child.   \"parul_1\" If n=3 We have 5 possibilities. Keeping each number first as root and then arranging the remaining 2 numbers as in case of n=2. \"parul_2\"   If n=4 We have 14 possibilities. Taking each number as root and arranging smaal numbers as left subtree and larger numbers as right subtree. \"parul_4\" Thus we can conclude that with n distinct numbers, if we take ‘k’ as root then all the numbers smaller than k will left subtree and numbers larger than k will be right subtree where the the right subtree and left subtree will again be constructed recursively like the root. Therefore, \"parul5\"   This solution is contributed by Parul Sharma.
Question 7
Consider the set ∑* of all strings over the alphabet ∑ = {0, 1}. ∑* with the concatenation operator for strings
Tick
does not form a group
Cross
forms a non-commutative group
Cross
does not have a right identity element
Cross
forms a group if the empty string is removed from ∑*


Question 7-Explanation: 
The given set with the concatenation operator forms a Monoid as it follows the properties of Closure, Associativity and has an identity element(null string). It is not a Group since no element has an inverse element i.e. there is no string S for another string R such that S*R = null string.
Question 8
Let G be an arbitrary graph with n nodes and k components. If a vertex is removed from G, the number of components in the resultant graph must necessarily lie between
Cross
k and n
Cross
k - 1 and k + 1
Tick
k - 1 and n - 1
Cross
k + 1 and n - k


Question 8-Explanation: 
Minimum: The removed vertex itself is a separate connected component. So removal of a vertex creates k-1 components. Maximum: It may be possible that the removed vertex disconnects all components. For example the removed vertex is center of a star. So removal creates n-1 components.
Question 9
Assuming all numbers are in 2's complement representation, which of the following numbers is divisible by 11111011?
Tick
11100111
Cross
11100100
Cross
11010111
Cross
11011011


Question 9-Explanation: 
Since most significant bit is 1, all numbers are negative. 2\'s complement of divisor (11111011) = 1\'s complement + 1 = 00000100 + 1 = 00000101 So the given number is -5 The decimal value of option A is -25
Question 10
For a pipelined CPU with a single ALU, consider the following situations
1. The j + 1-st instruction uses the result of the j-th instruction
    as an operand
2. The execution of a conditional jump instruction
3. The j-th and j + 1-st instructions require the ALU at the same 
   time
Which of the above can cause a hazard ?
Cross
1 and 2 only
Cross
2 and 3 only
Cross
3 only
Tick
All of above


Question 10-Explanation: 
Case 1: Is of data dependency .this can’t be safe with single ALU so read after write. Case 2:Conditional jumps are always hazardous they create conditional dependency in pipeline. Case 3:This is write after read problem or concurrency dependency so hazardous All the three are hazardous So (D) is correct option.
There are 89 questions to complete.

  • Last Updated : 02 Dec, 2021

Share your thoughts in the comments
Similar Reads