Question 1 |

The minimum number of cards to be dealt from an arbitrarily shuffled deck of 52 cards to guarantee that three cards are from some same suit is

3 | |

8 | |

9 | |

12 |

**General Aptitude**

**GATE-CS-2000**

**Discuss it**

Question 1 Explanation:

Total number of suits is 4
We need minimum 9 cards to make sure that there are 3 cards of same suit.
For example, With 8 cards, we can have 2 cards of each suit.

Question 2 |

An n x n array v is defined as follows:

v[i, j] = i-j for all i, j, 1 <= i <= n, 1 <= j <= nThe sum of the elements of the array v is

0 | |

n-1 | |

n ^{2} - 3n + 2 | |

n ^{2} (n+1)/2 |

**Misc**

**GATE-CS-2000**

**Discuss it**

Question 2 Explanation:

In this case, the matrix would be

Thus, A is the correct choice.

Please comment below if you find anything wrong in the above post.

0 -1 -2 -3 -4 -5 -6 -7 ... -n 1 0 -1 -2 -3 -4 -5 -6 ... -(n-1) 2 1 0 -1 -2 -3 -4 -5 ... -(n-2) 3 2 1 0 -1 -2 -3 -4 ... -(n-3) 4 3 2 1 0 -1 -2 -3 ... -(n-4) 5 4 3 2 1 0 -1 -2 ... -(n-5) 6 5 4 3 2 1 0 -1 ... -(n-6) 7 6 5 4 3 2 1 0 ... -(n-6) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . n n-1 n-2 n-3 n-4 n-5 n-6 n-7 ... 2 1Now, we take the sum of first row and first column, which comes out to be zero. Similarly, we take the sum of second row and second column, third row and third column, and so on, and it is found that all have a sum equal to zero. So, the sum of all the elements in the matrix is zero.

Thus, A is the correct choice.

Please comment below if you find anything wrong in the above post.

Question 3 |

5 | |

0 | |

4 | |

20 |

**Linear Algebra**

**GATE-CS-2000**

**Discuss it**

Question 3 Explanation:

The value of determinant is 2*1*2*1

Question 4 |

Let S and T be language over Σ = {a,b} represented by the regular expressions (a+b*)* and (a+b)*, respectively. Which of the following is true?

S ⊂ T | |

T ⊂ S | |

S = T | |

S ∩ T = φ |

**Regular languages and finite automata**

**GATE-CS-2000**

**Discuss it**

Question 4 Explanation:

Both have same output because if we draw DFA of S which is (a+b*)*, at final state it is just repeating.

Question 5 |

Let L denotes the language generated by the grammar S -> 0S0/00. Which of the following is true?

L = 0+ | |

L is regular but not 0+ | |

L is context free but not regular | |

L is not context free |

**Regular languages and finite automata**

**GATE-CS-2000**

**Discuss it**

Question 5 Explanation:

Option A :

**L is not 0+**, because 0+ will contain any arbitrary string over alphabet 0 with any no of 0's ( except empty string ), for ex: {0, 00, 000,00000}, but L will only have the strings as { 00, 0000, 000000,...}, i.e only even no of 0's ( excluding empty string}. Option D :**L is a Context Free Language**, because the Grammar G which generates the language L is Context Free Grammar. A Grammar G is CFG if all of its productions are of the form A->α, where A is a single non-terminal and α belongs to (V∪ T)* , i.e α can be a string of terminals and/or Non-terminals. (V represents a non-terminal and T represents a terminal) Option C :**L is a Regular Language**, Because we are able to write a regular expression for it ( and also able to make a Finite Automaton), which is (00)+. Option B : Hence This option is Correct, because L is Regular but not 0+, as we proved above.Question 6 |

The number 43 in 2's complement representation is

01010101 | |

11010101 | |

00101011 | |

10101011 |

**Number Representation**

**GATE-CS-2000**

**Discuss it**

Question 6 Explanation:

In2's complement representation, positive numbers are represented as their representation and negative numbers are represented by first doing 1's complement, then adding 1 to the result.
So 43 is represented as 00101011.
Note that option represents -43.

Question 7 |

To put the 8085 microprocessor in the wait state

lower the-HOLD input | |

lower the READY input | |

raise the HOLD input | |

raise the READY input |

**Microprocessor**

**GATE-CS-2000**

**Discuss it**

