## GATE 2001

Question 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?

S1 and S2 are both true | |

S1 is true, S2 is false | |

S1 is false, S2 is true | |

S1 and S2 are both false |

Question 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?

R1 and R2 are equivalence relations, R3 and R4 are not | |

R1 and R3 are equivalence relations, R2 and R4 are not | |

R1 and R4 are equivalence relations, R2 and R3 are not | |

R1, R2, R3 and R4 are all equivalence relations |

__R1__:

a+a = 2a

The set (a,a) is reflexive.

The set representation (a,a), (b,b) is also Symmetric.

The set representation is Transitive.

So, this is Equivalence.

__R2__:

a+a ≠ 2a

The (a,a) is non-reflexive.

__R3__:

a⋅a>0 → Reflexive

a⋅b>0 and b⋅a>0 → Symmetric

a⋅b>0, b⋅c>0 then c⋅a>0 → Transitive

The relation R3 is equivalence relation.

__R4__:

|a - a| ≤ 2, which is not possible, not Reflexive.

R1 & R3 are equivalence, R2 & R4 are not.

Question 3 |

Consider two well-formed formulas in prepositional logic

F1: P ⇒ ¬P F2: (P⇒¬P)∨(¬P⇒P)

Which of the following statements is correct?

F1 is satisfiable, F2 is valid | |

F1 unsatisfiable, F2 is satisfiable | |

F1 is unsatisfiable, F2 is valid | |

F1 and F2 are both satisfiable |

F1 is satisfiable; F2 is valid.

Question 4 |

Consider the following two statements:

- S1: {0

^{2n}|n≥1|} is a regular language

S2: {0

^{m}1

^{n}0

^{m+n}|m≥1 and n≥1|} is a regular language

Which of the following statements is correct?

Only S1 is correct | |

Only S2 is correct | |

Both S1 and S2 are correct | |

None of S1 and S2 is correct |

For S2, DFA is not possible which is not regular.

Question 5 |

Which of the following statements is true?

If a language is context free it can always be accepted by a deterministic push-down automaton | |

The union of two context free languages is context free | |

The intersection of two context free languages is context free | |

The complement of a context free language is context free |

Question 6 |

Given an arbitrary non-deterministic finite automaton (NFA) with N states, the maximum number of states in an equivalent minimized DFA is at least

N ^{2} | |

2 ^{N} | |

2N | |

N! |

^{N}.

If NFA have two states {1}{2} = 2

Then DFA may contain {ϕ}{1}{2}{1,2} = 4 = 2

^{2}= 2

^{N}

Question 7 |

More than one word is put in one cache block to

exploit the temporal locality of reference in a program | |

exploit the spatial locality of reference in a program | |

reduce the miss penalty | |

none of the above |

The temporal locality refers to reuse of data elements with a smaller regular intervals.

Question 8 |

Which of the following statements is false?

Virtual memory implements the translation of a program’s address space into physical memory address space | |

Virtual memory allows each program to exceed the size of the primary memory | |

Virtual memory increases the degree of multiprogramming | |

Virtual memory reduces the context switching overhead |

Question 9 |

A low memory can be connected to 8085 by using

INTER | |

HOLD | |

READY |

Question 10 |

Suppose a processor does not have any stack pointer register. Which of the following statements is true?

It cannot have subroutine call instruction | |

It can have subroutine call instruction, but no nested subroutine calls | |

Nested subroutine calls are possible, but interrupts are not | |

All sequences of subroutine calls and also interrupts are possible |

Question 11 |

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

xy+y'z | |

wx'y'+xy+xz | |

w'x+y'z+xy | |

xz+y |

⇒ y'z + xy

Question 12 |

A processor needs software interrupt to

test the interrupt system of the processor | |

implement co-routines | |

obtain system services which need execution of privileged instructions | |

return from subroutine |

Question 13 |

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

a hardware interrupt is needed | |

a software interrupt is needed | |

