gate sample

25
Consider the following program segment for a hypothetical CPU having three user registers Rl, R2 and R3. Instructio n Operation Instruction Size (in words) MOV Rl,5000 ; Rl Memory[5000] 2 MOV R2, (R1) ; R2 Memory[(Rl )] 1 ADD R2,R3 ; R2 R2 + R3 1 MOV 6000, R2 ; Memory[6000] R2 2 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

Upload: chetanya-maheshwari

Post on 02-Apr-2015

99 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: gate sample

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 � Memory[5000]

2

MOV R2,(R1) ; R2 �Memory[(Rl)] 1

ADD  R2,R3 ; R2 �R2 + R3 1

MOV 6000, R2; Memory[6000] �R2

2

HALT ; Machine halts 1

Let the clock cycles required for various operations be as follows:Register to/from memory transfer :        3 clock cyclesADD with both operands in register :    1 clock cycleInstruction fetch and decode :               2 clock cycles per wordThe total number of clock cycles required to execute the program is

Options A) 29 B) 24C) 23 D) 20Correct 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) 25C) 26 D) 27Correct Answer C 3 The Boolean function x, y, + xy + x, y Options A) x, + y, B) x + yC) x + y, D) x, + yCorrect 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

A) � a + bB) �  max {a, b}

C) �  min {M-a, N-b}

D) � min {a, b}

Correct Answer A 5 The relation scheme Student Performance (name, courseNo, rollNo, grade) has the following functional dependencies:name, courseNo �graderollNo, courseNo � gradename � rollNorollNo � nameThe highest normal form of this relation scheme is Correct Answer A 6 The minimum number of

Page 2: gate sample

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 sizeC) physical memory size D) number of processes in memoryCorrect 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 � Memory[5000]

2

MOV R2,(R1) ; R2 �Memory[(Rl)] 1

ADD  R2,R3 ; R2 �R2 + R3 1

MOV 6000, R2; Memory[6000] �R2

2

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) 1020C) 1024 D) 1028Correct 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) 8C) Less than 8 D) More than 12Correct 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

C) m1/2 D) m1/3

Page 3: gate sample

Correct Answer C 10 Consider the following C programmain (){        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; elsen = n - m ; }printf("%d",n); }The program computes Options A) x + y, using repeated subtraction B) x mod y using repeated subtractionC) the greatest common divisor of x and y D) the least common multiple of x and yCorrect Answer C 11 The best data structure to check whether an arithmetic expression has balanced parentheses is a Options A) queue B) stackC) tree D) listCorrect 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,2Two 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,5C) 10,8,7,1,2,3,5 D) 10,8,7,3,2,1,5Correct 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); }

Page 4: gate sample

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 treeC) The number of internal nodes in the tree D) The height of the treeCorrect 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.0C) 255.255.128.0 D) 255.255.252.0Correct 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) 416C) 464 D) 512Correct 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 grammarS � (S) | aLet 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

C) n1= n2 = n3D) n1 � 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);

Page 5: gate sample

}The value returned by f(1) isOptions A) 5 B) 6C) 7 D) 8Correct 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

A) u = x + 10 and v = yB) u = x + 10 and v � y

C) u + 10 =x and v = yD) u + 10 = x and v � 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) 3C) 4 D) 6Correct Answer B

Page 6: gate sample

GATE   � Sample Questions - CSE2

   

Questions And Answers

No. Question

1

Consider the following C functionvoid 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.

OptionsA) 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

Your Answer

   (Not Answered)

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 + R0I3: A R2, R0;      R2 <= R2 - R0Let 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?

OptionsA) 8 B) 10C) 12 D) 15

Your Answer

   (Not Answered)

Correct Answer

A

3 The address resolution protocol (ARP) is used for

Ads by Google

GATE 2011 preparationGATE 2011 Architecture exam studymaterial Architecture question Bankww

Page 7: gate sample

OptionsA) Finding the IP address from the DNS B) Finding the IP address of the default gatewayC) Finding the IP address that corresponds to a MAC address

D) Finding the MAC address that corresponds to an IP address

Your Answer

   (Not Answered)

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?

OptionsA) 8, 8 B) 120, 8C) 960, 8 D) 960, 120

Your Answer

   (Not Answered)

Correct Answer

C

5Consider 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

OptionsA) 10, 17 B) 10, 22C) 15, 17 D) 5, 17

Your Answer

   (Not Answered)

Correct Answer

A

6Which 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

Your Answer

   (Not Answered)

Correct Answer

D

7 The goal of structured programming is to

Page 8: gate sample

OptionsA) 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

Your Answer

   (Not Answered)

Correct Answer

C

8The tightest lower bound on the number of comparisons, in the worst ease, for comparison-based sorting is of the order of