Question 7 Explanation:

- If ready pin is high the microprocessor will complete the operation and proceeds for the next operation.
- If ready pin is low the microprocessor will wait until it goes high. Thus, option (B) is the answer. Please comment below if you find anything wrong in the above post.

Question 8 |

Comparing the time T1 taken for a single instruction on a pipelined CPU with time T2 taken on a non pipelined but identical CPU, we can say that

T1 <= T2 | |

T1 >= T2
| |

T1 < T2 | |

T1 is T2 plus the time taken for one instruction fetch cycle |

**Computer Organization and Architecture**

**GATE-CS-2000**

**Discuss it**

Question 8 Explanation:

*Pipelining does not increase the execution time of a single instruction. It increases the overall performance by executing instructions in multiple pipeline stages.*We assume that each stage takes ‘T’ unit of time both in pipelined and non-pipelined CPU. Let total stages in pipelined CPU = Total stages in non-pipelined CPU = K and number of Instructions = N = 1

- Pipelined CPU : Total time (T1) = (K + (N - 1)) * T = KT
- Non-Pipelined CPU : Total time (T2) = KNT = KT
Considering buffer delays in pipelined CPU,
**T1 >= T2****Thus, option (B) is the answer.**Please comment below if you find anything wrong in the above post.

Question 9 |

The 8085 microprocessor responds to the presence of an interrupt

As soon as the TRAP pin becomes 'high'
| |

By checking the TRAP pin for 'high' status at the end of each instruction fetch | |

By checking the TRAP pin for 'high' status at the end of the execution of each instruction | |

By Checking the TRAP pin for 'high' status at regular intervals |

**Microprocessor**

**GATE-CS-2000**

**Discuss it**

Question 9 Explanation:

**Explanation:**The microprocessor recognizes interrupt request on request lines(RST7.5,RST 5.5,RST 6.5,TRAP,INTR) at the end of current instruction execution. TRAP is non maskable interrupt .TRAP is active high ,level,edge triggered non maskable highest priority interrupt.when TRAP line is active microprocessor insert intervals restarts automatically at vector location of TRAP. So correct option is (C).

Question 10 |

The most appropriate matching for the following pairs

X: Indirect addressing 1 : Loops Y: Immediate addressing 2 : Pointers Z: Auto decrement addressing 3: Constantsis

X-3, Y-2, Z-1
| |

X-I, Y-3, Z-2 | |

X-2, Y-3, Z-1 | |

X-3, Y-l, Z-2 |

**Microprocessor**

**GATE-CS-2000**

**Discuss it**

Question 10 Explanation:

**Explanation:**In

**Indirect addressing mode**the instruction does not have the address of the data to be operated on,but the instruction points where the address is stored(it is indirectly specifying the address of memory location where the data is stored or to be stored) In

**immediate addressing mode**the data is to be used is immediately given in instruction itself;so it deals with constant data. In

**Autodecrement addressing mode**, Before determining the effective address, the value in the base register is decremented by the size of the data item which is to be accessed. Within a loop, this addressing mode can be used to step backwards through all the elements of an array or vector. So (C) is correct option.

Question 11 |

The following C declarations

struct node { int i; float j; }; struct node *s[10] ;define s to be

An array, each element of which is a pointer to a structure of type node | |

A structure of 2 fields, each field being a pointer to an array of 10 elements | |

A structure of 3 fields: an integer, a float, and an array of 10 elements | |

An array, each element of which is a structure of type node. |

**Structure & Union**

**GATE-CS-2000**

**Discuss it**

Question 11 Explanation:

// The following code declares a structure struct node { int i; float j; }; // The following code declares and defines an array s[] each // element of which is a pointer to a structure of type node struct node *s[10] ;

Question 12 |

The most appropriate matching for the following pairs

X: m=malloc(5); m= NULL; 1: using dangling pointers Y: free(n); n->value=5; 2: using uninitialized pointers Z: char *p; *p = ’a’; 3. lost memory is:

X—1 Y—3 Z ---2
| |

