Instruction Operation Instruction Size (In Words)

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 18

Consider the following program segment for a hypothetical CPU having three user registers Rl,

R2 and R3.

Instruction Operation Instruction Size (in words)

MOV Rl,5000 ; Rl � 2
Memory[5000]
;
MOV R2,(R1) 1
R2 �Memory[(Rl)]
ADD  R2,R3 ; R2 �R2 + R3 1
; Memory[6000]
MOV 6000, R2 2
�R2
HALT ; Machine halts 1

Let the clock cycles required for various operations be as follows:


Register to/from memory transfer :        3 clock cycles
ADD with both operands in register :    1 clock cycle
Instruction fetch and decode :               2 clock cycles per word
The total number of clock cycles required to execute the program is

Options
A) 29 B) 24
C) 23 D) 20
Correct Answer B 2 The order of an internal node in a B+ tree index is the maximum number of
children it can have. Suppose that a child pointer takes 6 bytes, the search field value takes 14
bytes, and the block size is 512 bytes. What is the order of the internal node? Options
A) 24 B) 25
C) 26 D) 27
Correct Answer C 3 The Boolean function x, y, + xy + x, y Options
A) x, + y, B) x + y
C) x + y, D) x, + y
Correct Answer D 4 In an MxN matrix such that all non-zero entries are covered in a rows and b
columns. Then the maximum number of non-zero entries, such that no two are on the same row
or column, is Options
B) �  max {a,
A) � a + b 
b}
C) �  min {M-a, N-
D) � min {a, b}
b}
Correct Answer A 5 The relation scheme Student Performance (name, courseNo, rollNo, grade)
has the following functional dependencies:
name, courseNo �grade
rollNo, courseNo � grade
name � rollNo
rollNo � name
The highest normal form of this relation scheme is Correct Answer A 6 The minimum number of
page frames that must be allocated to a running process in a virtual memory environment is
determined by Options
A) the instruction set architecture B)  page size
C) physical memory size  D) number of processes in memory
Correct Answer D 7

Consider the following program segment for a hypothetical CPU having three user registers Rl,
R2 and R3.

Instruction Operation Instruction Size (in words)

MOV Rl,5000 ; Rl � 2
Memory[5000]
;
MOV R2,(R1) 1
R2 �Memory[(Rl)]
ADD  R2,R3 ; R2 �R2 + R3 1
; Memory[6000]
MOV 6000, R2 2
�R2
HALT ; Machine halts 1

Consider that the memory is byte addressable with size 32 bits, and the program has been loaded
starting from memory location 1000 (decimal). If an interrupt occurs while the CPU has been
halted after executing the HALT instruction, the return address (in decimal) saved in the stack
will be

Options
A) 1007  B) 1020
C) 1024 D) 1028
Correct Answer A 8 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 9  What does the following algorithm approximate? (Assume m > 1, � > 0).
x = m;
y-i;
while (x - y > �)
{     x =   (x + y) / 2 ;
       y = m/x ;
}
print (x) ; Options
A) log m  B)
m2

 
1/2
C) m D) m1/3
Correct Answer C 10 Consider the following C program
main ()
{        int x, y, m, n ;
scanf ("%d %d", &x, &y);
/ * Assume x > 0 and y > 0 * /
 m = x;     n = y ;
while ( m ! = n)
{       if (m > n)
m = m � n;
 else
n=n-m;}
printf("%d",n); }
The program computes Options
A) x + y, using repeated subtraction B) x mod y using repeated subtraction
C) the greatest common divisor of x and y D) the least common multiple of x and y
Correct Answer C 11 The best data structure to check whether an arithmetic expression has
balanced parentheses is a Options
A) queue  B) stack
C) tree  D) list
Correct Answer B 12 A Priority-Queue is implemented as a Max-Heap. Initially, it has 5
elements. The level-order traversal of the heap is given below:
10, 8,5,3,2
Two new elements 1 and 7 are inserted in the heap in that order. The level-order traversal of the
heap after the insertion of the elements is Options
A) 10,8,7,5,3,2,1 B) 10,8,7,2,3,1,5
C) 10,8,7,1,2,3,5 D) 10,8,7,3,2,1,5
Correct Answer D 13

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
Correct Answer D 14 An organization has a class B network and wishes to form subnets for 64
departments. The subnet mask would be Options
A) 255.255.0.0 B) 255.255.64.0
C) 255.255.128.0 D) 255.255.252.0
Correct Answer D 15 Suppose the round trip propagation delay for a 10 Mbps Ethernet having
48-bit jamming signal is 46.4 s. The minimum frame size is: Options
A) 94 B) 416
C) 464 D) 512
Correct Answer C 16

