section a 1.this question consists of (twenty five) subq...

19
CS Branch GATE Paper 2001 Page : 1 SECTION A 1. This question consists of (TWENTY FIVE) sub-questions (1.1-1.25) of one mark each. For each of the sub-questions, four possible answers (a, b, c and d) are given, out of which only one is correct. (1 25=25) 1.1 Consider the following statements: S1: The sum of two singular n × n matrices may be non-singular S2: The sum of two n × n non-singular matrices may be singular Which of the following statements is correct? (A) S1 and S2 are both true (B) S1 is true, S2 is false (C) S1 is false, S2 is true (D) S1 and S2 are both false 1.2 Consider the following relations: R1 (a,b) iff (a+b) is even over the set of integers R2 (a,b) iff (a+b) is odd over the set of integers R3 (a,b) iff a.b > 0 over the set of non-zero rational numbers R4 (a,b) iff |a -b|≤ 2 over the set of natural numbers Which of the following statements is correct? (A) R1 and R2 are equivalence relations, R3 and R4 are not (B) R1 and R3 are equivalence relations, R2 and R4 are not (C) R1 and R4 are equivalence relations, R2 and R3 are not (D) R1, R2, R3 and R4 are all equivalence relations 1.3 Consider two well-formed formulas in propositional logic F1: P ¬P F2: (P ¬ P) ( ¬P P) Which of the following statements is correct? (A) F1 is satisfiable, F2 is valid (B) F1 is unsatisfiable, F2 is satisfiable (C) F1 is unsatisfiable, F2 is valid (D) F1 and F2 are both satisfiable 1.4 Consider the following two statements: S1: {0 2n | n ≥ 1} is a regular language

Upload: others

Post on 21-Mar-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SECTION A 1.This question consists of (TWENTY FIVE) subq ...media.careerlauncher.com.s3.amazonaws.com/gate/CS_GATE Papers_Version_… · CS Branch GATE Paper 2001 Page : 1 SECTION

CS Branch GATE Paper 2001

Page : 1

SECTION A

1. This question consists of (TWENTY FIVE) sub-questions (1.1-1.25) of one mark each. For each of the sub-questions, four possible answers (a, b, c and d) are given, out of which only one is correct.

(1 25=25) 1.1 Consider the following statements:

S1: The sum of two singular n × n matrices may be non-singular

S2: The sum of two n × n non-singular matrices may be singular

Which of the following statements is correct?

(A) S1 and S2 are both true (B) S1 is true, S2 is false (C) S1 is false, S2 is true (D) S1 and S2 are both false

1.2 Consider the following relations: R1 (a,b) iff (a+b) is even over the set of integers R2 (a,b) iff (a+b) is odd over the set of integers R3 (a,b) iff a.b > 0 over the set of non-zero rational numbers R4 (a,b) iff |a -b|≤ 2 over the set of natural numbers Which of the following statements is correct?

(A) R1 and R2 are equivalence relations, R3 and R4 are not (B) R1 and R3 are equivalence relations, R2 and R4 are not (C) R1 and R4 are equivalence relations, R2 and R3 are not (D) R1, R2, R3 and R4 are all equivalence relations

1.3 Consider two well-formed formulas in propositional logic

F1: P ¬P F2: (P ¬ P) ∨ ( ¬P P) Which of the following statements is correct?

(A) F1 is satisfiable, F2 is valid (B) F1 is unsatisfiable, F2 is satisfiable (C) F1 is unsatisfiable, F2 is valid (D) F1 and F2 are both satisfiable

1.4 Consider the following two statements:

S1: {02n| n ≥ 1} is a regular language

Page 2: SECTION A 1.This question consists of (TWENTY FIVE) subq ...media.careerlauncher.com.s3.amazonaws.com/gate/CS_GATE Papers_Version_… · CS Branch GATE Paper 2001 Page : 1 SECTION

CS Branch GATE Paper 2001

Page : 2

S2: {0m 1n 0 m+ n | m≥1 and n ≥1}is a regular language

Which of the following statements is correct?

(A) Only S1 is correct (B) Only S2 is correct