(X—2 Y—1 Z --3 | |

X—3 Y—2 Z--1 | |

X—3 Y—1 Z--2 |

**GATE-CS-2000**

**Discuss it**

Question 12 Explanation:

Question 13 |

The most appropriate matching for the following pairs

X: depth first search 1: heap Y: breadth-first search 2: queue Z: sorting 3: stackis

X—1 Y—2 Z --3 | |

X—3 Y—1 Z --2 | |

X—3 Y—2 Z--1 | |

X—2 Y—3 Z--1 |

**GATE-CS-2000**

**Discuss it**

Question 13 Explanation:

Stack is used for Depth first Search
Queue is used for Breadth First Search
Heap is used for sorting

Question 14 |

Consider the following nested representation of binary trees: (X Y Z) indicates Y and Z are the left and right sub stress, respectively, of node X. Note that Y and Z may be NULL, or further nested. Which of the following represents a valid binary tree?

(1 2 (4 5 6 7))
| |

(1 (2 3 4) 5 6) 7) | |

(1 (2 3 4)(5 6 7)) | |

(1 (2 3 NULL) (4 5)) |

**GATE-CS-2000**

**Discuss it**

Question 14 Explanation:

To solve this question we have to look at two things:
1) In a binary tree, a node may have at most 2 children.
2) To construct binary tree from the given sequences above, innermost parenthesis should be worked first.
In Option A : ( 4 5 6 7 ) is there, which says that node 4 has got three children, which is wrong for a binary tree, and also in the question, only ( X Y Z ) is defined, i.e. a node X can have at most 2 children, which will be the roots of subtrees Y and Z.
In Option B : after working on innermost (2 3 4), where 2 is a node of the binary tree, 3 is left subtree of node 2 and 4 is right subtree of node 2. From this we get (1 2 5 6). Here 2 has come from the root of subtree ( 2 3 4 ). Now again we don't have any definition for ( 1 2 5 6). Hence invalid.
In Option C: after working on ( 2 3 4) and ( 5 6 7 ) we get ( 1 2 5 ) where 2 has come from the root of subtree ( 2 3 4 ) and 5 has come from the root of subtree ( 5 6 7 ). Now, in ( 1 2 5 ) node 1 is the root of the binary tree, and subtree with root 2 is the left subtree and subtree with root 5 is the right subtree at root node 1. Hence it is giving valid binary tree.
In Option D: It is given as ( 2 3 NULL), here N,U,L and L are given as different elements, which is again wrong as according to ( X Y Z) definition, a node can have at most 2 children.

Question 15 |

Let s be a sorted array of n integers. Let t(n) denote the time taken for the most efficient algorithm to determined if there are two elements with sum less than 1000 in s. which of the following statements is true?

a) t (n) is O(1) b) n < t (n) < n c) n log 2 n < t (n) < d) t (n) = [/Tex]{n \choose 2} [/Tex]

a | |

b | |

c | |

d |

**GATE-CS-2000**

**Discuss it**

Question 15 Explanation:

Let array be sorted in ascending order, if sum of first two elements is less than 1000 then there are two elements with sum less than 1000 otherwise not. For array sorted in descending order we need to check last two elements. For an array data structure, number of operations are fixed in both the cases and not dependent on n, complexity is O(1)

Question 16 |

Aliasing in the context of programming languages refers to

multiple variables having the same memory location
| |

multiple variables having the same value | |

multiple variables having the same identifier | |

multiple uses of the same variable |

**Principles of Programming Languages**

**GATE-CS-2000**

**Discuss it**

Question 16 Explanation:

Refer question 2 of http://www.geeksforgeeks.org/principle-of-programming-languages-set-1/

Question 17 |

Consider the following C declaration

struct { short s [5] union { float y; long z; }u; } t;Assume that objects of the type short, float and long occupy 2 bytes, 4 bytes and 8 bytes, respectively. The memory requirement for variable t, ignoring alignment considerations, is

22 bytes | |

14 bytes | |

18 bytes | |

10 bytes |

**GATE-CS-2000**

**Discuss it**

Question 17 Explanation:

See question 3 of http://www.geeksforgeeks.org/c-language-set-1/

Question 18 |

The number of tokens in the following C statement.

printf("i = %d, &i = %x", i, &i);is

3 | |

26 | |

10 | |

21 |

**GATE-CS-2000**

**Discuss it**

Question 18 Explanation:

See question 4 of http://www.geeksforgeeks.org/c-language-set-1/

Question 19 |

Which of the following derivations does a top-down parser use while parsing an input string? The input is assumed to be scanned in left to right order.

Leftmost derivation | |