Consider the following C program segment:

char p [ 20];

char * s = "string" ;

int length = strlen (s) ;

for (i = 0 ; i < length; i++)

p[ i ] = s [length - i] ;

print f ("%s", p) ;
The output of the program is

Correct Answer A 17 Consider the grammar


S � (S) | a
Let the number of states in SLR(1), LR(1) and LALR(1) parsers for the grammar be n1, n2 and n3
respectively. The following relationship holds good Options
A)  n1< n2 < n3 B) n1= n3 < n2
D) n1 � n3
C) n1= n2 = n3
�n2
Correct Answer B 18 Consider the following C function:
int f (int n)
{ static int i = 1;
if (n >= 5) return n;
n = n + i;
i ++;
return f (n);
}
The value returned by f(1) is
Options
A) 5 B) 6
C) 7 D) 8
Correct Answer C 19 Consider the following code fragment:
if (fork ( ) = = 0)
{a = a + 5; print f (�%d, %d / n�, a, and a); }
else {a - 5; print f (� %d, %d / n�, a,& a); }
Let u, v be the values printed by the parent process, and x, y be the values printed by the child
process. Which one of the following is TRUE? Options
B) u = x + 10 and v �
A) u = x + 10 and v = y
y
D) u + 10 = x and v �
C) u + 10 =x and v = y
y
Correct Answer B 20 The following numbers are inserted into an empty binary search tree in the
given order: 10, 1, 3, 5, 15, 12, 16. What is the height of the binary search tree (the height is the
maximum distance of a leaf node from the root)? Options
A) 2 B) 3
C) 4 D) 6
Correct Answer B
A
ds
by
G
oo
gl
e

G
GATE  � Sample Questions - CSE2 A
T
    E
2
Questions And Answers 0
1
No. Question 1
pr
Consider the following C function e
void swap (int a, int b)  p
{ int temp ; ar
temp     = a ; at
1 io
a =   b ;
n
b = temp ;
G
} A
In order to exchange the values of two variables x and y. T
E
A) call swap (x, y) B) call swap (&x, &y) 2
Options C) swap (x, y) cannot be used as it does not D) swap (x, y) cannot be used as the parameters
0
return any value are passed by value 1
1
Your A
   (Not Answered)
Answer rc
hi
Correct te
B
Answer ct
ur
A 5 stage pipelined CPU has the following sequence of stages: e
IF - Instruction fetch from instruction memory, e
RD - Instruction decode and register read, x
EX - Execute: ALU operation for data and address computation, a
m
MA - Data memory access - for write access, the register read at RD stage is used, st
WB - Register write back. u
2 Consider the following sequence of instructions: d
I1 : L R0, 1oc1;  R0 <= M[1oc1] y
I2 : A R0, R0;      R0 <= R0 + R0 m
at
I3: A R2, R0;      R2 <= R2 - R0 er
Let each stage take one clock cycle. ia
What is the number of clock cycles taken to complete the above sequence of l
instructions starting from the fetch of I1? A
rc
A) 8 B) 10 hi
Options te
C) 12 D) 15
ct
Your ur
   (Not Answered) e