OptionsA) n B) n2

C) n log n D) n log2 n

Your Answer

   (Not Answered)

Correct Answer

B

9

Consider the following two problems on undirected graphsa: 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?

OptionsA)  is in P and  is NP-complete B)  is NP-complete and  is in PC) Both  and  are NP-complete D) Both  and are in P

Your Answer

   (Not Answered)

Correct Answer

C

10

Consider the languagesL1 = {wwR | w �{0, 1}*}L2 = {w# wR | w �{0, 1}*}, where # is a special symbolL3 = {ww | w �{0, 1}*}Which one of the following is TRUE?

OptionsA) L1 is a deterministic CFL B) L2 is a deterministic CFLC) L3 is a CFL, but not a deterministic CFL D) L3 is a deterministic CFL

Your Answer

   (Not Answered)

Correct Answer

B

11Let 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

Page 9: gate sample

OptionsA) 12 B) 8C) Less than 8 D) More than 12

Your Answer

   (Not Answered)

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

OptionsA) 0.5 B) 0.625C) 0.75 D) 1.0

Your Answer

   (Not Answered)

Correct Answer

A

13Consider the grammarE � E + n | E x n | nFor a sentence n + n x n, the handles in the right-sentential form of the reduction are

OptionsA) n, E + n and E + n x n B) n, E + n and E + E x nC) n, n + n and n + n x n D) n, E + n and E x n

Your Answer

   (Not Answered)

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.

OptionsA) 200 B) 180C) 160 D) 40

Your Answer

   (Not Answered)

Correct Answer

C

Page 10: gate sample

15Let 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?

OptionsA) 2 B) 30C) 56 D) 256

Your Answer

   (Not Answered)

Correct Answer

D

16Which 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.

Your Answer

   (Not Answered)

Correct Answer

B

17Consider 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?

OptionsA) AE, BE B) AE, BE, DEC) AEH, BEH, BCH D) AEH, BEH, DEH

Your Answer

   (Not Answered)

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?

OptionsA) For shortest path routing between LANs B) For avoiding loops in the routing pathsC) For fault tolerance D) For minimizing collisions

Your Answer

   (Not Answered)

Correct Answer

B

Page 11: gate sample

19Suppose T(n) = 2T (n/2) + n, T(0) = T(1) = 1Which one of the following is FALSE?

OptionsA) T(n) = O(n2 ) B) T(n) =  (n log n)C) T(n) =  (n2) D) T(n) = O(n log n)

Your Answer

   (Not Answered)

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

OptionsA) The number of leaf nodes in the tree B) The number of nodes in the treeC) The number of internal nodes in the tree D) The height of the tree

Your Answer

   (Not Answered)

Correct Answer

D

Page 12: gate sample

GATE   � Sample Questions - CSE3

   

Questions And Answers

Question

What does the following algorithm approximate? (Assume m > 1, � > 0).x = m;

while (x - y > �) x =   (x + y) / 2 ; y = m/x ;

print (x) ;

log m

B)

m2

1/2 D) m1/3

Not Answered)

The problems 3-SAT and 2-SAT are

both in P B) both NP-completeNP-complete and in P respectively D) undecidable and NP-complete respectively

Not Answered)

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?

AE, BE B) AE, BE, DE AEH, BEH, BCH D) AEH, BEH, DEH

Ads by Google

Download Google ChromeSearching is fast and easywith Google's web browser.www.Google.com/Chrome

Page 13: gate sample

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) 3D) 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) 6D) 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;

Page 14: gate sample

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 � Memory[5000]

2

MOV R2,(R1) ; R2 �Memory[(Rl)] 1

ADD  R2,R3 ; R2 �R2 + R3 1

MOV 6000, R2; Memory[6000] �R2

2

HALT ; Machine halts 1Let the clock cycles required for various operations be as follows:Register to/from memory transfer :        3 clock cyclesADD with both operands in register :    1 clock cycleInstruction fetch and decode :               2 clock cycles per wordThe total number of clock cycles required to execute the program is

B) 24D) 20

Not Answered)

Consider an operating system capable of loading and executing a singlesequential 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)

Page 15: gate sample

Consider the following statements with respect to user-level threads andkernel-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 kernelWhich 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 Pundecidable. 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 P3 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-orientedprogramming 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

Page 16: gate sample

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 expressionsI        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

II and IV onlyD) IV only

Not Answered)

How many distinct binary search trees can be created out of 4 distinct keys?

B) 14D) 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)

Page 17: gate sample

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) 3D) 6

Not Answered)

Postorder traversal of a given binary search tree, T produces the following sequence of keys10, 9, 23, 22, 27, 25, 15, 50, 95, 60, 40, 29Which 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)