Leftmost derivation traced out in reverse
| |

Rightmost derivation | |

Rightmost derivation traced out in reverse |

**Parsing and Syntax directed translation**

**GATE-CS-2000**

**Discuss it**

Question 19 Explanation:

See question 1 of http://www.geeksforgeeks.org/compilers-set-1/

Question 20 |

Which of the following need not necessarily be saved on a context switch between processes?

General purpose registers | |

Translation look aside buffer | |

Program counter | |

All of the above |

**Process Management**

**GATE-CS-2000**

**Discuss it**

Question 20 Explanation:

See question 2 of http://www.geeksforgeeks.org/operating-systems-set-3/

Question 21 |

Let m[0]…m[4] be mutexes (binary semaphores) and P[0] …. P[4] be processes.
Suppose each process P[i] executes the following:

wait (m[i]); wait(m[(i+1) mode 4]); ------ release (m[i]); release (m[(i+1)mod 4]);This could cause:

Thrashing | |

Deadlock | |

Starvation, but not deadlock | |

None of the above |

**GATE-CS-2000**

**Deadlock**

**Discuss it**

Question 21 Explanation:

See question 2 of http://www.geeksforgeeks.org/operating-systems-set-1/

Question 22 |

B+ -trees are preferred to binary trees in databases because

Disk capacities are greater than memory capacities | |

Disk access is much slower than memory access | |

Disk data transfer rates are much less than memory data transfer rates | |

Disks are more reliable than memory |

**GATE-CS-2000**

**Discuss it**

Question 22 Explanation:

Question 23 |

Given the relations

employee (name, salary, deptno) and department (deptno, deptname, address)Which of the following queries cannot be expressed using the basic relational algebra operations (U, -, x, , , p)?

Department address of every employee | |

Employees whose name is the same as their department name | |

The sum of all employees’ salaries | |

All employees of a given department |

**Database Design(Normal Forms)**

**GATE-CS-2000**

**Discuss it**

Question 23 Explanation:

See question 1 of http://www.geeksforgeeks.org/database-management-system-set-1/

Question 24 |

X, Y and Z are closed intervals of unit length on the real line. The overlap of X and Y is half a unit. The overlap of Y and Z is also half a unit. Let the overlap of X and Z be k units. Which of the following is true?

k must be 1 | |

k must be 0 | |

k can take any value between 0 and 1 (d) None
of the above | |

None of the above |

**Misc**

**GATE-CS-2000**

**Discuss it**

Question 25 |

E1 and E2 are events in a probability space satisfying the following constraints:

Pr(E1) = Pr(E2) Pr(EI U E2) = 1 E1 and E2 are independentThe value of Pr(E1), the probability of the event E1 is

0 | |

1/4 | |

1/2 | |

1 |

**Probability**

**GATE-CS-2000**

**Discuss it**

Question 25 Explanation:

Given Constraints:
1. Pr(E1) = Pr(E2)
2. Pr( E1 U E2) = 1
3. E1 and E2 are independent
As we know:
Pr(E1 U E2) = Pr(E1) + Pr(E2) – Pr(E1 ∩ E2)
As E1 and E2 are independent events. (cond.3)
So Pr(E1 ∩ E2) = Pr(E1) Pr(E2)
Pr(E1) = Pr(E2) (cond.2)
let probability of Event E1 = x = prob of E2
So,
Pr(E1 U E2) = Pr(E1) + Pr(E2) – Pr(E1) Pr(E2)
1 = x + x -x* x (cond. 1)
1=2x-x^2
x^2-2x+1 = 0
(x-1)^2 = 0
x = 1
So, Pr(E1) = Pr(E2) = 1
Thus, option (D) is the answer.
Reference :
https://people.richland.edu/james/lecture/m170/ch05-rul.html
This solution is contributed by

Pr(E1 U E2) = Pr(E1) + Pr(E2) – Pr(E1) Pr(E2)

Pr(E1) = Pr(E2) (given)

So,

2 * Pr(E1) – Pr(E1)

2 * Pr(E1) – Pr(E1)

So, Pr(E1) = Pr(E2) = 1

Thus, option (D) is the answer.

**Nitika Bansal.****Another Solution :**E1 and E2 are independent events.Pr(E1 U E2) = Pr(E1) + Pr(E2) – Pr(E1) Pr(E2)

Pr(E1) = Pr(E2) (given)