(C) Both S1 and S2 are correct (D) None of S1 and S2 is correct

1.5 Which of the following statements is true? (A) If a language is context free it can always be accepted by a deterministic push-down

automaton (B) The union of two context free languages is context free (C) The intersection of two context free languages is context free (D) The complement of a context free language is context free

1.6 Given an arbitrary non-deterministic finite automaton (NFA) with N states, the maximum number

of states in an equivalent minimized DFA is atleast (A) (B)

(C) 2N (D) N!

1.7 More than one word are put in one cache block to

(A) Exploit the temporal locality of reference in a program (B) Exploit the spatial locality of reference in a program (C) Reduce this miss penalty (D) None of the above

1.8 Which of the following statements is false?

(A) Virtual memory implements the translation of a program‘s address space into physical memory address space

(B) Virtual memory allows each program to exceed the size of the primary memory (C) Virtual memory increases the degree of multiprogramming (D) Virtual memory reduces the context switching overhead

1.9 A low memory can be connected to 8085 by using

(A) INTER (B) RESET IN

(C) HOLD (D) READY

Page 3: SECTION A 1.This question consists of (TWENTY FIVE) subq ...media.careerlauncher.com.s3.amazonaws.com/gate/CS_GATE Papers_Version_… · CS Branch GATE Paper 2001 Page : 1 SECTION

CS Branch GATE Paper 2001

Page : 3

1.10 Suppose a processor does not have any stack pointer register. Which of the following statements is true? (A) It cannot have subroutine call instruction (B) It can have subroutine call instruction, but no nested subroutine calls (C) Nested subroutine calls are possible, but interrupts are not (D) All sequences of subroutine calls and also interrupts are possible

1.11 Given the following Karnaugh map, which one of the following represents the minimal Sum-Of-Products of the map?

wx yz

00 01 11 10

00

01 11 10

0

0 0

1

1

0

1

1 0 0

(A) xy +y′z (B) wx′y′+ xy+ xz (C) w′x+ y′z+ xy (D) xz+y

1.12 A processor needs software interrupt to (A) test the interrupt system of the processor (B) implement co-routines (C) obtain system services which need execution of privileged instructions (D) return from subroutine

1.13 A CPU has two modes-privileged and non-privileged. In order to change the mode from

privileged to non-privileged (A) a hardware interrupt is needed (B) a software interrupt is needed (C) a privileged instruction (which does not generate an interrupt) is needed (D) a non-privileged instruction (which does not generate an interrupt) is needed

Page 4: SECTION A 1.This question consists of (TWENTY FIVE) subq ...media.careerlauncher.com.s3.amazonaws.com/gate/CS_GATE Papers_Version_… · CS Branch GATE Paper 2001 Page : 1 SECTION

CS Branch GATE Paper 2001

Page : 4

1.14 Randomized quicksort is an extension of quicksort where the pivot is chosen randomly. What is the worst case complexity of sorting n numbers using randomized quicksort? (A) O(n) (B) O(n lg n)

(C) O(n2) (D) O(n!)

1.15 Consider an array representation of an n element binary heap where the elements are

stored from index 1 to index n of the array. For the element stored at index i of the array (i ≤ n), the index of the parent is (A) i – 1 (B)

(C) (D) (i + 1) /2

1.16 Let f(n) = n2 and g(n) = n ( )10 be two positive functions of n. Which of the following