Answer
q
Correct u
A
Answer es
ti
3 The address resolution protocol (ARP) is used for o
n
B
a
n
k
w
w
A) Finding the IP address from the DNS B) Finding the IP address of the default gateway
Options C) Finding the IP address that corresponds to a D) Finding the MAC address that corresponds
MAC address to an IP address
Your
   (Not Answered)
Answer
Correct
D
Answer
Consider the following relation schema pertaining to a students database:
Student (rollno, name, address)
Enroll (rollno, courseno, coursename)
4
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?
A) 8, 8  B) 120, 8
Options
C) 960, 8  D) 960, 120
Your
   (Not Answered)
Answer
Correct
C
Answer
Consider a direct mapped cache of size 32 KB with block size 32 bytes. The CPU generates 32
5 bit addresses. The number of bits needed for cache indexing and the number of tag bits are
respectively
A) 10, 17 B) 10, 22
Options
C) 15, 17  D) 5, 17
Your
   (Not Answered)
Answer
Correct
A
Answer
Which one of the following is a key factor for preferring B+ -trees to binary search trees for
6
indexing database relations?
A) Database relations have a large number of B) Database relations are sorted on the
records primary key
Options
C) B+ -trees require less memory than binary
D) Data transfer from disks is in blocks
search trees
Your
   (Not Answered)
Answer
Correct
D
Answer
7 The goal of structured programming is to
B) be able to infer the flow of control from the
A) have well indented programs
compiled code
Options
C) be able to infer the flow of control from the
D) avoid the use of GOTO statements
program text
Your
   (Not Answered)
Answer
Correct
C
Answer
The tightest lower bound on the number of comparisons, in the worst ease, for comparison-
8
based sorting is of the order of
A) n B) n2
Options
C) n log n D) n log2 n
Your
   (Not Answered)
Answer
Correct
B
Answer
Consider the following two problems on undirected graphs
a: Given G(V, E), does G have an independent set of size |V| -4?
9
b: Given G(V, E), does G have an independent set of size 5?
Which one of the following is TRUE?
A)  is in P and  is NP-complete B)  is NP-complete and  is in P
Options
C) Both  and  are NP-complete  D) Both  and  are in P
Your
   (Not Answered)
Answer
Correct
C
Answer
Consider the languages
L1 = {wwR | w �{0, 1}*}
10 L2 = {w# wR | w �{0, 1}*}, where # is a special symbol
L3 = {ww | w �{0, 1}*}
Which one of the following is TRUE?
A) L1 is a deterministic CFL B) L2 is a deterministic CFL
Options
C) L3 is a CFL, but not a deterministic CFL D) L3 is a deterministic CFL
Your
   (Not Answered)
Answer
Correct
B
Answer
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
A) 12 B) 8
Options
C) Less than 8 D) More than 12
Your
   (Not Answered)
Answer
Correct
A
Answer
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
12
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
A) 0.5  B) 0.625
Options
C) 0.75  D) 1.0
Your
   (Not Answered)
Answer
Correct
A
Answer
Consider the grammar
13 E�E+n|Exn|n
For a sentence n + n x n, the handles in the right-sentential form of the reduction are
A) n, E + n and E + n x n B) n, E + n and E + E x n
Options
C) n, n + n and n + n x n  D) n, E + n and E x n
Your
   (Not Answered)
Answer
Correct
D
Answer
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 }
14 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.
A) 200 B) 180
Options
C) 160 D) 40
Your
   (Not Answered)
Answer
Correct C
Answer
Let A be a sequence of 8 distinct integers sorted in ascending order. How many distinct pairs of
15 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?
A) 2 B) 30
Options
C) 56 D) 256
Your
   (Not Answered)
Answer
Correct
D
Answer
Which one of the following is true for a CPU having a single interrupt request line and a single
16
interrrupt grant line?
A) Neither vectored interrupt nor multiple B) Vectored interrupts are not possible but
interrupting devices are possible. multiple interrupting devices are possible.
Options
C) Vectored interrupts and multiple D) Vectored interrupt is possible but multiple
interrupting devices are both possible. interrupting devices are not possible.
Your
   (Not Answered)