So,

2 * Pr(E1) – Pr(E1)

^{2}= Pr( E1 U E2)2 * Pr(E1) – Pr(E1)

^{2}= 1So, Pr(E1) = Pr(E2) = 1

Thus, option (D) is the answer.

Question 27 |

A polynomial p(x) satisfies the following:

p(1) = p(3) = p(5) = 1 p(2) = p(4) = -1The minimum degree of such a polynomial is

1 | |

2 | |

3 | |

4 |

**Numerical Methods and Calculus**

**GATE-CS-2000**

**Discuss it**

Question 27 Explanation:

p(1) = p(3) = p(5) = 1 p(2) = p(4) = -1 The polynomial touches 0 at least once from 1 to 2, so there is a root between 1 to 2 The polynomial touches 0 at least once from 2 to 3, so there is a root between 2 to 3 Similarly, there is at least one root from 3 to 4 and 4 to 5. So minimum degree is 4.

Question 28 |

A relation R is defined on the set of integers as xRy if f(x + y) is even. Which of the following statements is true?

R is not an equivalence relation | |

R is an equivalence relation having 1 equivalence class | |

R is an equivalence relation having 2 equivalence classes | |

R is an equivalence relation having 3 equivalence classes |

**Set Theory & Algebra**

**GATE-CS-2000**

**Discuss it**

Question 28 Explanation:

There are 2 2 equivalence classes.
1) All odd integers. (Reflexive as sum of two even is even, Symmetric and Transitive as + operation is Symmetric and Transitive)
2) All Even Integers. (Reflexive as sum of two odd is even, Symmetric and Transitive as + operation is Symmetric and Transitive)

Question 29 |

a | |

b | |

c | |

d |

**Set Theory & Algebra**

**GATE-CS-2000**

**Discuss it**

Question 29 Explanation:

Ex: let a set ‘s’ be, s={1,2}
Power-set(s)=P(s)={{},{1},{2},{1,2}} Note: ‘{}’ denotes empty or NULL set or φ.
In general, if a set ‘s’ contains ‘n’ elements, power-set will contain 2^n elements, that denotes set of all subset of ‘s’.
Solution: Option (a): P(P(S))=P(S) If, S={1} P(S)={ φ, {1}} P(P(S))={ φ,{ φ},{1},{ φ, {1}}}
NOTE: LHS is set of set of subsets of ‘S’ and RHS is set of subsets of ‘S’. So, we can conclude this option is false.
Option (b): P(P(S)) ∩P(S)={ φ}.
If, S={1}
P(S)={ φ, {1}}
P(P(S))={ φ,{ φ},{1},{ φ, {1}}}
P(P(S)) ∩P(S)= { φ}=RHS
So, we can conclude this option is TRUE.
Option (a): P(S) ∩S=P(S)
If, S={1}
P(S)={ φ, {1}}
P(S) ∩S= φ
NOTE: We can’t find anything common in set of elements (S) and set of sets(P(S)).
So, we can conclude this option is false.
Option (a): S ∉ P(S)
If, S={1}
P(S)={ φ, {1}}
Clearly, S is subset of P(S).
NOTE: By definition only, its clear that power-set is set of all subset that will contain S also.
So, we can conclude this option is false.
This solution is contributed by

**S****andeep pandey.**Question 30 |

Let a, b, c, d be propositions. Assume that the equivalences a ↔ (b V-b) and b ↔ c hold. Then the truth value of the formula (a ∧ b) → (a ∧ c) ∨ d) is always

True | |

False | |

Same as the truth value of b | |

Same as the truth value of d |

**Propositional and First Order Logic.**

**GATE-CS-2000**

**Discuss it**

Question 31 |

What can be said about a regular language L over {a} whose minimal finite state automaton has two states?

L must be {a ^{n}| n is odd} | |

L must be {a ^{n}| n is even} | |

L must be {a ^{n}| ³ O} | |

Either L must be {a ^{n} | n is odd}, or L must be {a^{n} | n is even} |

**Regular languages and finite automata**

**GATE-CS-2000**

**Discuss it**

Question 31 Explanation:

There are two states. When first state is final, it accepts even no. of a's. When second state is final, it accepts odd no. of a's.

Question 32 |

Consider the following decision problems:

(P1) Does a given finite state machine accept a given string (P2) Does a given context free grammar generate an infinite number of stingsWhich of the following statements is true?

