### GATE SAMPLE TEST-COMPUTER SCIENCE

No. Question

1 Consider the following C function

void swap (int a, int b)

{ int temp ;

temp = a ;

a = b ;

b = temp ;

}

In order to exchange the values of two variables x and y.

Options

A) call swap (x, y)

B) call swap (&x, &y)

C) swap (x, y) cannot be used as it does not return any value D) swap (x, y) cannot be used as the parameters are passed by value

Correct Answer B

2 A 5 stage pipelined CPU has the following sequence of stages:

IF – Instruction fetch from instruction memory,

RD – Instruction decode and register read,

EX – Execute: ALU operation for data and address computation,

MA – Data memory access – for write access, the register read at RD stage is used,

WB – Register write back.

Consider the following sequence of instructions:

I1 : L R0, 1oc1; R0 <= M[1oc1]
I2 : A R0, R0; R0 <= R0 + R0
I3: A R2, R0; R2 <= R2 - R0
Let each stage take one clock cycle.
What is the number of clock cycles taken to complete the above sequence of instructions starting from the fetch of I1?
Options
A) 8 B) 10
C) 12 D) 15
Correct Answer A
3 The address resolution protocol (ARP) is used for
Options
A) Finding the IP address from the DNS B) Finding the IP address of the default gateway
C) Finding the IP address that corresponds to a MAC address D) Finding the MAC address that corresponds to an IP address
Correct Answer D
4 Consider the following relation schema pertaining to a students database:
Student (rollno, name, address)
Enroll (rollno, courseno, coursename)
where the primary keys are shown underlined. The number of tuples in the Student and Enroll tables are 120 and 8 respectively. What are the maximum and minimum number of tuples that can be present in (Student * Enroll), where ‘*’denotes natural join?
Options
A) 8, 8 B) 120, 8
C) 960, 8 D) 960, 120
Correct Answer C
5 Consider a direct mapped cache of size 32 KB with block size 32 bytes. The CPU generates 32 bit addresses. The number of bits needed for cache indexing and the number of tag bits are respectively
Options
A) 10, 17 B) 10, 22
C) 15, 17 D) 5, 17
Correct Answer A
6 Which one of the following is a key factor for preferring B+ -trees to binary search trees for indexing database relations?
Options
A) Database relations have a large number of records B) Database relations are sorted on the primary key
C) B+ -trees require less memory than binary search trees D) Data transfer from disks is in blocks
Correct Answer D
7 The goal of structured programming is to
Options
A) have well indented programs B) be able to infer the flow of control from the compiled code
C) be able to infer the flow of control from the program text D) avoid the use of GOTO statements
Correct Answer C
8 The tightest lower bound on the number of comparisons, in the worst ease, for comparison-based sorting is of the order of
Options
A) n B) n2
C) n log n D) n log2 n
Correct Answer B
9 Consider the following two problems on undirected graphs
a: Given G(V, E), does G have an independent set of size |V| -4?
b: Given G(V, E), does G have an independent set of size 5?
Which one of the following is TRUE?
Options
A) a is in P and b is NP-complete B) a is NP-complete and b is in P
C) Both a and b are NP-complete D) Both a and b are in P
Correct Answer C
10 Consider the languages
L1 = {wwR | w Î{0, 1}*}
L2 = {w# wR | w Î{0, 1}*}, where # is a special symbol
L3 = {ww | w Î{0, 1}*}
Which one of the following is TRUE?
Options
A) L1 is a deterministic CFL B) L2 is a deterministic CFL
C) L3 is a CFL, but not a deterministic CFL D) L3 is a deterministic CFL
Correct Answer B
11 Let G be a simple graph with 20 vertices and 100 edges. The size of the minimum vertex cover of G is 8. Then, the size of the maximum independent set of G is
Options
A) 12 B) 8
C) Less than 8 D) More than 12
Correct Answer A
12 A and B are the only two stations on an Ethernet. Each has a steady queue of frames to send. Both A and B attempt to transmit a frame, collide, and A wins the first backoff race. At the end of this successful transmission by A, both A and B attempt to transmit and collide. The probability that A wins the second backoff race is
Options
A) 0.5 B) 0.625
C) 0.75 D) 1.0
Correct Answer A
13 Consider the grammar
E ® E + n | E x n | n
For a sentence n + n x n, the handles in the right-sentential form of the reduction are
Options
A) n, E + n and E + n x n B) n, E + n and E + E x n
C) n, n + n and n + n x n D) n, E + n and E x n
Correct Answer D
14 Consider the grammar with the following translation rules and E as the start symbol.
E ® E1 # T {E.value = E1.value * T.value }
| T {E.value = T.value }
T ® T1 & F { T.value = T1.value + F.value }
| F {T.value = F.value}
F ® num {F.value = num.value }
Compute E. value for the root of the parse tree for the expression: 2 # 3 & 5 # 6 & 4.
Options
A) 200 B) 180
C) 160 D) 40
Correct Answer C
15
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?
Options
A) 2 B) 30
C) 56 D) 256
Correct Answer D
16 Which one of the following is true for a CPU having a single interrupt request line and a single interrrupt grant line?
Options
A) Neither vectored interrupt nor multiple interrupting devices are possible. B) Vectored interrupts are not possible but multiple interrupting devices are possible.
C) Vectored interrupts and multiple interrupting devices are both possible. D) Vectored interrupt is possible but multiple interrupting devices are not possible.
Correct Answer B
17 Consider a relation scheme R = (A, B, C, D, E, H) on which the following functional dependencies hold : (A ® B, BC ® D, E ® C, D ® A). What are the candidate keys of R?
Options
A) AE, BE B) AE, BE, DE
C) AEH, BEH, BCH D) AEH, BEH, DEH
Correct Answer D
18
In a network of LANs connected by bridges, packets are sent from one LAN to another through intermediate bridges. Since more than one path may exist between two LANs, packets may have to be routed through multiple bridges.
Why is the spanning tree algorithm used for bridge-routing?
Options
A) For shortest path routing between LANs B) For avoiding loops in the routing paths
C) For fault tolerance D) For minimizing collisions
Your Answer (Not Answered)
Correct Answer B
19 Suppose T(n) = 2T (n/2) + n, T(0) = T(1) = 1
Which one of the following is FALSE?
Options
A) T(n) = O(n2 ) B) T(n) = q (n log n)
C) T(n) = W (n2) D) T(n) = O(n log n)
Correct Answer B
20
Consider the following C program segment
struct CellNode {
struct CellNode *leftChild ;
int element;
struct CellNode *rightChild ;
};
int DoSomething (struct CellNode *ptr)
{
int value = 0 ; if (ptr ! = NULL)
{ if (ptr->leftChild ! = NULL)

value = 1 + DoSomething (ptr – > leftChild) ;

if (ptr – > rightChild ! = NULL)

value = max (value, 1 + DoSomething (ptr – > rightChild)) ;

}

return (value);

}

The value returned by the function DoSomething when a pointer to the root of a

non-empty tree is passed as argument is

Options

A) The number of leaf nodes in the tree

B) The number of nodes in the tree

C) The number of internal nodes in the tree D) The height of the tree

Your Answer (Not Answered)

Correct Answer D

plz try to provide the solutions of gate sample paper which are given above.

For Gate Sample Paper CLICK HEREhy kirti,if we provid solution in below than the student is not try to sol ques.

plz give me discription of a conceptual ques.

please give the solution of the problems