Answer
Correct
B
Answer
Consider a relation scheme R = (A, B, C, D, E, H) on which the following functional
17
dependencies hold : (A � B, BC � D, E � C, D � A). What are the candidate keys of R?
A) AE, BE B) AE, BE, DE
Options
C) AEH, BEH, BCH D) AEH, BEH, DEH
Your
   (Not Answered)
Answer
Correct
D
Answer
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
18 to be routed through multiple bridges.

Why is the spanning tree algorithm used for bridge-routing?


A) For shortest path routing between LANs B) For avoiding loops in the routing paths
Options
C) For fault tolerance D) For minimizing collisions
Your
   (Not Answered)
Answer
Correct B
Answer
Suppose T(n) = 2T (n/2) + n, T(0) = T(1) = 1
19
Which one of the following is FALSE?
A) T(n) = O(n2 ) B) T(n) =  (n log n)
Options
C) T(n) =  (n2)  D) T(n) = O(n log n)
Your
   (Not Answered)
Answer
Correct
B
Answer
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)
20 {    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 
A) The number of leaf nodes in the tree B) The number of nodes in the tree 
Options
C) The number of internal nodes in the tree D) The height of the tree
Your
   (Not Answered)
Answer
Correct
D
Answer
A
ds
by
G
oo
gl
e

D
o
w
nl
o
a
GATE  � Sample Questions - CSE3 d
G
o
    o
gl
Questions And Answers e
C
Question hr
What does the following algorithm approximate? (Assume m > 1, � > 0). o
m
x = m; e
S
while (x - y > �) e
x =   (x + y) / 2 ; ar
c
y = m/x ;
hi
n
print (x) ; g
is
B) fa
st
log m  m2 a
n
  d
1/2
e
D) m1/3 as
y
Not Answered) w
it
h
G
o
The problems 3-SAT and 2-SAT are o
gl
both in P B) both NP-complete e'
s
NP-complete and in P respectively D) undecidable and NP-complete respectively
w
e
Not Answered) b
br
o
w
se
Consider a relation scheme R = (A, B, C, D, E, H) on which the following functional r.
w
dependencies hold : (A � B, BC � D, E � C, D � A). What are the candidate keys of w R?
w.
AE, BE B) AE, BE, DE G
oo
AEH, BEH, BCH D) AEH, BEH, DEH gl
e.
co
m/
C
hr
o
m
e
Not Answered)

A circuit outputs a digit in the form of 4 bits. 0 is represented by 0000,1 by 0001,..., 9 by 1001.
A combinational circuit is to be designed which takes these 4 bits as input and outputs 1 if the
� 5, and 0 otherwise. If only AND, OR and NOT gates may be used, what is the minimum
number of gates required?
B) 3
D) 5

Not Answered)

x (in base-x number system) is equal to 54y (in base-y number system), the possible values of
x and y are
8, 16  B) 10, 12
9, 13  D) 8, 11

Not Answered)

In a packet switching network, packets are routed from source to destination along a single path
having two intermediate nodes. If the message size is 24 bytes and each packet contains a header
of 3 bytes, then the optimum packet size is
B) 6
D) 9

Not Answered)

Consider the following program fragment for reversing the digits in a given integer to obtain a
new integer. Let n = d1d2... dm.
int n, rev;
rev = 0;
while (n > 0) {
= rev * 10 + n % 10 ;
n = n/10;
The loop invariant condition at the end of the ith iteration is:
n = d1d2... dm-i   and rev = dmdm-1�.dm-i+1 B) n = dm-i+1...dm-1dm  (or)  rev = dm-i
�  rev D) n = d1d2...dm   (or)   rev = dm...d2

Not Answered)

Consider the following program segment for a hypothetical CPU having three user registers Rl,
R2 and R3.

Instruction Operation Instruction Size (in words)