Both (P1) and (P2) are decidable | |

Neither (P1) nor (P2) are decidable
| |

Only (P1) is decidable | |

Only (P2) is decidable |

**Undecidability**

**GATE-CS-2000**

**Discuss it**

Question 32 Explanation:

- A finite state machine always halts in final or non-final state.Therefore, problem P1 is decidable.
- We check if the context free language generates any string of length between n and (2n – 1). If so, context free language is infinite else it is finite.Therefore, problem P2 is decidable.
**Thus, option (A) is correct.**Please comment below if you find anything wrong in the above post.

Question 33 |

The simultaneous equations on the Boolean variables x, y, z and w,

have the following solution for x, y, z and w, respectively.

0 1 0 0 | |

1 1 0 1 | |

1 0 1 1 | |

1 0 0 0 |

**Digital Logic & Number representation**

**GATE-CS-2000**

**Discuss it**

Question 33 Explanation:

We solve this question by putting in the options in the statements.
Statement 1 : x + y + z = 1

OPTION x y z w LHS LHS=1 -------------------------------------- A 0 1 0 0 1 Yes B 1 1 0 1 1 Yes C 1 0 1 1 1 Yes D 1 0 0 0 1 YesTill now, all the options are possible. Statement 2 : x y = 0

OPTION x y z w LHS LHS=0 -------------------------------------- A 0 1 0 0 0 Yes B 1 1 0 1 1 No C 1 0 1 1 0 Yes D 1 0 0 0 0 YesSince LHS ≠ 0, B is not possible. Statement 3 : x z + w = 1

OPTION x y z w LHS LHS=1 -------------------------------------- A 0 1 0 0 0 No C 1 0 1 1 1 Yes D 1 0 0 0 0 NoSince LHS ≠ 1, A and D are not possible. Statement 4 : x y + z' w' = 0

OPTION x y z w LHS LHS=0 -------------------------------------- C 1 0 1 1 0 YesThus, C is the correct option. Please comment below if you find anything wrong in the above post.

Question 35 |

The following arrangement of master-slave flip flops has the initial state of P, Q as 0, 1 (respectively). After three clock cycles the output state P, Q is (respectively),

1, 0 | |

1, 1 | |

0, 0 | |

0,1 |

**Digital Logic & Number representation**

**GATE-CS-2000**

**Discuss it**

Question 35 Explanation:

Given P = 0 , J = 1 and k = 1

- JK flipflop toggles the input in ‘11’ state. Therefore, output of first flipflop at P is ‘1’.
- Initial value of P is input for D flipflop. So, D = 0 .Therefore, output of second flipflop at Q is ‘0’.
**Thus, option (A) is the answer.**Please comment below if you find anything wrong in the above post.

Question 36 |

A graphics card has on board memory of 1 MB. Which of the following modes can the card not support?

1600 x 400 resolution with 256 colours on a 17-inch monitor | |

1600 x 400 resolution with 16 million colours on a 14-inch monitor | |

800 x 400 resolution with 16 million colours on a 17-inch monitor | |

800 x 800 resolution with 256 colours on a 14-inch monitor |

**Input Output Systems**

**GATE-CS-2000**

**Discuss it**

Question 36 Explanation:

See question 3 of http://www.geeksforgeeks.org/operating-systems-set-1/

Question 37 |

Consider the values A = 2.0 x 10

^{30}, B =-2.0 x 10^{30}, C= 1.0, and the sequenceX: = A + B Y: = A + C X: = X + C Y: = Y + Bexecuted on a computer where floating-point numbers are represented with 32 bits. The values for X and Y will be

X = 1.0, Y = 1.0 | |

X = 1.0, Y = 0.0 | |

X = 0.0, Y = 1.0 | |

X = 0.0, Y = 0.0 |

**Number Representation**

**GATE-CS-2000**

**Discuss it**

Question 37 Explanation:

1. X: = A + B 3. Y: = A + C 2. X: = X + C 4. Y: = Y + B 1. X: = 2.0 x 10^30 - (-2.0 x 10^30) = 0 2. X: = 0 + 1.0 = 1.0Option (C) and (D) are ruled out

3. Y: = 2.0 x 10^30 + 1.0 = 2.0 x 10^30 (as C has a mere value compared to A) 4. Y: = 2.0 x 10^30 - (-2.0 x 10^30) = 0.0Thus Option(B) This explanation has been contributed by

