# GATE CS 1997

 Question 1
The probability that it will rain today is 0.5. The probability that it will rain tomorrow is 0.6. The probability that it will rain either today or tomorrow is 0.7. What is the probability that it will rain today and tomorrow? 0.3 0.25 0.35 0.4

Question 1-Explanation:
Let A is the event that it will rain today and B is the event that it will rain tomorrow.
```probability (A intersection B) = probability ( A ) + probability (B) - probability (A union B).
probability (A intersection B) = 0.5 + 0.6 - 0.7 = 0.4 ```
 Question 2
The Newton-Raphson method is used to find the root of the equation x- 2 = 0. If the iterations are started from -1, the iterations will a. converge to -1 b. converge to √2 c. converge to -√2 d. not converge a b c d

 Question 3
The determinant of the matrix is  11 -48 0 -24

Question 3-Explanation:
The determinant value of a upper or lower triangular matrix is the product of the elements in the principal diagnol. This can be easily proved by expanding along the first row or the first column depending on whether the matrix is lower triangular or upper triangular. Determinant value = 6 * 2 * 4 * -1 = -48 Therefore option (B) is correct. This explanation is provided by Chirag Manwani.
 Question 4

The concatenation of two lists is to be performed in O(1) time. Which of the following implementations of a list should be used? singly linked list doubly linked list circular doubly linked list array implementation of lists

Question 4-Explanation:
As list concatenation requires traversing at least one list to the end. So singly linked list and doubly linked list requires O(n) time complexity whereas circular doubly linked list required O(1) time.

 Question 5
The correct matching for the following pairs is
```(A) All pairs shortest path          (1) Greedy
(B) Quick Sort                       (2) Depth-First search
(C) Minimum weight spanning tree     (3) Dynamic Programming
(D) Connected Components             (4) Divide and and Conquer
```
```Codes:
A    B    C    D
a    2    4    1    3
b    3    4    1    2
c    3    4    2    1
d    4    1    2    3
``` a b c d

 Question 6
In the following grammar
```X :: = X ⊕ Y / Y
Y :: = Z * Y / Z
Z :: = id
```
Which of the following is true? a. '⊕' is left associative while '*' is right associative b. Both '⊕' and '*' are left associative c. '⊕' is right associative while '*' is left associative d. None of the above a b c d

Question 6-Explanation:
X :: = X ⊕ Y is left recursive grammar, so ‘⊕’ is left associative and Z * Y is right recursive grammar, so ‘*’ is right associative.
 Question 7
Which of the following is essential for converting an infix expression to the postfix from efficiently ? An operator stack An operand stack An operand stack and an operator stack A parse tree

Question 7-Explanation:
Operator stack is used for converting infix to postfix expression such that operators like as +, *, (, ), / are pushed in stack where as operand stack is used for converting Postfix to Prefix evaluation such that operands are 7,2,1,2 etc. Hence, option (A) is correct.
 Question 8
A language L allows declaration of arrays whose sizes are not known during compilation. It is required to make efficient use of memory. Which of the following is true? A compiler using static memory allocation can be written for L A compiler cannot be written for L, an interpreter must be used A compiler using dynamic memory allocation can be written for L None of the above

Question 8-Explanation:
If a language L allows declaration of arrays whose sizes are not known during compilation time. It is required to use efficient use of memory. So a compiler using dynamic memory allocation can be written for L. An array is a collection of data items, all of the same type, accessed using a common name. C dynamic memory allocation refers to performing manual memory management for dynamic memory allocation in the C programming language via a group of functions in the C standard library, namely malloc, realloc, calloc and free.
 Question 9
The condition expansion facility of macro processors is provided to test a condition during the execution of the expanded program to expand certain model statements depending upon the value of a condition during the execution of the expanded program to implement recursion to expand certain model statements depending upon the value of a condition during the process of macros expansion

Question 9-Explanation:
Macro processors provided a condition expansion facility to expand the certain module statements depending upon the value of a condition during the process of macros expansion. Hence, option (D) is correct.
 Question 10
Heap allocation is required for languages that support recursion that support dynamic data structures that use dynamic scope rules none of the above

There are 75 questions to complete.
• Last Updated : 11 Oct, 2021