MOV Rl,5000 ; Rl � 2
Memory[5000]
;
MOV R2,(R1) 1
R2 �Memory[(Rl)]
ADD  R2,R3 ; R2 �R2 + R3 1
; Memory[6000]
MOV 6000, R2 2
�R2
HALT ; Machine halts 1
Let the clock cycles required for various operations be as follows:
Register to/from memory transfer :        3 clock cycles
ADD with both operands in register :    1 clock cycle
Instruction fetch and decode :               2 clock cycles per word
The total number of clock cycles required to execute the program is
B) 24
D) 20

Not Answered)

Consider an operating system capable of loading and executing a single


sequential user process at a time. The disk head scheduling algorithm used is First Come First
Served (FCFS). If FCFS is replaced by Shortest Seek Time First (SSTF), claimed by the vendor
to give 50% better benchmark results, what is the expected improvement in the I/O performance
of user programs ?
50%  B)  40%
25% D) 0%

Not Answered)
Consider the following statements with respect to user-level threads and
kernel-supported threads
(i) Context switch is faster with kernel-supported threads
(ii) For user-level threads, a system call can block the entire process
(iii) Kernel-supported threads can be scheduled independently
(iv) User-level threads are transparent to the kernel
Which of the above statements are true?
(ii), (iii) and (iv) only  B)  (ii) and (iii) only
(i), and (iii) only  D) (i) and (ii) only

Not Answered)

Consider three decision problems P1, P2 and P3. It is known that P1 is decidable and P
undecidable. Which one of the following is TRUE?
3 is decidable if P1 is reducible to P3 B) P3 is undecidable if P3 is reducible to P
3 is undecidable if P2 is reducible to D) P3 is decidable if P3 is reducible to P
complement

Not Answered)

Which one of the following are essential features of an object-oriented


programming language?

(i) Abstraction and encapsulation


(ii) Strictly-typedness
Type-safe property coupled with sub-type rule
(iv) Polymorphism in the presence of inheritance
(i) and (ii) only B) (i) and (iv) only
(i), (ii) and (iv) only D) (i), (iii) and (iv) only

Not Answered)

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?
8, 8  B) 120, 8
960, 8  D) 960, 120

Not Answered)

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[l]                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               B) II, III, and IV only
D) IV only
II and IV only  
 

Not Answered)

How many distinct binary search trees can be created out of 4 distinct keys?
B) 14
D) 42

Not Answered)

Given the following input (4322, 1334, 1471, 9679, 1989, 6171, 6173, 4199) and the hash
function x mod 10, which of the following statements are true ?
(i) 9679, 1989, 4199 hash to the same value
(ii) 1471, 6171 hash to the same value
(iii) All elements hash to the same value
(iv) Each element hashes to a different value
(i) only B) (ii) only
(i) and (ii) only  D)  (iii) or (iv)
Not Answered)
Packets of the same session may be routed through different paths in
TCP, but not UDP B) TCP and UDP
UDP, but not TCP D) Neither TCP, nor UDP

Not Answered)

The following numbers are inserted into an empty binary search tree in the given order: 10, 1, 3,
5, 15, 12, 16. What is the height of the binary search tree (the height is the maximum distance of
a leaf node from the root)?
B) 3
D) 6

Not Answered)

Postorder traversal of a given binary search tree, T produces the following sequence of keys
10, 9, 23, 22, 27, 25, 15, 50, 95, 60, 40, 29
Which one of the following sequences of keys can be the result of an inorder traversal of the tree

9, 10, 15, 22, 23, 25, 27, 29, 40, 50, 60, 95 B) 9, 10, 15, 22, 40, 50, 60, 95, 23, 25, 27, 29
29, 15, 9, 10, 25, 22, 23, 27, 40, 60, 50, 95 D) 95, 50, 60, 40, 27, 23, 22, 25, 10, 9, 15, 29

Not Answered)

Let f: B � C and g: A � B be two functions and let h = f o g. Given that h is an onto function.
Which one of the following is TRUE?
and g should both be onto functions. B) f should be onto but g need not be onto
should be onto but f need not be onto  D) both f and g need not be onto

Not Answered)

You might also like