**Piyush Doorwar.**

Question 38 |

Suppose you are given an array s[1..n] and a procedure reverse (s, i, j) which reverses the order of elements in a between positions i and j (both inclusive). What does the following sequence do, where 1 <= k <= n:

reverse(s, 1, k) ; reverse(s, k + 1, n); reverse(s, l, n);

Rotates s left by k positions | |

Leaves s unchanged
| |

Reverses all elements of s | |

None of the above |

**Misc**

**GATE-CS-2000**

**Discuss it**

Question 38 Explanation:

Effect of the above 3 reversals for any k is equivalent to left rotation of the array of size n by k. Please see this post for details.
If we rotate an array n times for k = 1 to n, we get the same array back.

Question 39 |

Let LASTPOST, LASTIN and LASTPRE denote the last vertex visited in a postorder, inorder and preorder traversal, respectively, of a complete binary tree. Which of the following is always true?

LASTIN = LASTPOST | |

LASTIN = LASTPRE | |

LASTPRE = LASTPOST | |

None of the above |

**Tree Traversals**

**GATE-CS-2000**

**Discuss it**

Question 39 Explanation:

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

Question 40 |

h(n) is O(f(n))
| |

h(n) is O(g(n)) | |

g(n) is not O(f(n)) | |

f(n) is O(g(n)) |

**GATE-CS-2000**

**Discuss it**

Question 40 Explanation:

**Big-oh notation:**Let f and g be two functions defined on real number. One writes f(n) = O(g(n)) if there is a positive constant M such that for all sufficiently large values of n, the absolute value of f(n) is at most M multiplied by the absolute value of g(n). That is, f(n) = O(g(n)) if and only if there exists a positive real number M and a real number n0 such that f(n)≤M(g(n)), for all n≥n0. In Big-oh notation, we only make comparison between two functions by considering larger values of n. To solve question like this we can take larger value of n and then compare the values of different function. f(n) = 3(n^32)=3*(2^10)^32=3*2^320 g(n) = 2^320 h(n)=1024! So relation between the functions can be: 1.f(n) and g(n) are of same order, so f(n) is O(g(n)) and g(n)=O(f(n)). Hence option C is wrong. 2.h(n) is n! Which is of higher order than f(n) and g(n). So options A and B are wrong. See http://geeksquiz.com/algorithms-analysis-of-algorithms-question-22/ This solution is contributed by

**Nirmal Bharadwaj**

Question 41 |

Let G be an undirected connected graph with distinct edge weight. Let emax be the edge with maximum weight and emin the edge with minimum weight. Which of the following statements is false?

Every minimum spanning tree of G must contain emin | |

If emax is in a minimum spanning tree, then its removal must disconnect G | |

No minimum spanning tree contains emax | |

G has a unique minimum spanning tree |

**GATE-CS-2000**

**Discuss it**

Question 41 Explanation:

In kruskal’s algorithm, we pick the edges in ascending order and add them to the forest if no cycle is formed. Option A is True because first edge could never create a cycle.
The only reason for emax to be present in the minimum spanning tree could be that it is the only possible edge to cover a particular vertex in a tree since all vertices have to be present in a spanning tree by definition. Consider the image below
See question 2 of http://www.geeksforgeeks.org/data-structures-and-algorithms-set-8/
This solution is contributed by

**Pranjul Ahuja**Question 42 |

Let G be an undirected graph. Consider a depth-first traversal of G, and let T be the resulting depth-first search tree. Let u be a vertex in G and let v be the first new (unvisited) vertex visited after visiting u in the traversal. Which of the following statements is always true?

{u,v} must be an edge in G, and u is a descendant of v in T | |

{u,v} must be an edge in G, and v is a descendant of u in T | |

If {u,v} is not an edge in G then u is a leaf in T | |

If {u,v} is not an edge in G then u and v must have the same parent in T |

**Graph Traversals**

**GATE-CS-2000**

**Discuss it**

Question 42 Explanation:

In DFS, if 'v' is visited after 'u', then one of the following is true. 1) (u, v) is an edge. u / \ v w / / \ x y z 2) 'u' is a leaf node. w / \ x v / / \ u y zIn DFS, after visiting a node, we first recur for all unvisited children. If there are no unvisited children (u is leaf), then control goes back to parent and parent then visits next unvisited children.