a privileged instruction (which does not generate an interrupt) is needed | |

a non-privileged instruction (which does not generate an interrupt is needed |

Question 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?

O(n) | |

O(n log n) | |

O(n ^{2}) | |

O(n!) |

Question 15 |

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

i-1 | |

⌊i/2⌋ | |

⌈i/2⌉ | |

(i+1)/2 |

Left Child is at index: 2i

Right child is at index: 2*i+1

Question 16 |

Let f(n) = n^{2}logn and g(n) = n(logn)^{10} be two positive functions of n. Which of the following statements is correct?

f(n) = O(g(n) and g(n) ≠ O(f(n)) | |

g(n) = O(f(n) and f(n) ≠ O(g(n)) | |

f(n) ≠ O(g(n)) and g(n) ≠ O(f(n)) | |

f(n) = O(g(n)) and g(n) = O(f(n)) |

^{2}logn; g(n) = n(logn)

^{10}

Cancel nlogn from f(n), g(n)

f(n) = n; g(n) = (logn)

^{9}

n is too large than (logn)

^{9}

So f(n)! = O(g(n)) and g(n) = O(f(n))

Question 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

Assembly | |

Parsing | |

Relocation | |

Symbol resolution |

Question 18 |

Which of the following statements is false?

An unambiguous grammar has same leftmost and rightmost derivation | |

An LL(1) parser is a top-down parser | |

LALR is more powerful than SLR | |

An ambiguous grammar can never be LR(k) for any k |

Option C: LALR is more powerful than SLR.

Option D: An ambiguous grammar can never be LR (k) for any k, because LR(k) algorithm aren’t designed to handle ambiguous grammars. It would get stuck into undecidability problem, if employed upon an ambiguous grammar, no matter how large the constant k is.

Question 19 |

Consider a set of n tasks with known runtimes r_{1}, r_{2}, ..., r_{n} to be run on a uniprocessor machine. Which of the following processor scheduling algorithms will result in the maximum throughput?

Round-Robin | |

Shortest-Job-First | |

Highest-Response-Ratio-Next | |

First-Come-First-Served |

Question 20 |

Where does the swap space reside?

RAM | |

Disk | |

ROM | |

On-chip cache |

When memory is full and process needs memory, inactive parts of process are put in swap space of disk.

Question 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

always decrease the number of page faults | |

always increase the number of page faults | |

sometimes increase the number of page faults | |

never affect the number of page faults |

See Belady’s anomaly is the name given to the phenomenon where increasing the number of page frames results in an increase in the number of page faults for a given memory access pattern.

This phenomenon is commonly experienced in following page replacement algorithms:

First in first out (FIFO), Second chance algorithm, Random page replacement algorithm.

Question 22 |

Which of the following requires a device driver?

Register | |

Cache | |

Main memory | |

Disk |

Question 23 |

Consider a schema R(A,B,C,D) and functional dependencies A → B and C → D. Then the decomposition of R into R_{1}(AB) and R_{2}(CD) is

dependency preserving and lossless join | |

lossless join but not dependency preserving | |

dependency preserving but not lossless join | |

not dependency preserving and not lossless join |

R

_{1}∩R

_{2}≠ 0

Given R

_{1}(A,B), R

_{2}

R

_{1}∩R

_{2}= 0

Not lossless.

The given relation decomposed into R

_{1}(A,B) and R

_{2}(C,D) and there are only two functional dependencies A→B and C→D. So the given decomposition is dependency preserving.

Question 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?

List of all vertices adjacent to a given vertex | |

List all vertices which have self loops | |

List all vertices which belong to cycles of less than three vertices | |

List all vertices reachable from a given vertex |

(b) Finding a self loop is also simple (Oop(X,X))

(c) If a → b, b → c then c!=a, finding this is also simple.

(d) List all the elements reachable from a given vertex is too difficult in Relational Algebra.

Question 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} (r) | |

r | |

σ _{A=a} (r)⨝s | |

None of the above |

(b) Display table

(c) A=a for all Tables r and s

Question 26 |

How many 4-digit even numbers have all 4 digits distinct?

2240 | |

2296 | |

2620 | |

4536 |

If last digit is (2, 4, 6, 8)

Total possibilities = 504 + 1792 = 2296

Question 27 |

Consider the following statements:

- S1: There exists 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?

Only S1 is correct | |

Only S2 is correct | |

Both S1 and S2 are correct | |

None of S1 and S2 is correct |

B = {2,3,5,7,11,13,...} set of prime numbers

C = {1,3,5,7,...} set of odd numbers

(B∪C) = {1,2,3,5,7,...}

A∩(B∪C) = {2}

Which is finite, S1 is true.

S2: Consider A=5+√3 Irrational

B=5-√3 Irrational

A+B=10 Rational

A+B, which is rational number, S2 is true.

Question 28 |

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)

S1: f(E ∩ F) = f(E) ∩ f(F)

Which of the following is true about S1 and S2?

Only S1 is correct | |

Only S2 is correct | |

Both S1 and S2 are correct | |

None of S1 and S2 is correct |

The both LHS and RHS contains the same element in E and F.

So, S1 is true.

S2: f(E∩F) = f(E)∩f(F)

E and F are partitions of A.

f(E)∩f(F) = ϕ

f(ϕ) is not defined, but f(E)∩f(F)=1.

So, S2 is false.

Question 29 |

Seven (distinct) car accidents occurred in a week. What is the probability that they all occurred on the same day?

1/7 ^{7} | |

1/7 ^{6} | |

1/2 ^{7} | |

7/2 ^{7} |

^{7}

Such as total no. of days in a week = 7

Total probability = 7 × 1/7

^{7}= 1/7

^{6}

Question 30 |

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?

8 | |

14 | |

15 | |

48 |

Same as b's divisible by 8 contains 8 state.

Total no. of states is = 8 * 6 = 48

Question 31 |

Consider the following languages:

- L1 = {ww|w ∈ {a,b}*}

L2 = {ww

^{R}|w ∈ {a,b}*, w

^{R}is the reverse of w}

L3 = {0

^{2i}|i is an integer}

L3 = {0

^{i2}|i is an integer}

Which of the languages are regular?

Only L1 and L2 | |

Only L2, L3 and L4 | |

Only L3 and L4 | |

Only L3 |

⇒ This is not regular language. We can't be able to identify where the 'w' will ends and where the next 'w' starts.

L2 = {ww

^{R}|w∈{a,b}*, w

^{R}is the reverse of w}

⇒ This also not a regular language. We can't identify where 'w' ends.

L4 = {0

^{i2}|i is an integer}

= {0

^{i}*0

^{i}|i is an integer}

⇒ This is also not a regular language. We can't identify where 0

^{i}ends.

L3 = {0

^{2i}|i is an integer}

⇒ This is regular. We can easily find whether a string is even or not.

Question 32 |

Consider the following problem X.

Given a Turing machine M over the input alphabet Σ, 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?

X is decidable | |

X is undecidable but partially decidable | |

X is undecidable and not even partially decidable | |

X is not a decision problem |

Question 33 |

Consider the following circuit with initial state Q_{0} = Q_{1} = 0. The D Flip-flops are positive edged 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?

Given clock is +edge triggered.

See the first positive edge. X is 0, and hence the output is 0, because

Y = Q

_{1N}= D

_{1}×Q

_{0}' = 0⋅Q

_{0}' = 0

At second +edge, X is 1 and Q

_{0}' is also 1. So output is 1 (when second +ve edge of the clock arrives, Q

_{0}' would surely be 1 because the setup time of flip flop is given as 20ns and clock period is ≥ 40ns).

At third +ve edge, X is 1 and Q

_{0}' is 0, so output is 0.

Now output never changes back to 1 as Q

_{0}' is always 0 and when Q

_{0}' finally becomes 1, X is 0.

Hence option (A) is the correct answer.

Question 34 |

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 re-locatable code Z. Base Register Addressing III. Passing array as parameter

(X, III) (Y, I) (Z, II) | |

(X, II) (Y, III) (Z, I) | |

(X, III) (Y, II) (Z, I) | |

(X, I) (Y, III) (Z, II) |

⇒ Writing relocatable code can be done by Base Register addressing by changing the value of Base Register.

⇒ While passing an array as parameter we use pointer and hence can use Indirect addressing.

Question 35 |

The 2’s complement representation of (-539)_{10} in hexadecimal is

ABE | |

DBC | |

DE5 | |

9E7 |

_{10}= (0010 0001 1011)

_{2}

For (-539)

_{10}= (1101 1110 0100)

_{2}

1's complement = (1101 1110 0100)

_{2}

2's complement = (1101 1110 0101)

_{2}

= (DE5)

_{16}

Question 36 |

Consider the circuit shown below. The output of a 2:1 Mux is given by the function (ac' + bc).

Which of the following is true?

f = x1' + x2 | |

f = x1'x2 + x1x2' | |

f = x1x2 + x1'x2' | |

f = x1 + x2' |

g = (1 and x1’) or (0 and x1)

g = x1’

f = ac’ + bc

f = (a and x2′) or (b and x2)

f = (g and x2′) or (x1 and x2)

f = x1’x2’ + x1x2

Question 37 |

Consider the circuit given below with initial state Q_{0} = 1, Q_{1} = Q_{2} = 0. The state of the circuit is given by the value 4Q_{2} + 2Q_{1} + Q_{0}

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

1,3,4,6,7,5,2 | |

1,2,5,3,7,6,4 | |

1,2,7,3,5,6,4 | |

1,6,5,7,2,3,4 |

Question 38 |

Consider the following data path of a simple non-pilelined CPU. The registers A, B, A_{1}, A_{2}, 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 “push r”, 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?

2 | |

3 | |

4 | |

5 |

T2: 8 → MBR, 1 cycle

T3: M[MAR] ← MBR, 2 cycles (As it is a memory operation)

So, total 5 clock cycles.

Question 39 |

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?

d(r,u) | |

d(r,u)>d(r,v) | |

d(r,u)≤d(r,v) | |

None of the above |

Question 40 |

How many undirected graphs (not necessarily connected) can be constructed out of a given set V = {v_{1}, v_{2}, ...,v_{n}} of n vertices?

n(n-1)/2 | |

2 ^{n} | |

n! | |

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

^{n}C

_{2}

Each subset of these edges will be form a graph.

No. of possible undirected graphs is 2

^{(n C 2) ⇒ 2(n(n-1)/2)}

Question 41 |

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

One | |

Two | |

Three | |

Four |

Question 42 |

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; }

10, 3 | |

31, 3 | |

27, 7 | |

None of the above |

And variable y and z of func1 points to address of variable x.

Therefore, y = y+4 ⇒ y = 10+4 = 14

and z = x+y+z ⇒ z = 14+14+3 = 31

z will be stored back in k.

Hence, x=31 and y will remain as it is (y=3).

Hence, answer is (B).

Question 43 |

Consider the following three C functions:

[PI] 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?

Only P3 | |

Only P1 and P3 | |

Only P1 and P2 | |

P1, P2 and P3 |

[P2] → It will cause problem because px is in int pointer that is not assigned with any address and we are doing dereferencing.

[P3] → It will work because memory will be stored in px that can be use further. Once function execution completes this will exist in Heap.

Question 44 |

Consider the following program

Program P2var n: int: procedure W(var x: int) begin x=x+1; print x; endprocedure Dbegin var n: int; n=3; W(n); End begin //beginP2 n=10; D; end

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

10 | |

11 | |

3 | |

None of the above |

W(n)=W(3)

Procedure W(var x; int)

begin

x = x+1 = 3+1 = 4

Print x → Print x=4

end

Question 45 |

Which of the following does not interrupt a running process?

A device | |

Timer | |

Scheduler process | |

Power failure |

Question 46 |

Consider a machine with 64 MB physical memory and a 32-bit virtual address space. If the page size is 4 KB, what is the approximate size of the page table?

16 MB | |

8 MB | |

2 MB | |

24 MB |

^{32}/ 2

^{12}= 2

^{20}

Frame size = 2

^{26}/ 2

^{12}= 2

^{14}

PT have to be stored in one frame so entry size must be 2 bytes, hence size of PT = 2

^{20}* 2 = 2 MB

Question 47 |

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.

flag[j]=true and turn=i | |

flag[j]=true and turn=j | |

flag[i]=true and turn=j | |

flag[i]=true and turn=i |

Question 48 |

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

A → B, B → CD | |

A → B, B → C, C → D | |

AB → C, C → AD | |

A → BCD |

Question 49 |

Which of the following relational calculus expressions is not safe?

{t|∃u ∈ R _{1} (t[A] = u[A])∧ ¬∃s ∈ R_{2} (t[A] = s[A])} | |

{t|∀u ∈ R _{1} (u[A]= "x" ⇒ ∃s ∈ R_{2} (t[A] = s[A] ∧ s[A] = u[A]))} | |

{t|¬(t ∈ R _{1})} | |

{t|∃u ∈ R _{1} (t[A] = u[A])∧ ∃s ∈ R_{2} (t[A] = s[A])} |

Question 50 |

Consider a relation geq which represents “greater than or equal to”, that is, (x,y) ∈ geq only if y >= 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 tuple (z,w) with z > y is deleted | |

A tuple (z,w) with z > x is deleted | |

A tuple (z,w) with w < x is deleted | |

The deletion of (x,y) is prohibited |

Question 51 |

(a) Prove that powerset (A∩B) = powerset(A)∩powerset(B)

(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

Theory Explanation is given below. |

Question 52 |

Consider the function h: N×N → N so that h(a,b) = (2a+1)2^{b}-1, where N ={0,1,2,3,…..} is the set of natural numbers.

- (a) Prove that the function h is an injection (one-one).

(b) Prove that it is also a Subjection (onto).

Theory Explanation is given below. |

Question 53 |

Construct DFA’s for the following languages:

(a) L = {w|w ∈ {a,b}*, w has baab as a subsring } (b) L = {w|w ∈ {a,b}*, w has an odd number of a's and an odd number of b's}

Theory Explanation is given below. |

Question 54 |

Give a deterministic PDA for the language L = {a^{n}cb^{2n}|n ≥ 1} over the alphabet Σ = {a,b,c}. Specify the acceptance state.

Theory Explanation is given below. |

Question 55 |

Let a decision problem X be defined as follows:

X: Given a Turing machine M over Σ and nay 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.

(b) Show that X is not even partially decidable.

Theory Explanation is given below. |

Question 56 |

Consider a disk with following specifications: 20 surface, 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 microsecond/byte, interrupt driven transfer has an interrupt overhead = 0.4 microseconds, 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?

(b) What is the data transfer rate?

(c) What is the percentage of time the CPU is required for this disk I/O for bytewise interrupts driven transfer?

(d) What is the maximum percentage of time the CPU is held up for this disk I/O for cycle-stealing DMA transfer?

Theory Explanation if given below. |

Question 57 |

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?

(b) What is the size (in bits) of the tag field per cache block?

(c) What is the number and size of comparators required for tag matching?

(d) How many address bits are required to find the byte offset within a cache block?

(e) What is the total amount of extra memory (in bytes) required for the tag bits?

Theory Explanation is given below. |

Question 58 |

(a) Is the 3-variable function f = ∑(0,1,2,4) its self-dual? Justify your answer.

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

Theory Explanation is given below. |

The function is self dual because

→ There is no mutually exclusive pair.

→ No. of minterms = No. of maxterms

(b)

Write Minimal POS.

Question 59 |

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, whereupon the process repeats. An example of input and output stream is shown below.

The input stream: 101100 01001011 0 11 The desired output: 101100 10110100 0 11

J-K master-slave flip-flops are to be used to design the circuit.

(a) Give the state transition diagram.

(b) Give the minimized sum-of-product expression for J and K inputs of one of its
state flip-flops.

Theory Explanation is given below. |

Question 60 |

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:

11: sub r2, r3, r4; /* r2 ← r3 – r4 */ 12: sub r4, r2, r3; /* r4 ← r2 – r3 */ 13: sw r2, 100(r1) /* M[r1+100] ← r2 */ 14: sub r3, r4, r2; /* r3 ← r4 – r2 */

(a) Show all data dependencies between the four instructions.

(b) Identify the data hazards.

(c) Can all hazards be avoided by forwarding in this case?

Theory Explanation is given below. |

Question 61 |

Consider the following C program:

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?

(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)?

Theory Explanation is given below. |

Question 62 |

(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.

(b) Draw the binary search tree after deleting 15 from it.

(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; it (t == NULL) return0; x=depth(t → left); S1: ____________; S2: if(x>y) return _____________: S3: else return _____________; }

Theory Explanation is given below. |

Question 63 |

Consider a weighted undirected graph with vertex set V = {n1,n2,n3,n4,n5,n6} and edge set

E = {(n1,n2,2),(n1,n3,8),(n1,n6,3),(n2,n4,4),(n2,n5,12),(n3,n4,7),(n4,n5,9), (n4,n6,4)}. The third value in each tuple represents the weight of the edge specified in the tuple.

(a) List the edges of a minimum spanning tree of the graph.

(b) How many distinct minimum spanning trees does this graph have?

(c) Is the minimum among the edge weights of a minimum spanning tree unique overall possible minimum spanning trees of a graph?

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

Theory Explanation is given below. |

(c) Yes, it always. Because 'the edge weight 2 is unique'.

(d) Yes, it always. Because 'the edge weight 9 is unique'.

Question 64 |

Consider the following grammar with terminal alphabet ∑{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.

(b) Complete the LL(1) parse table for the grammar.

Theory Explanation is given below. |

Question 65 |

The syntax of the repeat-until statement is given by the gollowing grammar

S → repeat S_{1}until E

Where E stands for expressions, S and S_{1} stand for statement. The non-terminals S and S_{1} have an attribute code that represents generated code. The nonterminal 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 repeatuntil 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 string s.

Theory Explanation is given below. |

Question 66 |

(a) Remove left-recursion from the following grammar:

S → Sa| Sb | a | b

(b) Consider the following grammar:

S → aSbS| bSaS |ε

Construct all possible parse trees for the string abab. Is the grammar ambiguous?

Theory Explanation is given below. |

Question 67 |

Two 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 (R1 is busy) do no-op; Q2: Set R1 ← 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).

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

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

Theory Explanation is given below. |

Question 68 |

Consider a disk with the 100 tracks numbered from 0 to 99 rotating at 3000 rpm. The number of sectors per track is 100. the time to move the head between two successive tracks is 0.2 millisecond.

(a) Consider a set of disk requests 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?

(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?

Theory Explanation is given below. |

Question 69 |

Consider the relation examinee (regno, name, score), where regno is the primary key to score is a real number.

(a) Write a relational algebra using (∏,σ,ρ,×) to find the list of names which appear more than once in examinee.

(b) Write an SQL query to list the regno of examinees who have a score greater than the average score.

(c) Suppose the relation appears (regno, centr_code) specifies the center where an examinee appears. Write an SQL query to list the centr_code having an examinee of score greater than 80.

Theory Explanation is given below. |

Question 70 |

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.

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

Theory Explanation is given below. |