statements is correct? (A) f(n) = O(g(n) and g(n) O (f(n)) (B) g(n) = O(f(n) and f(n) O (g(n))

(C) f(n) O(g(n) and g(n) O (f(n)) (D) f(n) = O(g(n) and g(n) = O (f(n))

1.17 The process of assigning load addresses to the various parts of the program and adjusting the

code and date in the program to reflect the assigned addresses is called (A) Assembly (B) Parsing

(C) Relocation (D) Symbol resolution

1.18 Which of the following statements is false?

(A) An unambiguous grammar has same leftmost and rightmost derivation (B) An LL(1) parser is a top-down parser (C) LALR is more powerful than SLR (D) An ambiguous can never be LR(k) for any k

1.19 Consider a set of n tasks with known runtimes r1, r2, …. rn to be run on a

uniprocessor machine. Which of the following processor scheduling algorithms will result in the maximum throughput? (A) Round-Robin (B) Shortest-Job-First

(C) Highest-Response-Ratio-Next (D) First-Come-First-Served

1.20 Where does the swap space reside?

(A) RAM (B) Disk

(C) ROM (D) On-chip cache

Page 5: SECTION A 1.This question consists of (TWENTY FIVE) subq ...media.careerlauncher.com.s3.amazonaws.com/gate/CS_GATE Papers_Version_… · CS Branch GATE Paper 2001 Page : 1 SECTION

CS Branch GATE Paper 2001

Page : 5

1.21 Consider a virtual memory system with FIFO page replacement policy. For an arbitrary page access pattern, increasing the number of page frames in main memory will (A) always decrease the number of page faults (B) always increase the number of page faults (C) sometimes increase the number of page faults (D) never affect the number of page faults

1.22 Which of the following requires a device driver?

(A) Register (B) Cache

(C) Main memory (D) Disk

1.23 Consider a schema R(A,B,C,D) and functional dependencies A B and C D.

Then the decomposition of R into R1 (AB) and R2(CD) is (A) dependency preserving and lossless join (B) lossless join but not dependency preserving (C) dependency preserving but not lossless join (D) not dependency preserving and not lossless join

1.24 Suppose the adjacency relation of vertices in a graph is represented in a table Adj (X,Y).

Which of the following queries cannot be expressed by a relational algebra expression of constant length? (A) List all vertices adjacent to a given vertex (B) List all vertices which have self loops (C) List all vertices which belong to cycles of less than three vertices (D) List all vertices reachable from a given vertex

1.25 Let r and s be two relations over the relation schemes R and S respectively, and let A be an attribute in R. Then the relational algebra expression σA=a (r⋈s) is always equal to (A) σA=a (r) (B) r

(C) σA=a(r)⋈s (D) None of these

2. This question consists of (TWENTY FIVE) sub-questions (2.1-2.25) of TWO marks each.

For each of the sub-questions, four possible answers are given, out of which only one is correct.

(2 25=50) 2.1 How many 4-digit even numbers have all 4 digits distinct?

(A) 2240 (B) 2296

(C) 2620 (D) 4536

Page 6: SECTION A 1.This question consists of (TWENTY FIVE) subq ...media.careerlauncher.com.s3.amazonaws.com/gate/CS_GATE Papers_Version_… · CS Branch GATE Paper 2001 Page : 1 SECTION

CS Branch GATE Paper 2001

Page : 6

2.2 Consider the following statements: S1: There exist infinite sets A, B, C such that A∩(B∪C) is finite. S2: There exists two irrational numbers x and y such that (x + y) is rational. Which of the following is true about S1 and S2?

(A) Only S1 is correct (B) Only S2 is correct

(C) Both S1 and S2 are correct (D) None of S1 and S2 is correct

2.3 Let f: A B be a function, and let E and F be subsets of A. Consider the following statements

about images. S1 : f(E∪F) = f(E) ∪f(F) S2 :f(E∩F) = f(E) ∩f(F) Which of the following is true about S1 and S2?

(A) Only S1 is correct (B) Only S2 is correct (C) Both S1 and S2 are correct (D) None of S1 and S2 is correct

2.4 Seven (distinct) car accidents occurred in a week. What is the probability that they all occurred on the same day? (A) 1/77 (B) 1/76

(C) 1/27 (D) 7/27

2.5 Consider a DFA over Σ = {a,b}accepting all strings which have number of a’s divisible by 6 and number of b‘s divisible by 8. What is the minimum number of states that the DFA will have?

(A) 8 (B) 14

(C) 15 (D) 48

2.6 Consider the following languages

L1 = { ww | w ϵ {a, b}*}

L2 = { wwR | w ϵ {a,b}* , wR is the reverse of w}

L3 = { 02i| i is an integer}

L4 = { | i is an integer}

Which of the languages are regular?

Page 7: SECTION A 1.This question consists of (TWENTY FIVE) subq ...media.careerlauncher.com.s3.amazonaws.com/gate/CS_GATE Papers_Version_… · CS Branch GATE Paper 2001 Page : 1 SECTION

CS Branch GATE Paper 2001

Page : 7

(A) Only L1 and L2 (B) Only L2, L3 and L4 (C) Only L3 and L4 (D) Only L3

2.7 Consider the following problem X.

Given a Turing machine M over the input alphabet S, any state q of M and a word w ∈ Σ*, does the computation of M on w visit the state q? Which of the following statements about X is correct? (A) X is decidable (B) X is undecidable but partially decidable (C) X is undecidable and not even partially decidable (D) X is not a decision problem

2.8 Consider the following circuit with initial state Q0 = Q1 = 0. The D Flip-flops are positive edge

triggered and have set up times 20 nanosecond and hold times 0.

Consider the following timing diagrams of X and C; the clock period of C ≥ 40 nanosecond. Which one is the correct plot of Y?

(A)

(B)

(C)

(D)

D1

X

C

D0

Q1

0 Clock Clock

Y

C

X

Page 8: SECTION A 1.This question consists of (TWENTY FIVE) subq ...media.careerlauncher.com.s3.amazonaws.com/gate/CS_GATE Papers_Version_… · CS Branch GATE Paper 2001 Page : 1 SECTION

CS Branch GATE Paper 2001

Page : 8

2.9 Which is the most appropriate match for the items in the first column with the items in the second column?

X. Indirect Addressing I. Array implementation

Y. Indexed Addressing II. Writing relocatable code

Z. Base Register Addressing III. Passing array as parameter

(A) (X, III), (Y, I), (Z, II) (B) (X, II), (Y, III), (Z, I)

(C) (X, III), (Y, II), (Z, I) (D) (X, I), (Y, III), (Z, II)

2.10 The 2’s complement representation of ( −539)10 in hexadecimal is

(A) ABE (B) DBC

(C) DE5 (D) 9E7

2.11 Consider the circuit shown below. The output of a 2:1 Mux is given by the function

( + bc).

Which of the following is true?

(A) f = x1′+ x2 (B)

(C) f= x1 x 2 + (D) f= x1 + x2′

2.12 Consider the circuit given below with initial state Q0 =1, Q1 = Q2 = 0. The state of the circuit is

given by the value 4Q2+2 Q1+ Q0

a 2:1

Mux

b c

a 2:1

Mux

b c

1

0

f

x1

x2

g

Page 9: SECTION A 1.This question consists of (TWENTY FIVE) subq ...media.careerlauncher.com.s3.amazonaws.com/gate/CS_GATE Papers_Version_… · CS Branch GATE Paper 2001 Page : 1 SECTION

CS Branch GATE Paper 2001

Page : 9

Which one of the following is the correct state sequence of the circuit?

(A) 1,3,4,6,7,5,2 (B) 1,2,5,3,7,6,4

(C) 1,2,7,3,5,6,4 (D) 1,6,5,7,2,3,4

2.13 Consider the following datapath of a simple non-pipelined CPU. The registers A, B, A1, A2,

MDR, the bus and the ALU are 8-bit wide. SP and MAR are 16-bit registers. The MUX is of size 8 ×(2:1) and the DEMUX is of size 8 ×(1:2). Each memory operation takes 2 CPU clock cycles and uses MAR (Memory Address Register) and MDR (Memory Date Register). SP can be decremented locally.

The CPU instruction where = A or B, has the specification M [SP] ← r SP ← SP - 1 How many CPU clock cycles are needed to execute the “push r” instruction?

(A) 2 (B) 3

(C) 4 (D) 5

A2 A1 B A

SP MAR MDR

MUX 1:2

DEMUX 1:2

dcr

D0 Q0 D1 Q1 D2 Q2

LSB MSB

clock

Page 10: SECTION A 1.This question consists of (TWENTY FIVE) subq ...media.careerlauncher.com.s3.amazonaws.com/gate/CS_GATE Papers_Version_… · CS Branch GATE Paper 2001 Page : 1 SECTION

CS Branch GATE Paper 2001

Page : 10

2.14 Consider an undirected unweighted graph G. Let a breadth –first traversal of G be done starting from a node r. Let d(r,u) and d(r, v) be the lengths of the shortest paths from r to u and v respectively in G. If u is visited before v during the breadth-first traversal, which of the following statements is correct? (A) d(r, u) < d(r, v) (B) d(r, u) > d(r, v)

(C) d(r, u) d(r, v) (D) none of these

2.15 How many undirected graphs (not necessarily connected) can be constructed out of a given

set V = { v1, v2 ,………….vn } of n vertices?

(A) n(n-1) /2 (B) 2n

(C) n! (D) 2 n(n-1)/2

2.16 What is the minimum number of stacks of size n required to implement a queue of size n?

(A) One (B) Two

(C) Three (D) Four

2.17 What is printed by the print statements in the program P1 assuming call by reference parameter passing? Program P1() { x=10; y=3; func1(y,x,x); print x; print y; } func1(x,y,z) {

y=y+4;

z=x+y+z;

}

(A) 10, 3 (B) 31, 3

(C) 27, 7 (D) None of these

Page 11: SECTION A 1.This question consists of (TWENTY FIVE) subq ...media.careerlauncher.com.s3.amazonaws.com/gate/CS_GATE Papers_Version_… · CS Branch GATE Paper 2001 Page : 1 SECTION

CS Branch GATE Paper 2001

Page : 11

2.18 Consider the following three C functions: [P1] int*g(void)

{ int x=10; return(&x); }

[P2] int*g(void) { int*px; *px=10; return px; }

[P3] int*g(void) { int*px;

px =(int*)malloc (sizeof (int)); *px=10; return px;

} Which of the above three functions are likely to cause problems with pointers?

(A) Only P3 (B) Only P1 and P3

(C) Only P1 and P2 (D) P1, P2 and P3

2.19 Consider the following program

Program P2 var n:int:

procedure W(var x:int) begin x=x+1; print x; end procedure D begin var n:int; n=3; W(n); end

begin //begin P2

Page 12: SECTION A 1.This question consists of (TWENTY FIVE) subq ...media.careerlauncher.com.s3.amazonaws.com/gate/CS_GATE Papers_Version_… · CS Branch GATE Paper 2001 Page : 1 SECTION

CS Branch GATE Paper 2001

Page : 12

n = 10; D;

end If the language has dynamic scoping and parameters are passed by reference, what will be printed by the program?

(A) 10 (B) 11

(C) 3 (D) None of these

2.20 Which of the following does not interrupt a running process?

(A) A device (B) Timer

(C) Scheduler process (D) Power failure

2.21 Consider a machine with 64 MB physical memory and a 32-bit virtual address space. If

the page size is 4KB, what is the approximate size of the page table? (A) 16 MB (B) 8 MB

(C) 2 MB (D) 24 MB

2.22 Consider Peterson‘s algorithm for mutual exclusion between two concurrent processes i and

j. The program executed by process is shown below. repeat flag[i]=true; turn=j; while (P) do no-op; Enter critical section, perform actions, then exit critical section flag[i]=false; Perform other non-critical section actions. until false; For the program to guarantee mutual exclusion, the predicate P in the while loop should be

(A) flag[j]=true and turn=i

(B) flag[j]=true and turn=j

(C) flag[i]=true and turn=j

(D) flag[i]=true and turn=i

2.23 R(A,B,C,D) is a relation. Which of the following does not have a lossless join, dependency preserving BCNF decomposition?

(A) A→B, B → CD (B) A →B, B→ C, C→D (C) AB → C, C→AD (D) A → BCD

Page 13: SECTION A 1.This question consists of (TWENTY FIVE) subq ...media.careerlauncher.com.s3.amazonaws.com/gate/CS_GATE Papers_Version_… · CS Branch GATE Paper 2001 Page : 1 SECTION

CS Branch GATE Paper 2001

Page : 13

2.24 Which of the following relational calculus expressions is not safe? (A) {t | u ϵ R1 (t [A] = u [A] ) ¬ s ϵ R2 (t[A] = s [A]) } (B) {t | u ϵ R1 (u [A] = ⇒ s ϵ R2 (t[A] = s [A] s[A] = u [A] )) } (C) {t | ¬(t ϵ R1)} (D) {t | u ϵ R1 (t [A] = u [A] ) ¬ s ϵ R2(t [A] = s [A]) }

2.25 Consider a relation geq which represents “greater than or equal to“, that is, (x,y)∈ geq

only if y 3 x. Create table geq

(Ib integer not null

ub integer not null

primary key 1b

foreign key (ub) references geq on delete cascade)

Which of the following is possible if a tuple (x,y) is deleted?

(A) A tuple (z,w) with z > y is deleted (B) A tuple (z,w) with z > x is deleted (C) A tuple (z,w) with w < x is deleted (D) The deletion of (x,y) is prohibited

SECTION-B (75 Marks)

This section consists of TWENTY questions of FIVE marks each. ANY FIFTEEN out of these questions have to be answered. (5 15=75) 3. (A) Prove that powerset (A B) = powerset (A) powerset (B) (2)

(B) Let sum (n) = 0 + 1 +2+ . . . . . + n for all natural numbers n. Give an induction proof to show that the following equation is true for all natural numbers m and n: Sum (m + n) = sum (m) + sum (n) + mn (3)

4. Consider the function h: N N → N so that h(a, b) = (2a + 1) 2b – 1, where N = { 0, 1, 2, 3, . . . .} is the set of natural numbers. (A) Prove that the function h is an Injection (one –one). (2) (B) Prove that it is also a Surjection (onto). (3)

Page 14: SECTION A 1.This question consists of (TWENTY FIVE) subq ...media.careerlauncher.com.s3.amazonaws.com/gate/CS_GATE Papers_Version_… · CS Branch GATE Paper 2001 Page : 1 SECTION

CS Branch GATE Paper 2001

Page : 14

5. Construct DFA’s for the following languages: (A) L = { w | w {a, b}*, w has baab as a substring} (3) (B) L = { w | w {a, b}*, w has an odd number of a’s and an odd number of b’s} (2)

6. Give a deterministic PDA for the language

L = { over the alphabet = {a, b, c}. Specify the acceptance state. (5)

7. Let a decision problem X be defined as follows: X: Given a Turing machine M over any word w Does M loop forever on w? You may assume that the halting problem of Turing machine is undecidable but partially decidable. (A) Show that X is undecidable. (2) (B) Show that X is not even partially decidable. (3)

8. Consider a disk with following specifications: 20 surfaces, 1000 tracks/surface, 16 sectors/track, data density 1 KB/sector, rotation speed 3000 rpm. The operating system initiates the transfer between the disk and the memory sector-wise. Once the head has been placed on the right track, the disk reads a sector in a single scan. It reads bits from the sector while the head is passing over the sector. The read bits are formed into bytes in a serial –in –parallel-out buffer and each byte is then transferred to memory. The disk writing is exactly a complementary process. For parts (c) and (d) below, assume memory read-write time = 0.1 micro-second/byte, interrupt driven transfer has an interrupt overhead = 0.4 micro-second, the DMA initialization and termination overhead is negligible compared to the total sector transfer time. DMA requests are always granted. (A) What is the total capacity of the disk? (1) (B) What is the data transfer rate? (1) (C) What is the percentage of time the CPU is required for this disk i/o for byte-wise interrupt

driven transfer? (2) (D) What is the maximum percentage of time the CPU is held up for this disk i/o for cycle-

stealing DMA transfer? (1)

9. A CPU has 32-bit memory address and a 256 KB cache memory. The cache is organized as a 4-way set associative cache with cache block size of 16 bytes. (A) What is the number of sets in the cache? (1) (B) What is the size (in bits) of the tag field per cache block? (1) (C) What is the number and size of comparators required for tag matching? (1)

Page 15: SECTION A 1.This question consists of (TWENTY FIVE) subq ...media.careerlauncher.com.s3.amazonaws.com/gate/CS_GATE Papers_Version_… · CS Branch GATE Paper 2001 Page : 1 SECTION

CS Branch GATE Paper 2001

Page : 15

(D) How many address bits are required to find the byte offset within a cache block? (1) (E) What is the total amount of extra memory (in bytes) required for the tag bits? (1)

10. (A) Is the 3-variable function f = (0, 1, 2, 4) is self –dual? Justify your answer. (2)

(B) Give a minimal product-of-sum form of the b4 output of the following excess-3 to BCD converter. (3)

11. A sequential circuit takes an input stream of 0’s and 1’s and produces an output stream of 0’s and 1’s. Initially it replicates the input on its output until two consecutive 0’s are encountered on the input. From then onward, it produces an output stream which is the bit-wise complement of input stream until it encounters two consecutive 1’s, where upon the process repeats. An example of input and output stream is shown below.

J-K master-slave flip-flops are to be used to design the circuit. (A) Give the state transition diagram. (2) (B) Give the minimized sum-of-product expressions for J and K inputs of one of its state flip-

flops. (3)

12. Consider a 5-stage pipeline – IF (Instruction Fetch), ID(Instruction Decode and register read), EX(Execute), MEM(Memory), and WB(Write back). All (memory or register) reads take place in the second phase of a clock cycle and writes occur in the first phase of the clock cycle. Consider the execution of the following instruction sequence: I1: sub r2, r3, r4; /* */ I2: sub r4, r2, r3; /* */ I3: sw r2, 100(r1) /* */ I4: sub r3, r4, r2; /* */ (A) Show all data dependencies between the four instructions. (1) (B) Identify the data hazards. (2) (C) Can all hazards be avoided by forwarding in this case? (2)

13. Consider the following C program:

Excess 3 TO BCD

Page 16: SECTION A 1.This question consists of (TWENTY FIVE) subq ...media.careerlauncher.com.s3.amazonaws.com/gate/CS_GATE Papers_Version_… · CS Branch GATE Paper 2001 Page : 1 SECTION

CS Branch GATE Paper 2001

Page : 16

void abc(char *s) { if (s[0] = = ‘\0’) return; abc(s +1); abc(s+1); printf(“%c”, s[0]); } main( ) { abc(“123”); } (A) What will be the output of the program? (3) (B) If abc(s) is called with a null-terminated string s of length n characters (not counting the null

(‘\0’) character), how many characters will be printed by abc(s)? (2)

14. (A) Insert the following keys one by one into a binary search tree in the order specified. 15, 32, 20, 9, 3, 25, 12, 1 Show the final binary search tree after the insertions. (2) (B) Draw the binary search tree after deleting 15 from it. (1) (C) Complete the statements S1, S2, and S3 in the following function so that the function computes the depth of a binary rooted at t. typedef struct tnode { int key; struct tnode *left, *right; } *Tree; int depth (Tree t) { int x, y; if (t = = NULL) return 0; x = depth (t →left); S1: ______________; S2: if (x > y) return ____________; S3: else return_____________; } (2)

15. Consider a weighted undirected graph with vertex set V = and edge set E=

The third value in each tuple represents the weight of the edge specified in the tuple.

Page 17: SECTION A 1.This question consists of (TWENTY FIVE) subq ...media.careerlauncher.com.s3.amazonaws.com/gate/CS_GATE Papers_Version_… · CS Branch GATE Paper 2001 Page : 1 SECTION

CS Branch GATE Paper 2001

Page : 17

(A) List the edges of a minimum spanning tree of the graph. (2) (B) How many distinct minimum spanning trees does this graph have? (1) (C) Is the maximum among the edge weights of a minimum spanning tree unique over all

possible minimum spanning trees of a graph? (1)

(D) Is the maximum among the edge weights of minimum spanning tree unique over all possible minimum spanning trees of a graph?

16. Consider the following grammar with terminal alphabet S = {a, (,), +, *} and start symbol E. The production rules of the grammar are: E → aA E → (E) A → +E A → *E A → (A) Compute the FIRST and FOLLOW sets for E and A. (2) (B) Compute the LL(1) parse table for the grammar. (3)

17. The syntax of the repeat-until statement is given by the following grammar

S → repeat S1 until E Where E stands for expressions, S and S1 stand for statement. The non-terminals S and S1 have an attribute code that represents generated code. The non-terminal E has two attributes. The attribute code represents generated code to evaluate the expression and store its truth value in a distinct variable, and the attribute varName contains the name of the variable in which the truth value is stored? The truth value stored in the variable is 1 if E is true, 0 if E is false. Give a syntax-directed definition to generate three-address code for the repeat-until statement. Assume that you can call a function newlabel ( ) that returns a distinct label for a statement. Use the operator ‘| |’ to concatenate two strings and the function gen(s) to generate a line containing the strings. (5)

18. (A) Remove left-recursion from the following grammar: S → Sa | Sb | a | b (2) (B) Consider the following grammar: S → aSbS | bSaS | e Construct all possible parse trees for the string abab. Is the grammar ambiguous? (3)

Page 18: SECTION A 1.This question consists of (TWENTY FIVE) subq ...media.careerlauncher.com.s3.amazonaws.com/gate/CS_GATE Papers_Version_… · CS Branch GATE Paper 2001 Page : 1 SECTION

CS Branch GATE Paper 2001

Page : 18

19. The concurrent processes P1 and P2 want to use two resources R1 and R2 in a mutually exclusive manner. Initially R1 and R2 are free. The programs executed by the two processes are given below. Program for P1: S1: While (R1 is busy) do no-op; S2: Set R1 busy; S3: While (R2 is busy) do no-op; S4: Set R2 busy; S5: Use R1 and R2; S6: Set R1 free; S7: Set R2 free; Program for P2: Q1: While (R2 is busy) do no-op; Q2: Set R2 busy; Q3: While (R1 is busy) do no-op; Q4: Set R1 busy; Q5: Use R1 and R2; Q6: Set R2 free; Q7: Set R1 free; (A) Is mutual exclusion guaranteed for R1 and R2? If not, show a possible interleaving of the

statements of P1 and P2 such that mutual exclusion is violated (i.e, both P1 and P2 use R1 or R2 at the same time) (2)

(B) Can deadlock occur in the above program? If yes, show a possible interleaving of the statements of P1 and P2 leading to deadlock. (2)

(C) Exchange the statements Q1 and Q3 and statements Q2 and Q4. Is mutual exclusion guaranteed now? Can deadlock occur? (1)

20. Consider a disk with the 100 tracks numbered from 0 to 99 rotating at 3000rpm. The number of sectors per track is 100. The time to move the head between two successive tracks is 0.2 milisecond. (A) Consider a set of disk request to read data from tracks 32, 7, 45, 5 and 10. Assuming that the

elevator algorithm is used to schedule disk requests, and the head is initially at track 25 moving up (towards larger track numbers), what is the total seek time for servicing the requests? (2)

(B) Consider an initial set of 100 arbitrary disk requests and assume that no new disk requests arrive while servicing these requests. If the head is initially at track 0 and the elevator algorithm is used to schedule disk requests, what is the worst case time to complete all the requests? (3)

Page 19: SECTION A 1.This question consists of (TWENTY FIVE) subq ...media.careerlauncher.com.s3.amazonaws.com/gate/CS_GATE Papers_Version_… · CS Branch GATE Paper 2001 Page : 1 SECTION

CS Branch GATE Paper 2001

Page : 19

21. Consider the relation examinee (regno, name, score), where regno is the primary key and score is a real number. (A) Write a relational algebra using (Π ) to find the list of names which appear more than

once in examinee. (2) (B) Write an SQL query to list the regno of examinees who have a score greater than the average

score. (2) (C) Suppose the relation appears (regno, centr_code) specifies the centre where an examinee

appears. Write an SQL query to list the centr_code having an examinee of score greater than 80. (1)

22. We wish to construct a B+ tree with fan-out (the number of pointers per node) equal to 3 for the

following set of key values: 80, 50, 10, 70, 30, 100, 90 Assume that the tree is initially empty and the values are added in the order given. (A) Show the tree after insertion of 10, after insertion of 30, and after insertion of 90.

Intermediate trees need not be shown. (3)

(B) The key values 30 and 10 are now deleted from the tree in that order. Show the tree after each deletion. (2)