Question 43 |

The value of j at the end of the execution of the following C program.

int incr(int i) { static int count = 0; count = count + i; return (count); } main() { int i,j; for (i = 0; i <=4; i++) j = incr(i); }

10 | |

4 | |

6 | |

7 |

**Functions**

**GATE-CS-2000**

**Discuss it**

Question 43 Explanation:

See question 2 of http://www.geeksforgeeks.org/c-language-set-1/

Question 44 |

Given the following expression grammar:

E -> E * F | F + E | F F -> F - F | idwhich of the following is true? (GATE CS 2000)

* has higher precedence than + | |

– has higher precedence than * | |

+ and — have same precedence | |

+ has higher precedence than * |

**Parsing and Syntax directed translation**

**GATE-CS-2000**

**Discuss it**

Question 44 Explanation:

Let say i/p is 3*4-5 when we draw parse tree according to grammar

E / | \ E * F | / | \ F F - F | | | id(3) id(4) id(5)As we can see first '- ' will be evaluated then ' * ' is evaluated so ' - ' has higher precedence then *. So correct choice is B See question 1 of http://www.geeksforgeeks.org/compilers-set-2/

Question 45 |

Suppose the time to service a page fault is on the average 10 milliseconds, while a memory access takes 1 microsecond. Then a 99.99% hit ratio results in average memory access time of (GATE CS 2000)

1.9999 milliseconds | |

1 millisecond | |

9.999 microseconds | |

1.9999 microseconds |

**Memory Management**

**GATE-CS-2000**

**Discuss it**

Question 45 Explanation:

If any page request comes it will first search into page table, if present, then it will directly fetch the page from memory, thus in this case time requires will be only memory access time.
But if required page will not be found, first we have to bring it out and then go for memory access. This extra time is called page fault service time.
Let hit ratio be p , memory access time be t1 , and page fault service time be t2.

Hence, average memory access time = p*t1 + (1-p)*t2 =(99.99*1 + 0.01*(10*1000 + 1))/100 =1.9999 *10^-6 secThis explanation is contributed by

**Abhishek Kumar.**Also, see question 1 of http://www.geeksforgeeks.org/operating-systems-set-3/Question 46 |

Which of the following is NOT a valid deadlock prevention scheme? (GATE CS 2000)

Release all resources before requesting a new resource | |

Number the resources uniquely and never request a lower numbered resource than the last one requested. | |

Never request a resource after releasing any resource | |

Request and all required resources be allocated before execution. |

**GATE-CS-2000**

**Deadlock**

**Discuss it**

Question 46 Explanation:

See question 1 of http://www.geeksforgeeks.org/operating-systems-set-1/

Question 47 |

Given the following relation instance.

x y z 1 4 2 1 5 3 1 6 3 3 2 2Which of the following functional dependencies are satisfied by the instance? (GATE CS 2000)

XY -> Z and Z -> Y | |

YZ -> X and Y -> Z | |

YZ -> X and X -> Z | |

XZ -> Y and Y -> X |

**Database Design(Normal Forms)**

**GATE-CS-2000**

**Discuss it**

Question 47 Explanation:

See question 2 of http://www.geeksforgeeks.org/database-management-system-set-1/

Question 48 |

Given relations r(w, x) and s(y, z), the result of

SELECT DISTINCT w, x FROM r, sis guaranteed to be same as r, provided

r has no duplicates and s is non-empty | |

r and s have no duplicates | |

s has no duplicates and r is non-empty | |

r and s have the same number of tuples |

**SQL**

**GATE-CS-2000**

**Discuss it**

Question 48 Explanation:

See question 3 of http://www.geeksforgeeks.org/database-management-system-set-1/

Question 49 |

In SQL, relations can contain null values, and comparisons with null values are treated as unknown. Suppose all comparisons with a null value are treated as false. Which of the following pairs is not equivalent?

x = 5 AND not(not(x = 5)) | |

x = 5 AND x> 4 and x < 6, where x is an integer | |

x < 5 AND not (x = 5) | |

None of the above |

**SQL**

**GATE-CS-2000**

**Discuss it**

Question 49 Explanation:

For all values smaller than 5, x < 5 will always be true but x = 5 will be false.

There are 49 questions to complete.