# GATE-CS-2003

Question 1 |

Consider the following C function.

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

x^y | |

e^x | |

ln(1 + x) | |

x^x |

**GATE-CS-2003**

**Discuss it**

Question 1 Explanation:

See question 1 of http://www.geeksforgeeks.org/data-structures-and-algorithms-set-5/

Question 2 |

Assume the following C variable declaration

int *A [10], B[10][10];Of the following expressions I A[2] II A[2][3] III B[1] IV B[2][3] which will not give compile-time errors if used as left hand sides of assignment statements in a C program?

I, II, and IV only | |

II, III, and IV only | |

II and IV only | |

IV only |

**GATE-CS-2003**

**Discuss it**

Question 2 Explanation:

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

1/4, 1/2 | |

1/2, 1/14 | |

1/2, 1 | |

1, 1/2 |

**Probability**

**GATE-CS-2003**

**Discuss it**

Question 3 Explanation:

Given, ,
We need to find the conditional probability of two given events without being told about . Also it is not mentioned that they are independent events.
But since is 1, it means that covers the complete sample space.
So,

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?

2 | |

30 | |

56 | |

256 |

**Combinatorics**

**GATE-CS-2003**

**Discuss it**

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.
This solution is contributed by

**Anil Saikrishna Devarasetty**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 is

A | |

B | |

C | |

D |

**Combinatorics**

**GATE-CS-2003**

**Discuss it**

Question 5 Explanation:

There are three options for every couple.

1) Nobody goes to gathering 2) Wife alone goes 2) Both goSince there are n couples, total possible ways of gathering are 3

^{n}Question 6 |

n-k+1 | |

n-k | |

n-k-1 | |

n-k-2 |

**Binary Search Trees**

**GATE-CS-2003**

**Discuss it**

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.

__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.__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.__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. 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, 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

does not form a group | |

forms a non-commutative group | |

does not have a right identity element | |

forms a group if the empty string is removed from ∑* |

**Set Theory & Algebra**

**GATE-CS-2003**

**Discuss it**

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

k and n | |

k - 1 and k + 1 | |

k - 1 and n - 1 | |

k + 1 and n - k |

**Graph Theory**

**GATE-CS-2003**

**Discuss it**

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?

11100111 | |

11100100 | |

11010111 | |

11011011 |

**Number Representation**

**GATE-CS-2003**

**Discuss it**

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 timeWhich of the above can cause a hazard ?

1 and 2 only | |

2 and 3 only | |

3 only | |

All of above |

**Computer Organization and Architecture**

**GATE-CS-2003**

**Pipelining and Addressing modes**

**Discuss it**

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.