157
http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 1 1. Which of the following can be used for zeroing out alternate bits of a 16-bit number using the AND operation A. 0101 B. AAAA C. EEEE D. FFFF E. 1010 2. If n is even, and assuming that all A[i] are distinct, what does the execution of the code below result in : for (i = 0; i < n; i++) A[i] = A[n+1-i]; A. It results in 2 copies of each value data B. The values remain unchanged. C. The array reverses. D. None of the above 3. If L \subseteq {0,1}* is not recursive then which of the following are true: I. L' is not recursive II. L is contained in a recursive set III. L is infinite A. I B. III C. I,III D. I,II,III 4. What is the min number of states required for converting ANY NFA with N states to a DFA: A. N B. N^2 C. 2^N D. 2N E. N! 5. What is the minimum number of states in the DFA that recognizes all strings with number of 1's divisible by 10, and # 0's div by 12 A. 12 B. 22 C.23 D.60 E.120 6. Which of the following does not help in writing programs for pipelined architectures: A. Unrolling short loops B. Writing short code segments with lot of subroutines C. Using registers as far as possible. D. Using direct/immediate modes of access

GRE Subject CS

Embed Size (px)

Citation preview

Page 1: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 1

1. Which of the following can be used for zeroing out alternate bits of

a 16-bit number using the AND operation

A. 0101 B. AAAA C. EEEE D. FFFF E. 1010

2. If n is even, and assuming that all A[i] are distinct, what does the

execution of the code below result in :

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

A[i] = A[n+1-i];

A. It results in 2 copies of each value data

B. The values remain unchanged.

C. The array reverses.

D. None of the above

3. If L \subseteq {0,1}* is not recursive then which of the following are true:

I. L' is not recursive

II. L is contained in a recursive set

III. L is infinite

A. I B. III C. I,III D. I,II,III

4. What is the min number of states required for converting ANY NFA with N

states to a DFA:

A. N B. N^2 C. 2^N D. 2N E. N!

5. What is the minimum number of states in the DFA that recognizes all

strings with number of 1's divisible by 10, and # 0's div by 12

A. 12 B. 22 C.23 D.60 E.120

6. Which of the following does not help in writing programs for pipelined

architectures:

A. Unrolling short loops

B. Writing short code segments with lot of subroutines

C. Using registers as far as possible.

D. Using direct/immediate modes of access

Page 2: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 2

E. Fixed-length integer instructions

7. In a system using buffered I/O, which of the following are needed for

ensuring a consistant state on recovery from a crash:

I. Allocate more main memory for buffers

II. Duplication of buffers in memory

III. Atomic write of multiple buffers

A. I B.III C. II, III D.I,II E. I, II, III

8. In a packet delivery system, a packet is retransmitted when lost, till it

successfully transmitted. If the probability of loss is C, and

retransmissions are independent, what is the expected number of unsuccessful

transmission before a successful transmission:

A. 1/(1-C) B. C/(1-C) C. 1/(1-C)^2 D. C E. 1-C

9. Which of the following are true:

I. Set Associative Cache is cheaper than a direct mapped cache.

II. Set Associative Cache has higher hit ratio than a Fully assoc. cache

III. Set Assoc. Cache has higher hit ratio than a direct mapped cache

A. I B. I,III C. III D. I,II E. I,II,III

10. If a,b,c occur with equal probability, which of the following is a valid

Huffman coding of these symbols

a. a=1, b=0, c= 11

b. a=0, b=111, c=000

c. a=0, b= 10, c= 11

d. None of the above

11. Policy 1: Allocate a file on disk contiguously

Policy 2: Allocate a file on arbitrary blocks on disk

Which of the following is/are the advantage of Policy 1:

I. It is good for reading large files sequentially

II. Files are easily expandable in this method

Page 3: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 3

III. Random access is faster in this method

A. I B. I,III C. II D. III E. I,II,III

12. Which of the following is FALSE about RISC architectures:

A. All arithmetic operations deal with registers

B. The only instructions accessing memory are load and store

C. The compiled code is shorter for RISC than for CISC

(JUNTA, supply the choices)

13. For standard Pascal syntax, the following are defined for any set of test

parameters acting on a program:

Statement coverage : All statements in the program are executed at

least once

Branch coverage : The boolean condition of any if/while stmt evaluates

to both true, and false at least once.

Expression coverage: All integer/boolean variables evaluate to atleast 2

distinct values during the course of the execution.

Which of the following are true:

I. Branch coverage => Statement coverage

II. Expression coverage => Branch coverage

III. Statement coverage => Expression coverage

A. I B. II C. III D.I,II E. I,II,III

14. AVL trees are those with the left branch and right branch differing in

height by atmost 1. which of the following is NOT an AVL tree?

... ... ... ... ... (trivial)

15. in an AVL tree with 1000 nodes, path length is the length of a path

from root to a leaf node.

a) at least one path has path length >100.

b) all paths have path length >100.

c) no path has path length >100.

d) cannot be determined from the above info.

Page 4: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 4

16. If I want to implement an abstract data structure with an efficient

"find maximum" operation, which of the following am I LEAST LIKELY to

use ?

a) ordered array

b) binary tree

c) hash table

d) heap

e) ordered list

17. For an ambigous grammar, the compiler writer can either (approach 1)

use a non-ambigous version of the same grammar, or (approach 2) retain

the ambigous grammar, but resolve the ambiguity by introducing

precedence and associative of operators. Why would he sometimes prefer

approach 2 to approach 1?

I. an ambigous grammar can produce at most two derivations

II. ambiguous grammars being smaller, they result in shorter code

III. ambigous grammars reduce parsing time by avoiding chain reduction

18. Assuming P != NP, which of the following is/are true concerning

propositional formulae:

I. All satisfiable formulae are in P

II. All unsatisfiable formulae are in P

III. All satisfiable formulae are in NP

19. On a packet switched network, each packet contains a packet

identifier. Which of the following can be included in the packet

identifier to ensure that the packets do not get misplaced and are

received in the correct order:

a) the sender's identity can be included in the packet id

b) the receiver's identity can be included in the packet id

c) the packet numbers are unique and monotonic increasing

20. S -> A | B

A -> 0B1 | 0

B -> 1A0 | 0

Page 5: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 5

what's true about the language?

I. context-free

II. regular

III. infinite

21. previous grammar what's FALSE:

a) Two consequtive 0's never possible

b) Two consequtive 1's never possible

c) Odd length strings

d) Center 0

22. construct DFA for

((Number of 0's) + 2 * (Number of 1's)) mod 3 = 0

23. CPU time of a program is dependent on which of the following

I. Clock frequency

II. Number of clocks per instruction

III. Number of instructions in program

24. floating point:

(-1)^s * 2^(E-127) (1.M)

then which of these cannot be represented exactly in this system?

a) 100

b) 15.5

c) 0.25

d) 0.1

e) 1.0625

25. Consider functional program

{ n = 1

{ f(x) = x + n

{ n = 2

f(17) }}}

a) static scoping f(17) = 19

b) dynamic scoping f(17) = 19

others crap.

Page 6: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 6

26. static type checking vs dynamic type checking

I. code bigger for dynamic typing

II. static takes more compilation time, dynamic takes more run time

III. static type checking checks all expressions while dynamic checks

only those expressions that are evaluated.

27. (decent) f(var,def,use) triple is (variable, line number of assignment

to var, and line number where var is evaluated), so that

1. there's no assignment to var in between executions of def and use

2. use follows a def in execution order.

3. there's some evaluation order in which var is used in line "use"

following the other rules.

program

~~~~~~~

1 A := 0

2 while A > 0 do

3 A := A - 1

4 if A is odd do

5 A := A - 1

6 endif

7 enddo

which of the following is *not* a valid def-use triple ?

a) f(A,1,3)

b) f(A,3,3)

c) f(A,5,3)

d) f(A,3,4)

e) f(A,5,4)

28. Which is FALSE about separate compilation

a) code reuse is possible

b) length of edit-compile-run cycle is shortened

c) recompilation is easier

d) benefits are reduced if external procedures are made inline

e) global optimization easier for compiler

Page 7: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 7

29. suppose p and q are pointer variables and the system implements

reference counting, what actions are peformed after the assignment

p = q ?

30. (trivial) Max number of nodes in a k-ary tree of height h

31. Given (some) circuit, for what percentage is the output equal to some

intermediate output X ?

a) 25 %

b) 50 %

c) 100 %

32. 2 level cache. A main memory, 2 caches, 4 processors connected to each

cache. 1 level hit ratio is 0.95, 2nd level hit ratio is 0.025 and the

rest is 0.025.

some 2-3 questions based on this.

Page 8: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 8

------------------------------------------

AGRE01.TXT

------------------------------------------

1. With respect to compilers and interpreters, which of the following is true?

a. Syntax analysis is done in compilers but not in interpreters.

b. A program that can be compiled can be interpreted.

c. Interpreters are written in high level languages and compilers in either.

a and b

2. Given a block of RAM, with address and data lines and a chip select,

what is the use of chip select?

a. To connect chips for greater address space.

b. To get words of size > 8 bits.

c. To reduce power consumption.

3. Give regular expns. for strings with exactly 2 consecutive 1s.

4. What is the string implementation for the operation "Insert a character next

to the

one pointed by P".

a. Sequential locations with 1 char/word.

b. .........................> ..........

c. Singly linked list with 1char/wd.

d. .......................>.......

e. Doubly linked list ...........

c

5. If A>B 75% of the time and B>C 25% of the time, if a segment is executed

10000 times,

with A>B then .....

else B>C then ........

How many times is each section executed?

7500 : 625

6. While A do B in FORTRAN.

Equivalent is

a. 10 if A goto 20

B

goto 10

b. 10 if ~A goto 20

Page 9: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 9

B

goto 10

b

7. Computer takes 36 bit word. Character takes 8 bits.While storing strings,

characters are

packed ,into double words. If reqd, padded with blanks to the nearest word

boundary. How

many blanks are reqd for k char. string.?

ceil(2K/9)

8. Do 10 i = 1 to N

Do 20 j = 1 to N

20 a = b

do 30 k = 1 to N

30 b = c

10 cont.

How many assignments?

2N**2

9. ith powwer of A is to be calculated. A is real. i is integer. M is mult,.

time. L is log

time. E is exp time. What cond is to be satisfied if exp faster than mult.

L + E < M(i - 2)

10. Gaussian elimination technique n * N matrix. How many operations reqd?

2n**3/3

11. { a,a a,b b,a b,b c,c }

Reflexive? Symmetric? Antisymmetric? Assymmetric?

1,3,4

12. define join(x,y) : concat. head(x) and tail(x)

join(head(x),tail(x)) = x

13. WhAt is the recursive defn of X?

rev = join(rev(tail(x)),head(x))

14. S-> SS | a

a. left recursive

b. right recursive

c. ambiguous

1,2,3

15. Why process a 256 * 256 array compared to a 1024 * 1024 array?

Page 10: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 10

a. faster

b. higher resolution

c. more contrast

a

16. Given a game tree, find the first players move. Use minimax fundaes.

17. 4 tape drives. jobs demand the tape drives :

w : 1 x : 2 y : 3 z : 4

which gives deadlock

y , wy, xyz (shady question)

3

18. Some incomprehensible question on file indexing.

t1 : bus -> address master

t2 : bus -> data master

t3 : req <- on master

t4 : ack -> on slave

t5 : req -> off master

t6 : bus -> float master

t7 : ack -> off slave

Communication for master slave devices in unibus.

This is for write. Interchange two commands for read.

t2 and t3.

19. How many height balanced trees with 5 nodes?

------------------------------------------

AGRE02.TXT

------------------------------------------

#

Ratio of the number of characters needed to print number 'a'

wrt base 'b' and 'c'

x = log a and y =log a

b c

a) upperbound(x) / upperbound ( y)

b) integervalue( x/y)

c) lowerbound(x+1)/lowerbound(y)

ans == b

#

i = 1

Page 11: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 11

j = 1

read(x)

while ( i < 10)

do

begin

j = j * i;

i ++;

if ( i = x) then exit

end

what is the assertion upon competition

a) (( j = ( x -1)! ) and ( i > = x))

b) ((j = 9!) and ( i = 10))

c) (( j = 10!) and ( i = 10))

d) ((( j = 10! ) and ( i = 10)) and (( j = ( x-1)!)and ( i = x)))

e) ((( j = 10!) and ( i =10)) and (( j = ( x-1) ! ) and ( i = x)))

ans == d

#

Which scheduling is starvation free

a) FCFS

b) round robin

c) LRU

d) shortest job next

e) youngest job next

ans == round robin

#

For getting different shades of grey each pixel is associated

with a Grey scale of 0 to 7

To make contrast less abdrupt , it is decided to assert the following

Two adjacent pixels can have maximum grey scale difference of two

Out of 64 possible combinations of shades between two adjacent pixels how

many are allowed by the above assertion ?

a) 24

b) 32

c) 34

d) 40

e) 100

Page 12: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 12

ans == 34

#

------------------------------------------

AGRE03.TXT

------------------------------------------

/* K.G.VENKATASUBRAMANIAN */

KGBBEGIN

# A certain computer represents floating point numbers by means of a

signed magnitude mantissa with decimal point to the right of mantissa.

Mantissa is normalised. Exponent is excess 16 base 2.

-------------------------------

| | | | | | | | | | | | | | | | |

| | | | | | | | | | | | | | | | | .

-------------------------------

|\ exponent/\ mantissa / \_ decimal point

/

Sign bit

What is the ratio of the largest number to the smallest positive number

that can be represented in this format?

a) 2 * 10^8 b) 4 * 10^8 c) 10^8 d) 4 * 10^9

Ans. 2^15 * (2^10 - 1)

----------------- = 2^32 = 4 * 10^9

2^-16 * 2^9

# a---

NAND---

b--- | is equivalent to ?

NOR---f

c--- |

NOR----

d---

Ans.

a---

AND---

b--- |___

___ AND---f

c--- |

Page 13: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 13

OR____|

d---

(By simple application of deMorgan's law to the NOR gate at the 2nd

level).

# A certain compiler has a six-character identifier consisting of the 36

characters 'A'..'Z','0'..'9'. Extra spaces created by shorter length

identifiers are padded to the left with blanks, which is given the code

37. It is necessary to find a suitable hashing function that can map the

identifier names into an index for a symbol table with space for 1400

records, only 1000 of which are active at a given time. If the

identifier is represented as a1a2..a6 (ai represents character code of

the ith character in the identifier), which of the following is the best

hashing function?

i) a1 + a2 + a3 ii) a4 * a5 * a6 iii) a1 * 38 iv) a1 * a2

v) a4 + a5

Ans. iv

# In postfix polish notation, an ambiguous expression can be created if

unary operations ( ex - ) are permitted in addition to binary

operations. Which of the following is NOT ambiguous in PPN ?

Ans. e) ab*-c-

# Question on NP-completeness.

Ans.

If connected graph can be transformed into Hamiltonian cycles in

polynomial time, then if connected graph is NP complete, then

Hamiltonian cycles is NP-hard but not vice versa.

Ans. c)

(Be careful of alternative d) which states the converse.)

# Question on tree traversal:

1) visit root 2) traverse right subtree ( if it exists ).

3) visit root 4) traverse left subtree ( if it exists ).

A

/ \

/ \

D C

\ / \

Page 14: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 14

B E F

Note : Take care of the order of traversal ( right first, then left).

Ans : ACFFCEEADBBD

# The following program fragment was written in assembly language for a

single address computer with one accumulator register.

LOAD A

MULT A

STORE T1

LOAD B

ADD B

STORE T2

MULT T2

ADD T1

STORE Z

What does locn Z contain in terms of A and B?

a) A^2 + B^2 b) A^2 + 2B^2 c) A^2 + 4B^2.

Ans : c)

# Question on demand paging: 3-page memory, initially all page frames

empty. Reference vector = 122134.... What is the state of the page

table before the fifth page fault assuming LRU is used?

Ans: { 1,3,4 }

# Question on weakest precondition for a given postcondition

x := y + z;

y := x + z;

z := x + y;

Postcondition : (x = y) V (y = z)

Ans : (z = 0) V (Y = Z).

# Question of decision tree:

Input could be 10,20,30,40 with probabilities 0.3,0.2,0.1,0.4.

Which decision tree minimizes the average number of comparisions ?

Ans :

| input

____|____

| <= 35 |

|_______|

/ \

Page 15: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 15

y/ \n

/ \

(<= 15) (40)

/ \

y/ \n

/ \

(10) (<= 25)

/ \

y/ \n

/ \

(20) (30)

# Question on Tic-Tac-Toe game ( ie Strategy given ). Machine plays X

and starts. Human plays O.

a) Machine always wins.

b) Human can ensure draw, but not win.

c) Human can win by playing at loc. 1 at first possible opportunity.

d) ------------- ''---------------- 6 -------------''--------------

e) -------------------------------- 7 -----------------------------

Board : 1 2 3

4 5 6

7 8 9

Ans : c).

# All the following statements are true except :

i) Concurrent processes must work on different processors.

ii) If the result of two parallel processes is independent of their

speeds then it has a deterministic solution.

iii) A deadlock is a circular unit where two or more processors are

waiting for others to release the resources.

iv) ..

v) ..

Ans : i).

# A 10 letter code is hahsed by taking first two digits and adding to

3rd through 6th digit, resultant of which is added to the remaining 4

letters. Total number of addresses that can be hashed are :

i) 20978 ii) 20977 iii) 10973 iv) 200978.

Ans : iv).

Page 16: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 16

# Number of bits needed to address 10,000 words :

i) 7 ii) 10 iii) 11 iv) 14 v) 16.

Ans : iv).

# Number of comparisons necessary to find max and second max among 4

numbers is :

i) 2 ii) 3 iii) 4 iv) 5 v)

Ans : iii).

# Programs are written with subroutines because of the following reasons

except :

i) easy debugging ii) no repetition of code iii) increase the access

speed from buffer to main memory.

Ans : iii).

# What is the output for 011001110 ?

i) abbaabb00 ii) abbaabba.

---0/a---> () ---0/0----

| / \ | ___

| 0/a 1/b V / \

| \ / | / (0,1)/0

-->() (()) ()<------

| / \ |

| 0/a 1/b |

| \ / |

---1/b---> () ---1/0----^

# The config. shown below is used for multiplying two unsigned 4-bit

numbers. There are 3 four bit registers. When a clock pulse goes high,

contents of reg B are shifted right and a control signal is issued

depending on whether the number is zero or one and simultaneously reg A

is loaded. To start with contents of reg A,B,C should be

i) zero, multiplicand, multiplier.

ii) multiplier, zero, multiplicand

iii) zero, multiplier, multiplicand

________

| |

| |

| ADDER <----------AND ARRAY <--------- reg C

| ^ ^

Page 17: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 17

| | |

-----> reg A reg B

# Number of clock pulses necessary to multiply ( above figure ) :

i) 2 ii) 4 iii) 3 iv) 5 v) 6

# If proper circuitry is provided for the sign bit then

i) 1's complement can be performed.

ii) 1's complement multiplication can be performed.

iii) Sign Magnitude multiplication can be performed.

# If A = 0, B = 0, the different states of the ckt are :

i) (0,0) (1,0) (1,1) (0,1) (0,0)

ii)(0,0) (0,1) (1,0) (1,1)

----------------------------------------------

| _______ _______ |

-->|J Q|--A ---------|J Q|------------ B

| | \ / | |

-------|Ck | \/ ---|Ck |

| | | /\ | | |

| ->|K ~Q|---/ \----- | -|K ~Q|---

| | ------- | ------- |

| |_______________________|______________|

|_________________________|

# A 2,3 tree is a tree in which each node has either 2 or 3 sons, except

the leaves and also has equal path length from root to any leaf. The

number of leaves is 9. Then the number of interval nodes can be :

a) 7 b) 8 c) 9 d) 6 e) 3.

Ans : a)

# A recurrence relation defining a function, T(n) is given by

T( n ) = 2 * T ( n/2 ) + n if n > 1 and

1 if n = 1.

Then the solution for T(n) is

a) n^2 b) n.log(n) - n + 2 c) n. log(n) + n d) n + 1 e) n + 3.

# In a linked list with value/next - "Insert p after q" is done by

i) Next(p) <- Next(q)

Next(q) <- p

ii) Next(q) <- Next(p)

Next(p) <- q

Page 18: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 18

# a = x;

b = y;

p = 0;

while ( a > 0 ) do

begin

p = p + b;

a = a - 1;

end

What is the loop invariant ?

i) p > 0

ii) xy = p + a * b

iii) xy = a - p/b

iv) xy = ab - p/b

Ans : ii).

#

S -> aAa | BDB

A -> aS | c

B -> b | bD

D -> S

What is the minimum length string with full of terminals possible?

i) 1 ii) 2 iii) 4 iv) 3

Ans : iv).

# What is true about the language generated ?

a) Start end symbols are the same

b) Only odd length derivation are possible

c) Consists of at most one 'c' in any terminal string

Ans : c).

# Which of the following consists of languages finite automata accept ?

i) 0^n 1^n , n>= 1

ii) a^n b^m , m<n

iii) balanced parantheses

iv) a string of zeros and ones and in the prefix the diff between number

of ones and of zeros is '1'

v)equal no. of zeroes.

KGBEND

------------------------------------------

Page 19: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 19

AGRE04.TXT

------------------------------------------

/* Manish Dopey Khettry */

DOPEYBEGIN

1.

cost(i) is defined as the minimum number of addition of pairs of no's whose

cost is already known to obtain i.We start with the number 1.

e.g cost(1) = 0;

cost(3) = 2;

cost(6) = 3;

since 6 = 3 + 3;

3 = 2 + 1;

2 = 1 + 1;

find cost(11) = 4 / 5 / 6 / 7 / 8 (5)

2.

S -> abA

A -> Sb

A -> a

B -> b

aA -> bB

Which of the following are true ?

a. ababa can be generated by the grammar

b. The language generated by the language is infinite

c. There exists a CFG for it

3.

i = 0 to inf summ A(i) * x**i where A(i) fibonacci numbers

a. 1 / ( 1 -x )

b. 1 / ( 1 -x**2)

c. 1 / ( 1 - x - x**2)

d. 1 / ( 1 + x - x**2)

4.

S -> AS | SB

A -> a

B -> bB | aB

Page 20: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 20

Which of the following are useful ?

choices not given !!

5.

proc wander(t:binarytree)

begin

if ( t is not a leaf )

begin

if (leftson(t) != null) then wander(leftson(t))

print(value(t));

if (rightson(t)!=null) then wander(rightson(t))

print(value(t));

end

end

c

/ \

a d

/ \ /

g e b

/

f

output ? a. ggaffeeacbbddc

b. aeeacddc

max number of print statements for an N node binary tree

choices lower ( log n) , N ,N / 2 , 2N - 2

6.

procedure pal (s:array of char)

int i,j; { n size of array }

begin

pal = false ; i = 1; j = n;

while (--) do

begin i = i + 1; j = j - 1; end

if ( i >= j ) pal = true;

end

what should be placed in (--) ?

Page 21: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 21

a. (s(i) = s(j)) and i < j

b. (s(i) = s(j)) and i >= j

assume n is even and that 0.5 of the times the input to pal is not(?) a

palindrome & in other cases it is equally likely that the loop is terminated

anywhere i.e a[1],a[n] or a[2],a[n-1] pair.What is the average no of times

the loop is executed ?

n , n/2 , (3n/8 - 0.25),(3n/8 + 0.25)

7.

Which of the following parameter lists produce different results

for call by name and call by reference

begin

a:array (1..100) of integer;

r , s ,t integer;

procedure f(x:integer , y:integer);

t:integer;

begin

t = x;x=y;y=t;

end

begin

for t = 1 to 10 do

a(t) = 2*t;

r = 4;s = 6;t = 8;

f(* , *)

choices r,s / s,r / s,t / r , a(r) / a(r) , r

8. a

For a seven segment display _

b| |f

g

c| |e

-

d

for displaying 0 to 9 with bcd input wxyz with w as msb what

is the function for d ?

9.

Page 22: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 22

For an algol like language with block structure and stack discipline(?)

for local variables how many words of storage are reqd if one word is

allocated for integers and reals ?

begin

x,y : integer

i,j : real

i = 2 ; x = 20;

for x = 1 to 10 do

begin

j : real;

j=i;

end

for y = 1 to 4 do

begin

y:integer;

y=x;

end

end

choices 4 / 5 / 18 / 14 / 8

10.

m = memory cycle time

t = instr execution time with one memory access

t > 2m

what follows is rather incomprehensible .

For DMA the controller requests for the memory but if the CPU is

using it , it gets control after CPU and will not delay the CPU

for the next instruction . If the CPU is using the bus , the DMA will

get control of the bus and then if the CPU requests for the bus ,

CPU will have to wait.What is the average waiting time for the CPU per

instruction ?

2*m / t**2 , m**2 / 2*t , t / 2*m

11.Hardware multiplication of two n bit numbers a and b is

Page 23: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 23

implemented by the eqn

p(i + 1) = ( p(i) + 2**n * a * b(i) ) / 2

b(i) is the ith bit of the multiplier

b(0) is the lsb

p(0) , p(1) .. p(i) are the partial products p(n) is the final prod

In the hardware implementation first an addition is performed followed

by a shift operation from the left to the right.The leftmost bit is

assigned to

0 / 1 / From the carry bit out of the highest order position.

12.

A relation is a table with coloumn headers x -> y is defines a

set of attributes under the coloumn heading in x are the same then

the attributes will be the same in the coloumnh eadings in y.

relation:course teacher student room hour

course -> teacher

(student , hour )-> room

(course , hour ) -> room

(room , hour ) -> course

Which of the following are not necessarily true ?

(student , room) -> teacher

(room , hour ) -> teacher

(student , hour ) -> course

13.

Given a set of equations AX = B (n * n) matrix A .The following program

solves for X if

program SOLVE

begin

Page 24: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 24

x (n) = b(n) / a(nn);

for i = n - 1 to 1 do

x(i) = ( b(i) - x(i + 1)) / a(ii)

end.

1. Upper triangular matrix

2. Lower triangular matrix

3. Main diagonal is non zero and the diagonal above it is all ones

4. Main diagonal is non zero and the diagonal below it is all ones

14.

For the following program fragment

{ z:=z*a ; y:=y-1 }

which of the following assertion is true ?

a**b = z*(a**y)

a*b = z + a*y

15.

A computer has three types of instructions

a. Instr fetch , defer for indirect addressing , execute

b. Instr fetch , execute

c. Instr fetch , fetch / execute immediately

States 1. fetch / execute

2. defer

3. execute

Connectivity matrix of the states of the computer

1 0 1 1 1 1 1 1 1

0 0 1 0 0 1 1 0 1

1 0 0 1 0 0 0 0 1

16.

Let A be the time taken for a memory cycle . Let m be the average no

of cycles an instr takes and let I be the time for execution / fetch

including memory access times.A DMA is also to be performed evety t secs

Page 25: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 25

and each DMA takes 1 memory cycle. The necessary condition for the CPU

to go unaffected by the DMA is

1. (I <= m * A) && (t<=I)

2. t < (m + 1)*A

17.

A,B,C,D are railway wagons on tracks.The straight numbered tracks can

hold 4 wagons each , but the dotted or curved wagons cannot hold

any wagon.A move is defined as the movement of wagon from a numbered

section to another without crossing over or by passing another wagon.Find

the minimum number of moves required to reverse the wagons in section 4.

\ /

\ 1 /2

\ /

\ /

.......

. .

. .

.

|

|3

|

. .

. .

. .

.........

/ \

4/ \5

/ \

/ \

18. C----

D---- and ------ |

B---- |

Page 26: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 26

|--

A-----|-------- | A---- O___

B-----| nand |-D D---- and ---------- R

C-----| | C---- ___

----------- |

A---- |

D---- and ------|

B----

What is the boolean function implemented by the above ckt ?

19.

G------- Q -- X Q -- Y

GATE -------- D ff F -- D ff

H------- - - - -

Q -- X Q -- Y

What should F, G, H be in terms of X and Y ?

What should gate be ?

!!

20.

A ring counter is implemented using D ffs.

Initially Q(a) , Q(b) , Q(c) are zero .

What is the state after 8 clk pulses ?

______________________________________________________________________

| |

| ________ ________ _________ |

| | |Q(a) | |Q(b) | |Q(c) |

------ |D |----------------|D |---------|D |------- not---

| | | | | |

| | | | | |

| | | | | |

-------- -------- ---------

------------ clk------------------- clk--------------- clk

Ans: 110

21.

Page 27: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 27

Which is true of the cost of replacement policy ?

a. c(LRU) < c(FIFO)

b. .. > ..

c. .. = ..

d. Cannot be answered

22.

A system has three page frames in the main memory and uses LRU replacement

policy.What is the stage of the MM after the 5th page fault if the

reference sequence is

1 2 2 3 4 1 3 1 2 1 ?

Ans 143

23.

z <- 1

p <- x

q <- y

while y > 0 do

if (odd (y)) z <-z*x

y <- y div 2

x <- x*x

if y = 13 at the start of the execution what are the values taken by z

Ans:1 , p , p^5 , p^13 ..

24.

A and B are two symmetric n * n matrices.

do j = 1 to n

do k = j to n

d = 0;

do l = 1 to n

d = d + A(j,l)*B(l,k) statement x

end

C(j,k) or C(k,j) = d

What does the program do ?

Ans:Multiplies two matrices and stores the result in an upper triangular

matrix .

How many times is the statement x executed ?

Ans: n^2 * (n + 1) / 2

Page 28: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 28

25.

A processor contains the following

2 8-bit adders

2 multipliers

1 accumulator

How best can you describe the processor ?

Choices:

Multiprocessor / array processor /* multifunction processor */ content

addressable processor

26.

|a(11) a(12) a(13) .. a(1n)| |x(1)| |b(1)|

| 0 a(22) a(23) .. a(2n)| |x(2)| |b(2)|

| 0 0 a(33) .. a(3n)| * | | = | |

| . | | | | |

| . | | | | |

| 0 0 0 0 a(nn)| |x(n)| |b(n)|

What is the necessary condition for this set of equations to have a

unique solution ?

Ans: pi (i = 1 to n) a(ii) != 0

DOPEYEND

------------------------------------------

AGRE05.TXT

------------------------------------------

/* Narasimhan */

SNOOPYBEGIN

10. Define stack as follows.

i. e ---> is a stack

ii. push(s,x) ---> is a stack

iii. pop(push(s,x),y) = s

iv. top(push(s,x)) = x

Which of the following cannot be defined using the stack

defined above.

Page 29: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 29

ans : (E) pop(pop(push(e,x),y),y) = x

11. Un-Understandable.

Open problem !!!!

12. The following program uses binary search to find if z is in a[1:n]

arranged in increasing order.

f := 1 , l := n

while f <= l do

begin

* -------> m := (f+l) / 2

if (z = a[m]) then write(found)

else if z > a[m] then

f := m + 1;

else l:= m - 1 ;

end.

The avg. search time is

ans : O(lg n)

13. If the statement * in (12) is replaced by some arbitary stmt.

which gives out a vague answer, which of the following

will be least likely to detect error.

a) n odd

b) f = [ lower-ceiling (n) ] /* lower-ceiling(1.8) = 1 etc */

c) n = 0;

ans : c

14. In (12) if f <= l is replaced by f < l which of the following is

true ?

ans. The solution is affected if z is in a[1..n] sometimes.

15. y := b

Page 30: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 30

z := 1

while (y > 0) {

z := z * a

y := y-1

}

What is the loop invariant ?

ans : power(a,b) = z * power(a, b-y) /* power(2,3) = 8 etc */

Therefore power(a,b) = z * power(a,y)

16. If (2*a) > b then b := b + 1

What is the 'wp' to ensure that a < b holds before & after the

assignment.

a) ( (a>b+1) AND (a>=0) ) OR ( (a>b) AND (a<=0) )

b) ( (a>b+1) AND (a>=0) ) OR ( (a>b) AND (a<0) )

c) (a>b+1)

d) (2a>b) AND (a>1)

e) ((a>0) AND (a>b+1)) OR ( (a>b) AND (2a<=b) ) OR (a>b+1)

17. procedure p(m:integer);

begin

p := 1 ;

if (m=1) then p = z ;

else

for i:= 1 to m-1 do

if m mod i = 0 then

p := p * p(i)

end

Find the value of p(6)

ans : Z ** 3

18. L1 : begin

integer a,b ; -------> (1)

integer c,d ;

Page 31: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 31

.

.

.

L2 : begin

integer a,c ;

integer g,t ;

end

end

If L1 - L2 (scope) - describes a variable in L1 & not in L2 then

which of the following describes variables a & b in (1) best

a) L1 -L2 ,L1

19. procedure p(m,n)

begin

m := m-n;

n := n-1;

m := n-m;

end

begin

i := 2;

j := 3;

p(i,j);

end.

Find the values of i and j after execution

ans : 3,2

/* These questions were brought to you by

Snoopy inc. */

SNOOPYEND

Page 32: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 32

------------------------------------------

AGRE06.TXT

------------------------------------------

/* C. Sridhar */

BBEGIN

21) p(n) = a(0)+a(1)x+....+a(n)x^n , what is true about the above

polynomial

i) it has n real roots .

ii) whereever there is a complex root , it always has a conjugate .

iii) it can be expressed as a product of n consecutive factors in the

complex field .

A)I B)II C)I && II D)II && III E)III

(ANS - D)

22) begin

i,j :integer ; A(i):array ;

procedure p(x,y)

begin

y = y + 2 (?);

x = x + y;

end;

for i = 1 to n do A(i) = i;

j = 2 ;

L1 : p(A(j),j);

->L2:

at L2 A(1) = 1 ; A(2) = 2 ; A(3) = 3; A(4) = 6 ; A(5) = 5 ; A(6) = 6;

Then the procedure call should be

i) x call by value , y call by ref.

ii)x call by ref,y call by value .

iii)x call by ref , y call by result .

iv)............

{ANS - y - call by value;x - call by reference}

23) 5 professors & 5 courses . Which one of the following is true .Each

prof can not take more than one course .

A - CS1, CS4

B - CS 1,2,3,4

Page 33: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 33

C - CS 1,2,3

D - CS 1,5

E - CS 1 , 4

{Courses that each prof can teach}

i)prof D has to teach CS 1.

ii)prof D has to teach CS4 .

iii)either prof A or E has to teach course CS1 .

iv)..........

v)Prof D has to teach CS5 .

24) A binary tree is stored as

i) H ii) H

/ \ / \

B G B G

/ \ /\ \ / \

A C D E C D E

/ / /

F F A

17) There are 2 resources R1 and R2 and two processors P1 and P2 . A

directed graph

Pi->Ri means "Pi requests Ri"

Ri->Pi means "Ri is allotted to Pi" . Then which of the following

diagrams represents a possible deadlock .

I)

______

_______/______| P1 |_____\______

| \ |____| / |

__|___ __|___

|R1 | | R2 |

|____| |____|

| |

| |

| ______ |

|______\______| P2 |_____/______|

/ |____| \

II)

______

Page 34: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 34

_______/______| P1 |_____\______

| \ |____| / |

__|___ __|___

|R1 | | R2 |

|____| |____|

| |

| |

| ______ |

|______\______| P2 |_____/______|

/ |____| \

III)

______

_______/______| P1 |_____\______

| \ |____| / |

__|___ __|___

|R1 | | R2 |

|____| |____|

| |

| |

| ______ |

|______\______| P2 |_____/______|

/ |____| \

IV)

_____ _____

| |___\_______| |

| P1| / |R1 |

|___|____/______|___|

_____ _____

| |___\_______| |

| P2| / |R2 |

|___|____/______|___|

\

V) none of the above .

Page 35: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 35

18) Given a tabular representation of a function f ;

x -2 0 2 4

f(x) 3 5 6 12

find f(2.4) using linear interpolation between successive points.

10) In a memory scheme , the address of a location is specified by a page

address and a displacement within the page in hexa decimal .

no: of pages = 16 . No: of words in each page = 256 . The address of

11th page , 94th word is

A)B5E B)A5E C)5EB D)E9C E)5EA

11) Procedure zap(n)

begin

if n <= 1 then zap = 1

else zap = zap(n-1)+zap(n-3)

end

find zap(6)

12) define f(x) as

f(x) = if odd(x) then ((x-1)/2)

else f(f(x-1)) . Find f(16)

13) bubble sort . the number of operations needed is

A)2N B)N(N-1)/2 C)N(N+1)/2 D)N^2 E)N-1

14) A Chomsky normal form of a CFG is one with productions of the form

S->AB,S->a .Then the no: of productions needed to produce a

terminal

string of length n is

A)N+1 B)N C)2N D)2N-1 E)N^2

15) The above computer is used for multiplying two unsigned 4 bit numbers.

There are four bit registrers when. When a clk pabc goes high, contents

of reg B

are shifted right and a control signal is isssued depending on whether

the number is zero or one and simultaneously loaded.

To start with contents of reg A,B,C should be

(a) zero,multiplicand, multiplier

(b) multiplier, zero ,multiplicand

(c) zero, multiplier,multiplicand

16) No of clock pabc's necessary to multiply

Page 36: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 36

(a) 2 (b) 4 (c) 3 (d) 5 (e) 6

17) If proper circuitry is provided for the sigh bit then

(a) 1's complement can be performed

(b) " " mul.. " " "

(c) Sign mag " " " "

18) If A = 0 and B = 0, diff states the ckt goes through are

_______________________________________________

| |

| ___________ ____________ |

| | | | | |

---->|J Q|---A ------>|J Q|---------B

| | \ / | |

| | \ / | |

| | \ | |

| _ | / \ | _ |

---->|K Q |--/ \------>|K Q |-----|

| |_________| |__________| |

| |

|______________________________________________|

(there are clock inputs to both the FFs)

(a) (0,0) (1,0) (1,1) (0,1) (0,0)

(b) (0,0) (0,1) (1,0) (1,1)

(c)....

15) A 2-3 tree is a tree in which each node has either 2 or 3 sons,

except the leaves and also has equal path length from root to

any leaf. The no of leaves is 9. Then the no of internal nodes

can be

(a) 7 (b) 8 (c) 9 (d) 6 (e) 3

16) A recurrence relation defining a fn, T(n) is given by

T(n) = 2*T(n/2) + n if n > 1

= 1 if n = 1

T(n) is

(a) n**2 (b) nlogn-n+2 (c) nlogn+n (d) n+1 (e) n+3

Q10 contd

What is the sequence fo the counter when clocked

continuoulsy

Page 37: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 37

(a) 10,11,..15,10,11....

(b) 5,6,7,8,5....

(c) 5,6,7,8,9,5.....

(d) 10,11,10,...

(e) none of the above

(11) Decision tree problem with nos 10,20,30,40 having probabilities

0.3,0.2,0.1,0.4 (order ?) (complete the question)

(12) Digital analysis

(13) First fit allocation policy (2 questions)

(14) Connected graph - Hamiltonian circuit

(15) E

/|\

/ | \

/ | \

/ + \

E E

| /|\

a / | \

/ | \

E - E

/|\ |

/ | \ d

/ | \

E + E

| |

b c

Which derivation corresponds to the above tree ?

16)

(A)

/ \

/ \

/ \

(B) (C)

\ / \

\ / \

(F)(D) (E)

Page 38: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 38

A traversal is described as follows

(i) visit the root

(ii) traverse right sub tree if it exists

(iii) visit the root again

(iv) traverse left subtree if it exists.

What is the order of traversal of the above tree ?

17)

1 bit -sign

5 bits-excess 16 exponent (base 2)

10 bits - mantissa

Binary decimal point after the last bit.

What is the ratio of the largest number to the smallest +ve

number represented ?

18) N computers each having unique language and representation. How many

translators reqd to translate from any computer to any other computer.

(Ans - 2*N ?)

19) Queue with permitted operations

(i) insertion at tail of queue

(ii)output the head of queue

(iii)place the head at the tail

For an input string of 1 2 3 4 5 6 which of the following outputs

are possible

(i) 3 4 1 2 6 5 (ii) 5 2 1 3 4 6 (iii) 5 6 1 2 3 4

(a) I only (b) II only (c) III only (d) I & III (e)** I,II & III

20) Propositional calculus

21) Representation of integers

dn,dn-1,....d0

where di = A mod ri where ri is a prime no. radix

r0 = 2, r1 = 3, r2 = 5. what are the representations for 65,14 (110,..)

22) Expert system for TIC-TAC-TOE

23) Multiplication using shift register.

24) Which are not accepted by an PSA (?????)

(i) 0**n 1 1**n (ii) 0**n 1**m (iii) 0**n a 0**m,(n=13,m is a

multiple of n)

25) Which are true

Page 39: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 39

(i) All langages accepted are recursive

(ii) recursive languages accepted by TM

(iii) all NP languages are recursive

26) Into function from set A (# A = n) to set B (# B = n), how many fns

possible? n**n

27) Consider

Procedure(k,l)

k = k - l;

l = l - 1;

k = l - k;

end

i = 2, j = 3;

call(i,j)

What are values of i & j after execution of call by reference

#) What is the language accepted

1)0^*+1 2)(0+1) 3)(01+10)(ans) 4)(01+10)(01+10)^*

(Question is incomplete)

#) temp := A(N);

DO I = 1 TO N -1

K := _____;

A(K+1) := A(K);

END ;

A(I) = TEMP;

Program code is supposed to shift the array vector A right by one

element . Fill in the blank

1) N-I-1 2)I-1 3)N-1(ans) 4)N-I

#) If in the above code K := ____ is replaced by A(I+1) := A(I) and

A(K+1) := A(K) is replaced by A(I+1) := A(I) , then modified code does

the above fn provided

1)A(i) = 0 for i = 1,.,n

2)A(i) = 0 for i = 1,..,n-1

3)A(1) is not necessarily zero but A(i) = 0 for i = 2,..n

4)A(i) = c for i = 1,..,n-1 , where c is some constant

#) What is true about floating point numbers

Page 40: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 40

1)f(x+(y+z)) = f((x+y)+z)

2)If f(x+(y+z))has an error , it always has a small relative error

3)f(x(y.z)) always has some small relative error

i)1 ii)2 iii)1 && 2 iv)1,2,3 v)3(ans)

#) In pocket calculators excess 3 is used instead of BCD because

i)excess 3 counters are easy to make

ii)excess 3 is a self compt(?computing ,correcting) code(ans)

iii)a division by zero can never occur

#) An array is defined as A[1:8,-2:2,3:12]

A[1-2,3] is at location 2000 . Where will A[5,0,5] be ?

How many locations are there ?

#) A disk has the following properties . Tracks - 35 ; sectors - 10

Bit transfer rate 2,50,000 bits /sec

Speed of rotation - 300 rev/min

Find the storage in bytes .

#) Interrupt is used for a request for a byte from the above disk .

If interrupt overhead = 10 microseconds ,byte transfer time = 8

microseconds . How much time is available during byte transfer for other work?

#) r-->rev/min of disk;

s-->#of sectors;

k-->#of bits /sector;

b-->bit rate /second;

what inequality holds to have a gap between sectors?

A) 60*b < r*s*k

#) Grammar G: S-->Aa|bB|Sa

A-->b|a

B-->Aa

Which of the following is true

A)string aaaa proves G is ambiguous

B)string baaa proves that G is ambiguous

C)string abab proves that G is ambiguous

D)ambigous but not detectable from above given procedure

E)not ambiguous

#) There are 5 stations A,B,C,D,E. The stations are connected in

the following way .

station connected to

Page 41: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 41

------- ------------

A B,C,E

B A

C A,E

D E

E A,C,D

A routing problem is to find a route from one station to

another by visiting stations at most once . How many routes are possible

from E to B

i)1 ii)2(ans) iii)3 iv)5 v)6

#) A cpu and display share a common memory . The display needs 60

bytes every 50 microseconds . The memory can access 4 bytes per second .

What is the maximum cpu access to the memory

a)3.175 x 10 ^6 bytes /sec b)2.8 x 10^6 bytes /sec(ans)

#) A-->F|sF

F-->T|FmT

T-->P|TaP

P-->x|bAb

What are the terminals in this grammar

a)F,....

b){s,m,a,x,b} (answer)

c){s,m,b,^}

#) Which of the following cannot be generated by the grammar given above.

a)xmx b)xmxax c)xmxbsb(ans)

1 0 1 0

#) D0 D1 D2 D3

__|____|___|__|__

| |

| |

______|\ |-----------|

|/ | |

|_______________| |

| | | | |

Q0| Q1 Q3 |Q4 |

| |__________|--|---|

|_____________________|nand |

Page 42: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 42

|______|

This is a clocked counter with outputs Q0,Q1,Q2,Q3 where Q0 is

the LSB . The counter increments at every clock when load = 1 , buy when

load = 0 , the parallel inputs are set

#) A 32 bit register is used to keep information of the storage

density in a disk . A 1 in any bit signifies that the particular sector

is full, a zero denotes an empty . A register shows DF4E2003 (in hex) .

What percentage of the disk is full

ans. 44% (approx)

#) A ring counter is shown

_______________________________________________________o/|______

| \| |

| _________ _________ _________ |

| | | | | | | |

|_____|D Q|_______|D Q|_______|D Q|________________|

| | | | | |

| ~Q| | ~Q| | ~Q|

|_______| |_______| |_______|

The number of states of the counter are

a)four b)five c)three(ans) d)two or six e)three or five

#) Which one of the job scheduling policies are starvation true

i)round robin (ans) ii)shortest job iii)lcfs iv)fcfs

#)

_________

0/0 | | 0/0

____/_________| |_____/___

| \ |_______| \ |

| |

__|______ ________ __|______

start | | 0/0 | | 0/0 | |

_______\| |____\__| |____\__| |

/|_______| / |_______| / |_______|

| | | |

| 0/0/|\ \|/ 1/0 |

Page 43: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 43

| __|___|__ |

| | | |

|____\________||_______/_|

/ |_______| \

1/1 1/0

i)For a 15 string input find the number of ones generated (max)

as output (ans 3)

ii)What is the output when 100110 is the input ?

BEND

------------------------------------------

AGRE07.TXT

------------------------------------------

/* R. RAMACHANDRAN */

CHAKABEGIN

(d) (e)

#13)---- -------

\ /

\/

|| (c)

/\

/ \

DCBA-- -------

(a) (b)

4 wagons on a rail track (namely A B C D).

A move consists of moving any one wagon along the track without changing

the direction from one straight section to another.

a,b,c,d,e are the straight sections.

no vehicle can stop on any curved section.

What is the min no of moves to invert the order of the 4 wagons?

choices: 7 8 9 10 11

(ans) 9

#14)

Mult. of 2 n-bit unsigned nos be done by a H/W multiplier , implementing the

recurrence

P(i+1) = p(i) + (2**n) d m(i) ,i = 0,1,2,...n-1

d = multiplicand

Page 44: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 44

m(n-1),m(n-2)...,m(0) = multiplier

by an add and shift mechanism . The addition is conditional - depends on m(i).

The shift is to the right . What must be the bit shifting in ?

(a) 1 (b) 0 (c) shift out of right end .

(d) carry generated upon addition etc.

(ans) (?)

#15)cheap one.

Seven segment display .What is the boolean expr for corresponding to 'f'.

#16)

Add 2's complement no's

A(0) A(1) ... A(N-1)

B(0) B(1) ... B(N-1)

--------------------

S(0) S(1) ... S(N-1)

when can we say overflow has occurred?

(a) A(0)B(0)~S(0)+ ~A(0)~B(0)S(0)

(b) ~A(0)B(0)~S(0) + A(0)~B(0)~S(0) + A(0)B(0)

(ans) check and find out!!

#17)

Addn of unsigned X and 1's complement Y result is

(a) x-y-1 always

(b) x-y always

(c) x-y unless x < y and we discard end-around carry.

(d) x-y-1 when x > y and we discard end-around carry.

(e) none

(ans) (d)

#18)

How many diff. strings of length 3 are possible from a,a,b,b,c ?

(ans) ?

#19)

S -> SB | AB

A -> a

B -> bB

which are the useful symbols?

(ans) none.

#20)

Page 45: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 45

S -> abA

A -> SB

A -> a

A -> b

B -> b

Consider the following statements

(a) ababa is a string of this lang.

(b) Lang is infinite

(c) Lang is eq. to CFL.

ans) ???

#21) encoding used

P(a) ~ 2 a 00

P(e) ~ 2e 01

P(i) ~ 3i 10

p(o) ~ 1o 010

p(u) ~ 2u 011

find avg no of bits per vowel ?

(ans) 2.3

#22)

Given 4 nos 10,20,30,40 and given that n can take on one of theses four values

only , one can determine n in various ways .

eg:-

< 35 ?

|

yes no

<15 40

|

yes no

10 < 25

|

yes no

20 30

etc.

Given prob that

x = 10 is 0.1

x = 20 is 0.3

Page 46: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 46

x = 30 is 0.2

x = 40 is 0.4

Det. the optimal search tree .

(ans) Huffman coding fundas .

#23)

In a chomsky NF grammar , how many steps are used to derive a string of length

'n'?

(ans) 2n-1

#24)

Regular exp (0+1)*111*

what is the min no of states of a finite Automata to accept this r.e

(ans) 3

#25)

1/0

________________________________

|| ||

|| ||

\/ 0/0 1/0 ||

start>> (x)---------->(x)---------->((X))

|| /\ || ||

|| || || ||

|| || || ||

|| 1/0 || ||0/0 ||

|| 1/1 || \/ 0/1 ||

------------>( x )<--------------

| |

| |

|>>>|

0/0

|w| = 15.what is the max no. of 1's thata can be output ?

(ans) 5.

#26)

If the input to the m/c is 000110, what is the o/p ?

(ans) 000001.

#27)

Page 47: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 47

MEMORY ACCESS TIME = A

INSTRUCTION TIME = I

DMA ACCESS INTERVAL = C { 1 ACCESS EVERY C secs}

NO OF ACCESSES PER INSTRN = H

what are the conditions which must be true if the DMA doesnot slow

down the CPU.

(ans) C >= I and (H+1)A <= I

#28)

Instrn time = t

mem cycle time = m

Every instrn fetches and executes an instrn ( indirect access)

There exists a DMA channel that accesses the memory at random intervals .

What is the avg processor delay / cycle.

ans) m**2/2t

#29)

x is the root of a tree

wander(x)

= if x is not a leaf then

begin

if x has a left son then

wander(leftson(x))

print(x);

if x has a right son then

wander(rightson(x))

print(x)

end

Consider the tree

C

/ \

A E

\ / \

B D G

/

F

what does wander(c) print ?

Page 48: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 48

(ans) AACEGGEC

#30)

If no of nodes = n , what is the max length of o/p of wander ?

(ans) 2*(n-1) { because degenerate tree has only one leaf }

#31)

Axiomatic defn of a stack was given . Which of a no. of complicated

eqns.. is invalid ?

Nature of expr

top(push (pop(push(E,X)),a)) = a is true.

pop(pop(push(E,X)) = X is false.

#32)

When is the pass-by-name and pass-by-reference different .

The swap procedure was given and the ans for which there exits

a diff.. was to be chosen ???

begin

r,s,t:int;

A[1..10]:array of int;

proc swap(a,b:int)

t:=a;

a:=b;

b:=t;

end {swap}

for t = 1to 10 do

A(t) := |t/2| + 1

swap(...,...);

end.

ans) swap(r,A(r));

#33)

When do you use a fast optimising compiler rather than aa slow

optimising compiler .

(ans) In a debug environment .

#34)

Pages range from 1 to 16.

Addresses within a page range from 1 to 256.

Page 11. Addr within page = 94.

what is the virtual address in here ?

Page 49: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 49

(ans) B5E

#35)

121 TO BASE 4 + 84 TO BASE 16 = ?

ANS) 2131 TO BASE 4.

#36)

A mod-3 counter is to be built .

Y X

0 0

0 1

1 0

________ ________

G-------| | | x |----

|gate |-------|D |

H-------| | | ~x|----

--------- ---------

_________

F-------| |---y

| D |

| |---~y

--------

choice if F,G,H = ?, gate = ?

ANS)

F=X,G=X,H=Y; GATE = NOR ??? (some such answer)!!

#37)

<<_____________________________________________________

| <<_________________________________ |

| | <<_____________ | |

| | | | | |

________ ________ ________ ________________

| d1 | | d2 | | d3 | | d3 d2 d1 |

| | | | | | |comb. ckt |

| y1 | | y2 | | y3 | | y3 y2 y1 |

--------- --------- --------- -----------------

| | | | | |

| | _____________>> | |

| _________________________________>> |

Page 50: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 50

_____________________________________________________>>

Y1Y2Y3 = 000-->100-->010-->001-|

^ |

<---

Find the combinatorial ckt ?

(ans)

d1 = ~y1~y2~y3

d2 = y1

d3 = y2+y3

#38)

Read Addition of floating pt nos.

which of the following is correct ?

(a)Answer is rounded version of true sum.

(b) Total no. of distinct floating pt. nos in any computer is

finite.

(ans) b.

#39)

Given that

(student,room) chosen => tecaher detains.

(teacher,room) => course.

course => teacher

etc.

Does some X => Y etc.

#40)

Two processes concurrently execute the following program .

begin

X:=Y

X:=X+1

end

Initially X=Y=0;

both use same same data.

What could X be after both are finished.

(ans) {1,2}

CHAKAEND

Page 51: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 51

------------------------------------------

AGRE08.TXT

------------------------------------------

/* C. LAXMINARAYANAN */

LBABABEGIN

# Given a machine with only a stack whose top can be outputted and on which

PUSH and POP are allowed,which of the following strings can be sorted in

ascending order.

a)4312

b)3421

c)2134

d)1243

e)3142

# Define vector v[a:b] each element occupies two words.If address of v[a] is

denoted by @v[a],what is the address of v[i](first word of v[i])

a) (@v[a] - 2a) - 2*gamma*i

b) (@v[a] - 1) -i

c) @v[a] + 2(i - a)

# An array[1:8;-2:2;1:5] with 1 word elements requires how many locations for

storage?

# If A[1,-2,3] is in location (2000)10 where is A[3,0,5]

# What is the minimum hardware required for a parity bit generator where the

bits come in serial order ?

a) EXOR gates : 1 for each pair of bits

b) 4 EXOR gates

c) AND gates

d) TOGGLE FLIPFLOP acting as a mod 2 counter

# The figure shows a total ring counter implemented by D FFs. If the initial

state is (QA QB QC) = (1 0 0 )what is the state after 8 clock pulses?

____________________________________________

| ___ ____ ____ |

|___|D |A___|D |B__|D |C_______inverter___|

|CL | |CL | |CL |

----- ---- ---

All CL s denote the clocks and are connected together.

Page 52: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 52

# What is true about C the cost of a replacement policy ( which is given as

the number of page faults for a reference string )

a) C(LRU) always < C(FIFO)

b) C(LRU) always > C(FIFO)

c) C(LRU) always = C(FIFO)

D) CAN'T BE ANSWERED

ANS : D

# A system has 3 page frames and uses the LRU replacement policy.With

the following reference string what is the state of the main memory (the

pages existing )after the 5th page fault.

1223413121

ANS 213

# a & b are two numbers such that a>>b. ab, a+b, a-b are given.Which is

the best way of calculating a, b.

a) 1/2[(a+b)+(a-b)] and 1/2[(a+b)-(a-b)]

b) 1/2[(a+b)+(a-b)] and ab/a

# z:=1; x:=p; y:=q;

while (y>0) do begin

if odd(y) then z := z *x;

y := y div 2;

x := x * x;

end

if q = 13 , what is the sequence of values that z takes

# A & B are two symmetric N x N matrices

DO J = 1 to N;

DO K = 1 to N;

D = 0;

DO L = 1 TO N ;

D = D+A[J,L]+B[L,K];

END;

C[J,K] = 0;

C[K,J] = 0;

END;

END;

How many times is the statement X executed .

(??What is X)

Page 53: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 53

# <symbol> ->{<parent>,<let>}|<let>

<parent> -> (<let>) | <let> | <parent>,<let>

<let> -> A|B|C

which of the following are true , i.e. valid

a)C b){(C),C} c)B

# Computer A represents floating point exponents with 8 bits using

excess 128 to base 10 form. Computer B uses 8 bits and sign magnitude .

Which of the following is true ?

a)A -ve exponent in one corresponds to a positive exponent in the other.

b)No exponent has the same representation in the two systems .

# A computer represents floating point exponents using the excess

64 to base 10 form (using 7 bits). If two such exponents are added using

a seven bit adder , what is the modification in the sum required to

ensure that the resulting exponent is in excess 64 form.

a)generate end around carry and add

b)generate end around borrow and subtract

c)complement MSB

d)no change is required

# begin

cobegin x := y+1;y:=x;coend;

cobegin z:=y+1;y:=z;coend;

end;

What are the different values possible for y;

# Which has more prime factors , 105 or 310

# Express 217 (in base 10) in base 6

# x1______------ ____

|nand|________|nand|_____A

_______| | X1__|____|

C__| ------

|______|-----|

|nand |_______|-----|

x2----|_____| |nand |_____B

x2--|_____|

When C changes from 0 to 1 , (A,B) changes from what to what

(~x1,~x2) = (1,1)

#

Page 54: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 54

______

A------|nand|

B------|____|

| ______

|-------------|nor |

| |

|-------------|____|

|

__|__

C------|nor |

D------|____|

Which of the following circuits are equivalent to the one above

______

A------|and |

B------|____|

| ______

|-------------|and |

| |

|------------|____|

|

__|__

# let E = { 10,11,12,...,20} Define a relation R on (x,y) belonging to E

: R = { (x,y) | x,y have the same number of prime factors . } . What is

the number of equivalence classes into which the set is partitioned by

R.

# The following are coded representations of the numbers 2 ,4 , 6, 8 .

Which is not a Gray code .

a)1110,1010,1111,0101

b)1001,0011,1111,1100

c)1101,1000,0010,0111

# begin

b:=a+b+c+d+e;

c:=a+d+b+e;

d:=a+c+d+e;

end;

Page 55: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 55

code optimisation , which part of the above expression can be

moved outside the block .

# A

/ \

B C

/ \ \

D E G

/ /

F H

Results of preorder , postorder and inorder search of the tree .

# random number generation

n(i) = a(0) + (n(i-1) + b(0)) mod A

what is the length of the cycle of random numbers .

# solving f(x) = 0 , by gradient method , find conditions for

convergence

# Which of the following is a tautology

a) a or b => a and b

b) a and b => a or b

c) a => a and b

d) a or b => a equivalence b

# In a binary tree with n nodes, how many nodes will point to NIL

a)N b)N-1 c)(N-1)/2 d) (N+1)/2

# random numbers are generated in the range 0 <= x < 1 to get

numbers between -4 and 6 inclusive . [Int(k) = integer part of k]

a) int(11*rand(x)) -4

b)int(10*rand(x)) -4

c) int(rand(x))*10 -4

# number of comparisons to find max and second max amongst 4

numbers is

a)2 b)3 c)4 d)5 e)6

# programs are written with subroutines because of the following

reasons except

a)easy debugging b)no repetition of code c)increase in access speed from

buffer to main memory d)

# Pn = ao + a1x+a2x^2+.......anx^n.What is true about the

polynomial?

Page 56: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 56

1)it has n real roots

2)Any complex root is always accompanied by its conjugate.

3)It can be expressed as a product of n linear factors in a

complex field.

Ans 2 & 3

# A binary tree is stored as follows :-

1--> A ^ ^

2--> B 1 3

3--> C 6 ^

4--> D 2 ^

5--> E ^ ^

6--> F ^ ^

7--> G 4 5

^ is NULL

identify the tree :

a) D

/ \

B G

/ \ /\

A C D E

/

F

b) G

/ \

D E

/

B

/ \

A C

/

F

# All the following statements are true except :

1)concurrent processes must work on different processors.

2)If the result of two parallel tasks is independent of their speed then

the result has a deterministic solution.

Page 57: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 57

3)A deadlock is a circular wait where two or more processors are waitig

for others to release resources.

Ans 1

# Prefix form of (A*B^C + D^(E/F + G))

+^*ABC^D+/EFG

# WHAT is true for floating point numbers ?

1) f(x+(y+z))=f((x+y)+z)

2) (x+(y+z)) always has some relative error

3) xyz always has some small relative error

# processing jobs in a queue :

A 6microsecs

B 10

C 13

D 16

E 18

F 20

Find the average turn around time.

# A stack is defined as follows :-

a) e--> empty stack is a stack

b) S--> is a stack

c) PUSH(S,X) is a stack

d) POP(PUSH(S,X),X) is = S

e) TOP(PUSH(S,X))=X

which of the following cannot be defined using the stack defined

above;

Ans POP(POP(PUSH(e,X),Y),Y)

# A "summer" given :

LBABAEND

------------------------------------------

AGRE09.TXT

------------------------------------------

/* M.KANNAN */

DRAXBEGIN.

1 . A summer given ......

Page 58: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 58

X = X1 X2 X3 X4

+ Y = Y1 Y2 Y3 Y4

------------------------

S = S1 S2 S3 S4

Overflow Condition ??

_____ __

Answer : S1.(X1.Y1) + S1.X1.Y1

2 . In the grammar

<s> --> rl | r<s>l | <s><s>

which ones are possible

i) rrllrlrl ii) rllrrrll

iii) rrllrlrlrlrll

A) i) only . B) ii) only .

C) iii) only . D) i) , ii) & iii)

3 . for i = 1 to n do v[i] := v[i] + 1 ;

Which of the following does the same as above ?

i) i := 1 ;

while i <= N do

begin

v[i] := v[i] + 1 ;

i := i + 1 ;

end ;

ii) i := 0 ;

while i < N do

Begin

i := i + 1 ;

v[i+1] := v[i+1] + 1 ;

End ;

iii) i : = 0 ;

while i <= N do

Begin

v[i+1] := v[i+1] + 1 ;

i := i + 1 ;

End ;

Page 59: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 59

4 . In a new language the following is possible

if B1 then S1 if B1 then S1

B2 then S2 else if B2 then S2

. .

. ======> .

. .

Bn then Sn else if Bn then Sn

else Sn+1. else Sn+1.

Given a statement as below

if B1 then S1

B2 then S2

else S3 .

Which of the following has the same meaning ?

i) if ~B1 then if B2 then S2 else S3 .

ii) if B1 then S1 else if B2 then S2 else S3 .

5. Procedure

Integer n , x , y , z, w ;

Begin

Read(n) ;

x := n ; y := z := 0 ;

while (x > 0 ) do

Begin

w := y ;

y := z ;

z := w + 1 ;

x := x - 1 ;

End ;

write(z) ;

End ;

What is the final value of Z ?

a) [n] b) [n/2]

c) _ _

|n/2| (upper ceiling)

d) | n/2 | (lower ceiling)

-- --

e) n / 3 .

Page 60: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 60

6 . Two relations given ...

R : T :

--------- ---------

A | B B | C

--------- ---------

2 | 3 3 | 4

4 | 5 3 | 2

--------- ---------

RT => is a relation (a , b, c)

where (a,b) is an element of R.

and (b,c) is an element of T .

What are the possible values of (a,b,c) ?

7 . BIG := a[1]

for i = 2 to N do

if A[i] > BIG then BIG := A[i] ;

If in the above program , the biggest number can be anywhere in

A[1..n] with equal probability , find the average number of

executions of the instruction BIG := A[i] .

8. Given a NDFA , finf the regular expression ....

--- ---

| q | | B |

--- ---

___

--- ---

| A | || C ||

--- ___

___

Description :

Page 61: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 61

q : start state .

C : Terminal state .

Transitions :

q-->q : 1 ;

q-->B : 0 ;

q-->A : 0 ;

B-->A : 0 ;

A-->B : 1 ;

A-->C : 0 ;

C-->B : 1 ;

C-->C : 0 ;

9 . What is the regular expression ......

--- --- --- ---

| A | | B | || C || | D |

--- --- --- ---

Description :

Start state : A

Final State : C

Transitions :

A-->B : 1 ;

A-->D : 0 ;

B-->C : 1 ;

B-->C : 0 ;

B-->D : 1 ;

C-->D : 0 ;

10 . Begin

b := a + b + c + d + e ;

if c > 0 then d := a + b + c + e ;

else c := a + b + d + e ;

End ;

What can be taken out of the compound statement without

any problems ?

11 . Two type of instructions ..

----------------------------------

Page 62: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 62

| 0 | 3 bits |

----------------------------------

|<-- Op-code -->|

----------------------------------

| 1 | 6 bits |

----------------------------------

How many instructions possible ?

12 . A1 = A ; (a1) A2 = A ; (b1)

A1 = A + 10 ; (a2) A2 = A2 + 20 ; (b2)

A = A1 ; (a3) A = A2 ; (b3)

Statements a1 , a2 , a3 must be in that order .

Same for b1 , b2 , b3 .

How many ways can A be incremented by 30 ? (2)

How many ways can A be incremented by 10 ? (9)

13 . Next[j] := Next[i] ;

Next[i] := j ;

What happens to j ?

14 . Stacks : MUL and ADD instns POP 2 values , operate on them

and push result back . STORE pops one value of stores .

PUSH A

PUSH B

MUL

STORE T1

PUSH T1

PUSH T1

MUL

PUSH C

MUL

PUSH D

ADD

STORE T2

HALT

Page 63: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 63

T2 == ??

15 . Begin

i , j : integer ;

A(i) : array ;

Procedure P(x,y)

begin

y := y + 2 ;

x := x + y ;

end ;

for i = 1 to N do A[i] := i ;

L1 : P(A[j],j) ;

L2 :

at L2 A(1) = 1; A(2) = 2 ; A(3) = 3 ;

Then the procedure call should be ...

1) x call by value , y call by reference .

2) x call by ref , y call by value .

3) X call by ref , y call by value ,result .

16 . 5 profs , 5 courses .

Which of the following is true ?

Each prof not more than 1 course .

A --> CS1,4 ;

B --> CS1,2,3,4 ;

C --> CS1,2,3 ;

D --> CS1,5 ;

E --> CS1,4 ;

1) Prof D has to teach CS1

2) Prof E has to teach CS4

3) Either prof A or prof E has to teach CS1

4) Prof D has to teach CS5 .

17 .

a = x ;

Page 64: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 64

b = y ;

p = 0 ;

while ( a > 0 ) do

begin

p = p + b ;

a = a - 1 ;

end ;

What is the loop invariant ?

1) p > 0 ;

2) x*y = p + a*b ;

3) x*y = a - (p/b) ;

4) x*y = a*b - (p/b)

Answer : 2

18 .

S --> aAa | BSB

A --> aS | c

B --> b | bS

What is the minimum length string full of terminals possible ?

a) 1 b) 2 c) 3 d) 4 e) 5

Answer : c)

19 . What is true about the language generated by the above grammar ?

a) Start and end symbols are the same .

b) Only odd length derivations are possible .

c) Consists of at most one 'c' in any terminal string .

20 . Which of the following consist of strings that finite automata

accept ?

1) (0^n)(1^n) n >= 1 ;

2) (a^n)(b^m) m < n ;

3) Balanced Paranthesis ;

4) A string of zeroes and ones and in the prefix the number

of ones differs from the number of zeroes by one .

5) Equal number of zeroes and ones .

Answer : 4 .

21 . The number of bits to address 19000 words

Page 65: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 65

a) 7 b) 10 c) 11 d) 14 e) 16 .

Answer : d .

22 . Temp = A[N]

do I = 1 to N - 1

K = N - I - 1;

A[K+1] = A[K] ;

end ;

A[1] = temp ;

No idea what the question is about ????

*?

23 . Consider a sequence of records s1,s2,s3 .... sn

such that s1 < s2 < s3 < ........ < sn .

These records are stored in the array a[1..n]

Given the position of Si then the time required to locate position

of Si+1 is the order of

a) 1 b) N c) log N (to the base 2)

d) square(N) e) N-1

24 . Suppose the above sequence of records is represented in a binary

search tree with each node having a pointer to the parent node ,

a pointer to the left son , a pointer to the right son then given

the node Si , the time to find the location of Si+1 over all possible

binary search tree orederings of s1 , s2 ... sn is the order of ...

a) 1

b) log N (to the base 2)

c) N log N (to the base 2)

d) square( N )

e) N

25 . A certain computer follows a binary number system comprised of

Page 66: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 66

of 1 , 0 , ~1 .

For example (~1)01 implies

-1 * (2 power 2) + 0 * ( 2 power 1) + 1 * ( 2 power 0)

Which of the following is a valid representation for the number

6.25 ?

Answer : 100(~1).(~1)(~1)

26 . A certain computer has a primary memory of p locations and

a cache of c locations . A k-way associative mapping is used

such that a memory location in p maps to a particular location

in the cache . The cache is divided into sets of k-locations .

Assume k = 2 . Then the number of primary memory locations

coorresponding to a particular location in the cache is

a) 2 b) 4 c) p d) 2p/c e) p/c

27 . Now assume that the cost of accessing a particluar location is

proportional to log k (to the base 2) and the cost of construction

of cache is proportional to k . Then the optimum value of k to

maximize the ratio of value to the cost of constuction ....

i) 2 ii) 4 iii) 3 iv) c v) 1

28 . for J = 1 to N-1 do

for K = 1 to N-J do

if A[K-1] < A[K] then swap (A[K] , A[K-1]) ;

Now eventually the array A is such that A[i] = i ;

Then the number of swap statements executed is

i) N-1 ii) (N-1)*N iii) N*N

iv) (N*(N-1))/2 v) N-J

Answer : iv)

29 . Sally and Sue decide to write a Pascal program such that

Sally writes the main program and Sue is to write a function

zap(x,y) . On which of the following do Sally and Sue need not

agree upon ?

i) The place where zap is to be positioned in the main program .

ii) The type of the function zap .

Page 67: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 67

iii) The type of variables x , y ;

iv) The type of the formal parameters to zap .

Answer : i)

30 . Define a n-way tree as a single node for n= 1 else

each node has exactly n-children .

Then which of the following is true ?

i) There are no non-empty trees with even number of leaves with

odd n ;

ii) There are no non-empty trees with even number of leaves with

even n .

Answer : 1

DRAXEND.

------------------------------------------

AGRE10.TXT

------------------------------------------

/* R. GOPALAKRISHNAN */

SOFTYBEGIN

COMPUTER SCIENCE TEST Time 170 minutes, 80 questions

1) The number of 1s in the binary representations of

13*(16 cube) + 11*(16 sq) + 9*16 + 3 is

a)7 b)8 c)9 d)10 e)11

2)Which of the following has average case & worst case running times of

0(nlogn) ?

a)Bubble sort b)Insertion sort c)Merge sort d)Quicksort e)Selection

sort

3)With regard to Pascal declarations

type

Vector = array[1..10]of integer;

var

a :Vector;

b,c : array[1..10] of integer;

d: Vector;

which of the following is false?

Page 68: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 68

a)a & b have structurally equivalent types.

b)a and d have name equivalent types.

c)b and c have structurally equivalent types.

d)b and d have name equivalent types.

e)a ,c , and d have structurally equivalent types.

4)In the NoNicks OS, the time required by a single file-read operation has

4 non_overlapping components:

disk seek time : 25 ms.

disk latency time : 8 ms.

disk transfer time: 1ms per 1000 bytes.

OS system overhead :1 ms per 1000 bytes + 10ms.

In version 1 of the system, the file read retrieved blocks of 1000 bytes.

In version 2------------------do---------------------------- 4000 bytes.

The ratio of the time required to read a large file under version2 to the time

reqd by version1 is (approx)

a)1:4 b)1:3.5 c)1:1 d)1.1:1 e)2.7:1.

5)Sometimes the object module produced by a compiler includes information

(from the symbol table) mapping all source program names to their address.

The most likely purpose of this information is

a)for use as input to a debugging aid.

b)to increase the run time efficiency of the program.

c)for the reduction of the symbol table space needed by the compiler.

d)to tell the loader where each variable belongs.

e)to tell the OS what to call the variables.

6) a b c f

------------------------------------

0 0 0 1

0 0 1 1

0 1 0 1

0 1 1 x

1 0 0 1

1 0 1 0

1 1 0 1

1 1 1 x

consider logic function above (x = don't care).Which of the following statements

describes correctly the relation between the minimal sum and minimal

Page 69: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 69

product form of f?

a)They are logically equivalent by defn.

b)----------do----------------- because don't cares are used in same

way.

c)They are logically eq. because don't cares do not matter.

d)They are logically not equivalent by defn.

e)-----------------do------------- because don't cares are used in

different ways.

Questions 7-8 are based upon the following program written in Pascal

like language.

L1: begin

var a,b,c :integer; (1)

var d,e :real;

-------

-------

L2: begin

var a,f:integer;

var g,h:real;

---------

---------

end;

end;

Let the designation "block Li" refer to all statements from the begin

labelled begin to the corresponding end.

7)In block L2 the variables are best described as

a)dummy variables b)parameter var c)global var d)local var e)recursive var

8)If the notation L1-L2 means "the portion of block L1 not in L2", Then

the scope of the variables declared in the statement numbered(1) are

a)L1 for a and L1 for b

b)L1 for a and L1-L2 for b

c)L1-L2 for a and L1 for b

d)L1-L2 for both a and b

e)L2 for both a and b

9)The binary relation on the integers defined by

R = {(x,y):|y-x| <= 1}

has which of the following properties?

Page 70: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 70

i)reflexivity ii)symrttry iii)transitivity

a)none b)i and ii only c)i and iii only d) ii and iii only e)i, ii and iii

10)A major advantage of the direct mapping of a cache is its

simplicity.The main disadvantage is

a)it does not allow access to the intended data and tag

b)it is more expensive than other ytpes of cache organisation

c)the cache hit ratio is degraded if two or more blocks used

alternatively map onto the same block frame in the cache

d)its access time is greater than other forms of cache orgn

e)the number of blocks reqd for the cache increases linearly with the

size of the main memory

11)

2 computers communicate by sending data packets across a LAN.Size of

packets is 1000 bytes. netwok has a capacity for 1000 packets/sec. CPU

time required to execute the network protocol to send 1 packet is 10 ms.

Max rate at which a computer can send data is (approx)

a)10,000 bytes/sec

b)25,000 bytes/sec

c)100,000 bytes/sec

d)500,000 bytes/sec

e)100,000 bytes/sec

12)The language {ww |w belongs to (0 + 1)* }is

a) not accepted by any turing machine

b)accepted by turing m/c but not by push down automatan

c)accepted by push down automaton but not context free

d)context free, but not regular

e)regular

13) A singly linked list is implemented in two arrays, value and link,

in which link[i] points to the suvvessor of value[i].If an element not

initially in the list is assigned to value[j], then the program fragment

link[j] = link[i];

link[i] = j;

is one that

a)inserts value[j] before value[i] in the list

b)----------do---- after ---------do---------

c)replaces value[j] by value[i] in the list

Page 71: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 71

d)---------value[i]----value[j] ------------

e)does none of the above

14)Consider the part of the 2 dimensional integer grid bounded by point

A = (0,0) at the "southwest" corner and by point B = (n,n) at the

north_east corner.How many different ways are there of walking from A to

B on grid lines, always moving between any two grid points either north

or east?

a) 2 pow 2n b)(2n C n) c) n! d) n*n e) n*(n+1)/2

15)Consider the following program fragment

(1) for i := 1 to n do

(2) M[i] := 0;

Let A represent the initialization(i:=1);let B represent the body of the

loop; (line 2). Let I represent the incrementation of i implied by

line1, and let T represent the test for i<= n also implied by line1.

Which of the following regular expression represents all possible

sequences of steps taken during execution of the fragment, if it is

assumed that n is arnitrary and no abnornal terminations of loops can

occur ?

a)AT(BIT)* b)A(ITB)*T c)AT*B*I*T d)(ABIT)*

e)A(TBI)*

16)The following iteration where i and n have type integer and

the value of i is unimportant after the iteration

i:= n;

while i >1 do

begin

writeln("hello");

i := i-1;

end

is to be replaced bya call Foobar(n) where Foobar is defined by

procedure Foobar(j:integer) ;

begin

body

end;

A correct value of body is

a) if j >1 then

begin writeln("hello");Foobar(j-1);end

Page 72: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 72

b)Foobar(j-1); if (j > 1) then writeln("hello");

c)Foobar(j - 1); if(j >=1) then writeln("hello");

d)if (j>=1) then

begin

Foobar(j-1);

writeln("hello");

end

e) if (j > 1) then

writeln("hello");

Foobar(j-1);

17)

z = (i + a) . ((not a) + j)

is used to implement the function z = f(a,b) = not(a) + b

inputs (i,j) can be selected from the set {0,1,b,not b}

What values should be chosen for (i ,j)?

a)(0,b) b)(1,b) c)(1,1) d)(not b, 0) e)(1,not b)

|<----1----| |----0,1--|

18)start--> A ---1--> B ---0---> C ----0----> D-----<----

| |-----1---->------------|

| |

|-------------------0-------->----|

In the figure the finite automaton M has initial state A and accepting

state C.Which of the following regular exp denotes the set of words

accepted by M?

a)10* b)(10)* c)10*1*0 d)1(01)*0 e)(01)*01

19)A 0-2 binary tree is arooted tree such that every node has either 2

or no children.The height of a binary tree is the maximum number of

edges on a path from the root to a leaf.Let n(h) be the minimum number

of nodes in a 0-2 binary tree of height of height h, and let N(h) be the

maximum number.For all h > 0,(n(h),N(h)) =

a))h+1,2 pow h -1

b)h+1, 2 pow (h + 1)

c) h+1,2 pow (h+1) -1

d)2*h+1,2 pow h -1

Page 73: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 73

e)2*h + 1,2 pow (h+1) -1

20)Which of the regular expressions below describes the same set of

strings as the following grammar(with root S)?

S->Ax |By

A->y |Ay

B->x |y

a)y*x + xy +y

b)y*x + x +yy

c)yy*x +xy +y

d)y*x + xy+ yy

e)yy*x + xy +yy

21)Let A be an n * n matrix and P be an n * n permutation matrix. which

of the following must be true?

a)A = p(inv)ap

b)pa = p(p(inv)ap)

c)pap(inv) = p(p(inv)ap)p

d)ap = (p(inv)ap)p

e)det(a) = det(p(inv)ap)

22 & 23)

A single surface disk has the following characteristics:

# tracks/disk 35

# sectors/track 10

bits/sec Xfer rate 250,000

rpm speed 300

22)if no gaps & special formatting is assumed capacity of disk is in bytes

a) 6250 b)29267 c)218750 d)1750,000 e)none of above

23)Assume data xfers are interrupt driven 1byte at a time.If the instrns

to do a 1 byte xfer takes 8 micro secs, & interrupt overhead is 10 micro

sec, then time available between byte xfers for oyher computing in micro

sec is

a)0 b)8 c)10 d) 14 e) 32

24)Consider a floating point number system used by a modern computer for

solving large problems.+ denotes fp addition.which of the following is

true ?

a)x & y are real nos with fp representations x1 ,y1 then x1 + y1 is

always the fp represntation of x + y

Page 74: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 74

b)The associative law is valid

c)There are only finitely many fp numbers.

d)The fp numbers are equally spaced throughout their range

e) none of the above

25&26

In the microprogrammed control unit of the XMP computer, the output of

the control state is loaded into a contral register.the control store

may be addressed from any of 3 sources:1)o/p of a micropc for sequential access

of microinstrns.2)field in the control register for branch instrns 3)an

addl input to which are connected signals derived from other parts of

the XMP

25)The addl input if LEAST likely to be used for signals derived from

a)cpu instrn opcode

b)cpu instrn address

c)cpu instrn addr mode bits

d)alu condition codes

e)interrupts &/or other types of exceptions.

26)Suppose that the same clock signal is used to increment the micropc

and to load the control register.which of the following assertions is

true?

i)microinstrns execution time is atleast 2 clock periods

ii)micro instrn execution can be overlapped with fetching the next instrn

iii)unconditional branch instrns must take longer than other instrn types

a)i only b) ii only iii)iii only d)i & iii e) ii & iii

27)Consider the representation of 6 bit numbers in 2scomplemnt ,

1scomplement or by sign-magnitude.In which representation is there an

overflow from the addition of integers 011000 & 011000?

a)2s complement

b)s-m & 1scomplement

c)2s comp & 1scomplement only

d)2scomp and s-m

e)all 3

28)

a

|

Page 75: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 75

-------------

b c

/ \ / \

d e f g

init(q);

enqueue(q,root);

while not empty(q) do

begin

dequeue(q,a);

if a<> nil then

begin

print(a);

enqueue(q,a^left);

enqueue(q,a^right);

end

end

if the algorithm above is applied to the tree in the figure which of the

following is the output?

a)abcdefg b)abdecfg c)dbeafcg d)debfgca e)gfedbca

29)a 2-3 tree is a tree in which

i)every interior node has 2 or 3 children and

ii)all paths from the root to the leaves havr the same length

which of the following could be the number of interior nodes of a tree

with 9 leaves?

a)5 b)6 c) 7 d) 8 e) 9

30)Suppose that there is an open hash table with 4 buckets numbered 0..3

and integers are hashed into these buckets using the hash function h(x)

= x mod 4.If the sequence of perfect squares 1,4,9,..is hashed into the

table ,then as the total number of entries grow ,what happens?

a)2 of the buckets will get approx half the entries and the other 2 will

remain empty

b)all buckets will receive approx the same number of entries

c)all entries will goto the same bucket

d)all buckets will receive entries ,but the difference between the

buckets with the smallest & largest entries will grow

e)3 of the buckets will get approx the same number of entries(one third)

Page 76: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 76

while the fourth will remain empty.

SOFTYEND.

Page 77: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 77

------------------------------------------

AGRE11.TXT

------------------------------------------

/* P. VISHWANATH */

VISHYBEGIN

5) A certain computer uses a seven bit excess 64 exponent and a 24 bit

mantissa and a sign bit for floating pt repn. What does the following repn

show ?

|1 | 1010101 | 110----0

sign, exponen, mantissa

ans : 1) .875 exp 85 2) -.75 exp 21

6) Given the grammer

S -> S+S | S*S | a

how many distinct parse trees exist for the expression a+a*a+a

ANS : 1) 4 2) 5 3) 6 4) 9 5) 8.

ans :: (2) 5.

7) In a certain computer every address is translated to the physical address

by a page table as shown --->

VIRTUAL PAGE | PHYSICAL PAGE

0 3

1 -

2 1

A LOCATION IN THE PHYSICAL memory is given by (v,d) where v is the v.page

and d the byte of the actual page. Assume each page of 1024 bytes . Then

(0,514) corresponds to -->

ANS : 3586 .

8) A certain computer follows a binary no.. system composed of 1,0,Z.

eg. Z01 implies -1x4 + 0x2 + 1x1 = -3.

Which of the following is a valid repn.. of 6.25.

ANS : 1)100Z.ZZ

9) Consider a seq.. of records s1,s2,..,sn in strictly increasing order. They

are stored in the array a[1..n]. Given the position of s(i) , the time needed to

locate position of s(i+1) order --->

a. 1 b. N c. logN d.N**2 e. N-1.

ANS : 1

Page 78: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 78

10)Suppose the above seq. of records is represented in a binary search tree

with each node having a pointer to the parent node , to the left son , to the

right son . Then given the node si the worst case time to find the location of

s(i+1) over all possible search tree orderings of s1,s2 ..,sn is order of --->

a. 1 b. logN c. NlogN d. N**2 e.N.

ANS : e.

11) A certain computer has a primary memory of P locations and a cache of C

locns. A k way associative mapping is used such that a memory locn.. in P maps

to a aprticular locn.. in the cache. The cache is divided into sets of k locn.

Let k = 2. Then the no.. of primary memory locns. corresponding t o a

particular locn. in the cache is --->

a. 2 b.4 c. P d. 2P/C e. P/C

ANS : d.

12) Now assume that the cost of accessing a particular locn. is proportional to

logU and the cosrt of construction of cache is prop to U. Then the optimum value

of U to maximize the ratio of value to cost of constuction is

2 4 3 C 1.

ANS : 2.

13) In a particular no.. system a number a(n-1)...a(0) represents the decimal

value SIGMA(a(j) (-2)**j) (0 .. (n-1)).

Then which of the following represents an increasing order of numbers

in the given system .

ANS : D !!!

14) For J =1 to N-1 do

For K = 1 to N-J do

If A(K-1) < A(K) then

SWAP(A(K), A(K-1)).

Initially A(i) = i. Then the no.. of swaps executed is,

a. N-1 b. (N-1)N c. N**2 d.N (N-1)/2. e. N-J.

15) Sally and Sue decide to write a Pascal pgm such that Sally writes the main

program and Sue is to write a fn ZAP(x,y). On which of the following do they

need not agree upon,

1) The place where ZAP is to be positioned in the main pgm.

2) The type of function ZAP.

3) The type of the variables x,y.

Page 79: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 79

4) The type of the formal parametersto ZAP.

16) Define a n-way tree as a single node for n=1 else each node has exactly n

children . Then which of the following is true ?

1) There are no non empty trees with even no.. of leaves with odd n.

2) There are no non empty trees with even no.. of leaves with even n.

17) What range of values is ceil(log(n+1)) = 1 + flo(log n).

ANS : n >= 1.

18) A committee of persons is to be selected from N people. Each committee has a

particular person as a head. Two sets with the same persons but different heads

are regarded as 2 diff. committees. Then the no.. of different coms you can

have out of N is -->

ANS : SIGMA (i * Nci) [i = 1 ..N].

19) Consider the program segment -->

PROCEDURE

var x,y;

PROCEDURE p(a,b,c)

BEGIN

b = b+ 10;

a = b+ c;

END;

y = 20;

x = 10;

p(y,x,y);

write(Y,X);

END;

w.r.t this pgm, if p is called by reference , whay are printed ::

a. 40,20 b. 35,10 c. 30,20 d.25,35.

20) If the procedure P is call by value result what are the values of x,y.

a. 30,20 b.30,40 c.15,10 d.30,15.

21) a\bc

--------------------

| x | | 1 | x |

--------------------

| 1 | | x | |

--------------------

Page 80: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 80

Get the expression for the K-map --->

ans) b ~c v c ~b !?!

22) The input X is either 0 or 1 and does not change during a transfer .

----------------------

| ---------------- |

| | | |

Register D1 D0

| | | |

| ----------A2 - | |

-------------A1 - ROM |

| | X---A0 -------

| |

What does the configuration represent ?

a. A up counter (2 bit)

b. A down counter (2 bit)

c. 2 bit Up/Down counter

d. A 3 to 2 bit data compressor

e. A 8 state computer controller.

ANS :: c

23) Consider the multiplexor shown -->

Inputs -> X,Y, ~Z(c1).

c0,c2,c3 are not given. A table was given.

Which of the following donot represent ~Z~XY U X~Y

ANS :: b ?!?

24) In a new method of retrieval of a record there are 3 processors involved as

shown ->

p1 -> p2 -> p3.

p1 : locates the corresp. hash table.

p2 : locates the co. bucket in the hash table .

p3 : locates the co. record in the bucket.

Let them be invoked in any sequence. If the processing time for p(i)

is t(i) , then the min time between any 2 records searched is --->

a. min(t1,t2,t3). b. t1+t2+t3. c. (t1+t2+t3) /3 d. max(t1,t2,t3).

ANS : max(t1,t2,t3).

25) Suppose a single processor is used for all the 3 jobs with the corresponding

times t1,t2,t3 and the order of processing is 1,2,3. Then, min time between any

Page 81: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 81

2 records retrieved is ,

ANS: t1+t2+t3

If 3 processors can perform any job, min time = (t1+t2+t3)/3.

26)A certain computer transmits data at 10**7 bips and the transmitted data goes

at 1000m/s. 10000 bits are transmitted at stationA towards station B which is

10000 m apart. When does it reach B.

27) The no.. of stack locations needed for evaluating (((a+b)*e)-d) using a

stack is -->

a. 4 b. 5 c. 6 d.3 e. 7

VISHYEND

------------------------------------------

AGRE12.TXT

------------------------------------------

/* S. Satish */

STASHBEGIN

# Cost(i) is defined as the minimum number of additions of pairs

of numbers whose cost is already known , to obtain i. We start

with the number 1.

e.g.:

cost(1) = 0;

cost(3) = 2;

cost(6) = 3;

as 6 = 3+3, 3 = 2+1, 2 = 1+1

Find cost(11)

a) 4 b) 5 c) 6 d) 7 e) 8

Ans: b

# A,B,C,D are railway wagons on tracks. The straight numbered tracks

can hold 4 wagons each but the dotted or curved tracks cannot hold any

wagons. A move is defined as the movement of a wagon from a numbered

section to another without crossing over or by passing another wagon.

Find the maximum number of moves required to reverse the wagons in

section 4.

\ /

1\ /2

Page 82: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 82

\ /

. . .

. .

.

|

|3

|

.

. .

. . .

/ \

4/ \5

/ \

a) 7

b) 8

c) 9

d) 10

e) 11

Ans: c

# S -> abA

A -> SB

A -> a

B -> b

aA -> bB

Which of the following are true

I) ababa can be generated from the Grammar

II) The language generated is infinite

III) There exists a CFG for it

a) I only

b) I & II

c) I & III

d) II & III

Ans: d

inf i

# SIGMA A(i) x

Page 83: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 83

i=0

where

A(i) = fibonacci number A(0) = A(1) = 1

A(i) = A(i-1) + A(i-2) ; i >=2

a) 1 / (1 - x)

b) 1 / ( 1 - x**2)

c) 1 / ( 1 - x - x**2)

d) 1 / ( 1 + x - x**2)

# S -> AS | SB

A -> a

B -> bB | aB

Which of the following are useful ?

/* Sorry, the photostat copy in so terrible here */

/* that one cannot make out what the choices are */

# What is the boolean function implementated by the following circuit ?

X := nand(a,b,c)

Y := and (X,b,c)

Z := and (a,X,c)

W := and (a,b,X)

U := or(Y,Z,W)

What is the value of 'U' ?

#

________________ _________________ ___________________

| | | | | |

G--| |----------|D Q|--X | |

| | | | | Q |-Y

| GATE | | | F--| D |

| | | | | |

H--| | | | | |

| | | NQ |--NX | NQ|-NY

| | | | | |

| | | | | |

| | | | | |

________________ _________________ ___________________

| |

| |

Page 84: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 84

CLOCK____________________________________________________________

What should F,G,H be in terms of X and Y ?

What should the gate be ?

#

procedure WANDER(T:binarytree)

begin

if T is nt a leaf then

begin

if Leftson(T) <> NIL then WANDER(Leftson(T))

print(value(T))

if rightson(T) <> NIL then WANDER(rightson(T))

print(value(T))

end

end

c

/ \

a d

/ \ /

g e b

/

f

A) The output of the above function for the above tree is

a) aabbccddeeffgg

b)abcdefg

c)aeeacddc

d)ggaffeeacbbddc

B)

Maximum number of print statements for an N node binary tree

a) [log2N] /* lower bound log n to the base 2 */

b) N

c) N/2

d) 2N-2

e) 2N

#

Procedure PAL(s: array of characters )

Page 85: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 85

i,j : integer;

begin

PAL := false;

i := 1; j := n;

while ............ do

begin

i := i +1;

j := j -1;

end

if ( i <= j ) then PAL = true;

end

A) What should be substituted in palce of .......... ?

a) s[i] = s[j] and i<j

b) s[i] = s[j] and i>= j

c) s[i] <> s[j]

d) s[i] <> s[j] and i <> j

Ans : a

B) Assume that n is even and that 0.5 of the times the input to PAL

in not a palindrome and is in other cases it is equally likely that

the loop is terminated ( that is ) A[1]A[n], A[2]A[n-1] etc.

What is the average number of times the loop is executed ?

a) n

b) n/2

c) ((3n/8)- 1/4)

d) ((3n/8)+ 1/4)

Ans: c

# Which of the following parameter lists produce different results

for call by name and call by reference

begin

A: array ( 1..10 ) of integer ;

r,s,t: integer;

procedure f( x:integer; y :integer);

t:integer

begin

t:= x;

Page 86: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 86

x:=y;

y:=t;

end;

for t:= 1 to 10 do

A[t] := 2t;

r := 4;

s := 5;

t := 8;

f(*,*);

end

a) r,s

b) s,r

c) s,t

d) r,A[r]

e) A[r],r

# Seven segment display is used for displaying 0 to 9 with BCD WXYZ

with W as MSB . What is the fubction for d.

__

| |

--

| |

--

d

# For an ALGOL like language with block structure and stack discipline

for local variables , how many words of storage are required if one word

is allocated for integers and reals ?

a) 4

b) 5

c) 18

d) 14

e) 8

# m = memory cycle time

t = instruction execution time with one memory access

t > 2m

For DMA the controller requires for the memory bus. If the CPU

is using it , it gets control after CPU and will not delay the CPU

Page 87: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 87

for the next instruction . If the CPU is not using the bus , the DMA

will get control of the bus and then if the CPU requets the bus CPU

will have to wait . What is the average waiting time for the CPU

per instruction?

a) 2m/ t^2

b) m^2/ 2t

c) t/2m

# Hardware multiplication of 2 n bit numbers a and b is

implemented by equation

p(i+1) = (1/2) ( p(i) + 2^n a b(i))

b(i) = is the ith bit of the multiplier

b(0) = LSB

p(0) , p(1) , p(2) etc are partial products

p(n) being the final product.In the hardware implementation

this addition is performed and then a shift is performed

from left to right. The leftmost bit is assigned to

a) 0

b) 1

c) from the carry bit out of the highest order position

# A relation is a table with column headers .

X-> Y defines a set of attributes under the column heading in X are the same

then the attributes will be same under the column heading in Y.

relation : COURSE, TEACHER , STUDENT , ROOM , HOUR

(course) - > (teacher)

(student,hour) -> ( room )

(course,hour) -> ( room)

(room,hour) -> (course)

Which of the foolowing is not necessary

a) ( student,room)-> (teacher)

b) (room,hour) -> (teacher)

c) (student,hour) -> (course)

# Given a system of equations AX = B ( n by n matrices )

matrix A. The following progrma solves for X if

program solve :

begin

Page 88: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 88

x(n) = b(n) / a(n,n)

for i= n-1 to 1 do

x(i) = ( b(i) - x(i+1))/ a(i,i)

end

a) upper triangular matrix.

b) lower traingular matrix

c) main diagonal is non-zero and the diagonal above is all ones

d) main diagonal is non-zero and the diagonal below is all ones

# For the following program fragment

{ z := z*a ; y := y -1 ; }

Which of the following assertions is true before and after the

execution of the fragment .

a) a^b = z(a^y)

b) ab = z + ay

# A computer has 3 types of instructions

1) Instruction fetch ; defer for indirect addressing , execute

2) Instruction fetch , execute

3) Instruction fetch ; fetch/ execute immediately

States are

1) fetch / execute

2) defer

3) execute

The connectivity matrix of the states of the computer are

_ _ _ _ _ _

| 1 0 1 | | 1 1 1 | | 1 1 1 |

| 0 0 1 | | 0 0 1 | | 1 0 1 |

| 1 0 0 | | 1 0 0 | | 0 0 1 |

- - - - - -

# Let A be the time taken for a memory cycle . Let 'm'

be the average number of cycles an instruction takes and let

I be the time taken for execution /fetch including memory

access times . A DMA is also to be performed at every 't'

seconds and each DMA takes one memory cycle. The necessary

Page 89: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 89

condition for the CPU to go unaffected by the DMA is

a) I <= MA

b) t <= I

c) T < ( M + 1) A

# In a particular number system a number a(n-1) ... a(0) represents

the decimal value

SUMMATION a(j) ( -2)^j

j going from 0 to ( n-1)

Then which of the following represents increasing order of numbers

in the given system.

/* No fundas in this problem */

Ans d)

# for j = 1 to n-1 do

fo k = 1 to n-j do

if a[k-1] < a[k] then

swap(a[k],a[k-1]);

Now initially the array A is such that A[i] = i

then the number of executions of swap statements is

a) N-1

b) (N-1)N

c) N^2

d) N(N-1) / 2

e) N-J

# Sally and Sue decide to write a Pascal program such that Sally writes

the main program ans Sue is to write a function ZAP(x,y) . On which

of the following do Sally and Sue need not agree upon.

a) The palce where ZAP is to be positioned in the main program

b) the type of function ZAP

c) the type of the variables x,y

d) the type of the formal parameters to ZAP

# Define a n-way tree as a single node for n=1 else each node has exactly

n children . Then which of the following is true

a) There are no non-empty trees with even number of leaves with odd n.

b) There are no non-empty trees with even number of leaves for even n.

# For what ranges of values is

Page 90: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 90

________

| log (n+1) = 1 + | log n |

| 2 |____ 2 _|

a) n >= 1

b) n >= 2

c) n > 4

d) n > 1

e) for finitely any n

# Consider the following program

Procedure X

var x,y;

procedure p(a,b,c)

begin

b := b + 10;

a := b + c;

end

y = 15

x = 10

p( y , x, y);

write(y,x)

end

with respect to the above program fragment if the procedure P is call by

reference what are the values of x,y printed out

a ) 40 , 20

b ) 35 , 10

c ) 30 , 20

d ) 25 , 35

# If the procedure P is call by value result . What are the values of

x,y ( assume that ordering is from left to right )

a) 30 ,20

b) 30,40

c) 15,10

d) 30 ,15

# Given the three variable K-MAP ( x denotes donot care ), which of the

following donot represent the expression given by the K-MAP

Page 91: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 91

\ BC

A \________________________________

| x | | 1 | x |

________________________________

| 1 | | x | |

________________________________

Ans e) B(~C) OR (~B)C

#

The input X in the following diagram is either 0 or 1 and does not

change values while a transfer is taking place.

A2 A1 A0 D1 D0

0 0 0 0 1

0 1 0 1 0

1 0 0 1 0

1 1 0 0 0

0 0 1 1 1

0 1 1 0 0

1 0 1 0 1

1 1 1 1 0

_____________________________________

| |

| _________________________ |

| | | |

___________ D1| | D0

| REGISTER | _______________

___________ | |

| | | |

| |____________________ A2| ROM |

|_________________________ A1| |

| | ----- A0| |

| | X _________________

What does the configuration represent

a) A UP counter ( 2 bit )

b) A DOWN counter ( 2 bit )

Page 92: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 92

c) 2 bit UP_DOWN counter

d) A 3 to 2 bit data compressor

e) A 8 state computer controller

# Consider the multiplexor shown

C0 C1 C2 C3

_________________ The input to C1 is (~Z)

A | |

B | |

_________________

A table was given

Which of the following donot represent ( ~z ~x y ) or ( x ~y )

Ans b)

# Grammar

S -> Aa | bB | Sa

A -> b| a

B -> Aa

Which of the following is true.

a) aaaa proves that grammar is ambiguous

b) baaa proves that the grammar is ambiguous

c) abab proves that the grammar is ambiguous

d) Ambiguous but not detectable from the above given productions

e) Not ambiguous

#

________________________________________

| ___________________________ |

| | ______________ | |

| | | | | |

| | | | | |

| | | | | |

__________________ __________________

| D1 D2 D3| | |

clock | FLIP FLOPS | | |

______ | Q1 Q2 Q3| _____ | COMBNATORIAL CKT |

| __________________ | __________________

| | | | | | | |

Page 93: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 93

____________________________

| | | | | |

| | | | | |

| | | | | |

| | ______________ | |

| ___________________________ |

________________________________________

| | |

| | |

| | |

Initially Q1 Q2 Q3 == 0 0 0

For the next 8 clock pulses

Q1 Q2 Q3

1 0 0

0 1 0

0 0 1

0 0 1

0 0 1

0 0 1

0 0 1

0 0 1

What is the boolean logic implementation for D1 D2 D3 in the

combinatorial circuit to get the desired output.

Ans

_ _ _

D1 = Q1 Q2 Q3

D2 = Q1

D3 = Q2 OR Q3

# 5 processes are in a queue. The times for completion for

each process are

p1 = 6 units

p2 = 3

p3 = 4

p4 = 3

p5 = 2

Find the minimum average turn around time

Page 94: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 94

a) 18/5

b) 9

c) 62/5

d) 63/5

e) 18

Ans b)

# An array defined as A[1:8,-2:2,3:12]

A[1,-2,3] is at the location 2000

What will be the location of A[5,0,5] be

Ans 2222

# A disk has the following properties

- tracks =35

- sectors = 10

- but transfer rate = 250000 bits/sec

- speed of rotation = 300 rev/min

Find the total storage in bytes

# Interrupt is used for request for a single byte if interrrupt

overhead = 10 micro seconds and byte transfer rate time = 8 micro sec

, how much time is available for byte transfers?

( See december 1985 paper )

# r = revolutions per minute

s = number of sectoras

k = number of words per sector

n = number of bits per word

b = bit rate per second

What inequality holds if there is to be a gap between sectors

a) 60 b > rskn

b) 60 b < rskn

# if the disk accesses memory directly then the memory access time can

be atmost

Ans: n/b

# Stack initially empty

Each of I(i) is either a PUSH(X,i) operation ( X == stack)

or pop(X) operation

What cannot be the contents of the stack after the excution

of halt in the following sequence

Page 95: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 95

I1,I2,I3,I4,I5,HALT

a) <2>

b) <3>

c) <5>

d) <1,2,5>

e) <3,4,5>

# Define stack as follows

- E is an empty stack

- PUSH(E,X) is a stack

- POP(PUSH(S,X),Y) == S

- TOP(PUSH(X,S)) == S

Which of the following cannot be defined by using the above

functions

Ans TOP(POP(PUSH(E,X),Y) == X

#

Binary search on a sorted ascending order array . find average

search time ( program was given in the question paper )

A[1..n] middle number was 'm'

#

if m<=n is replaced in the program by m < n when will it affect

the search

# Linked list

First and last pointers to the list were given.

What operation depends on the length of the list

Ans deleting last element

#

Two relations given

Relation R

A | B

____

2 | 3

4 | 5

Relation T

B | C

_____

3 | 4

Page 96: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 96

3 | 2

RT ==> relation ==> (a,b,c)

where (a,b) belong to R

and (b,c) belong to T

What are the posible values of (a,b,c)

# BIG = A[1]

for i= 2 to N do

if A[i] > BIG

then BIG = A[i]

In the above program if the biggest number can be anywhere in A[1..N]

with equal probability . Find average number of executions of the

statement BIG = A[i]

Ans : H(n) harmonic series

SUMMATION 1/i

i from 1 to n

#

NDFA

Which of the following does it accept

0

_____________> B

1 |\ | | |

-- S 1 up| |0 downward

start | | |

_____________> A

0

Ans: 100100

# DFA given accepts

Ans : 1(01)*0

OR

10(10)*

#

begin

b := a+b+c+d+e

if c>0 then d : = a+b+c+e

else e := a+b+d+e

Page 97: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 97

z := a+b+c+d+e

end

What can be taken out of the compound statement without any

problems

Ans: a+e

#

Two types of instructions

________________________________________

| indicator bit | instruction | operand |

________________________________________

___________________

| 0 | 3 bits | |

___________________

___________________

| 1 | 6 bits | |

___________________

How many instructions are possible

Ans: 2^3 + 2^6 = 72

#

a1: A1 := A

a2: A1 := A1 + 10

a3: A := A1

b1: A2 := A

b2: A2 := A2 + 20

b3: A := A2

The statements a1 a2 a3 must be in that order but not necessarily

together . Same for b1 b2 b3 statements

In how many ways can A be incremented by 30 ?

# In how many ways can A be incremented by 10 ?

# Consider the following linked list

________ ____ _______

---> | i - 1 | ---> | i | ---> | i + 1 | -->

________ ____ _______

__

| j |

Page 98: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 98

____

after NEXT [j] = NEXT [i];

NEXT [i] = NEXT [j];

What happens to j ?

#

One problem on microprogramming

#

One problem on KWIC indexing

#

Stack problem :

MUL or ADD pops top 2 values , performs the respective operation

and puts back the result on top of the stack.

STORE pops one value and stores it.

PUSH A

PUSH B

MUL

STORE T1

PUSH T1

PUSH T1

MUL

PUSH C

MUL

PUSH D

ADD

STORE T2

HALT

What is ther value of T2 ?

( in terms of A,B,C,D)

STASHEND

------------------------------------------

AGRE13.TXT

------------------------------------------

/* KODAKULA INDUPRAKAS */

FUNDUBEGIN

68)

Page 99: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 99

Computer A represents floating pt exponents with 8-bit using excess

128 (10) form. Computer B uses 8 bits & sign magnitude. which of the

following is true?

1) A -ve exponent in one m/c corresponds to a positive exponent

on the other m/c

2) No exponent has the same reprsn in the two systems.

69)

A computer represents floating point exponents in excess 64(10)

form , using 7 bits. If two such exponents are added (because of a

multiplication using a 7 bit adder) , what is the modification in the

sum required to ensure that the resulting exp is in excess 64 form?

1) Generate end-around carry and then add.

2) Generate " borrow and then subtract.

3) Complement MSB.

4) No change reqd.

70)

Begin

Cobegin x = y+1 ; y = x; coend;

Cobegin z = y+1 ; y = z; coend;

end;

What are the different values of y possible.

71)

Which has more distinct prime factors ? 105 or 310

Page 100: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 100

72)

Express 219 (10) in base 6.

73)

x1------ x2-----|

|-----| |NAND------A

|NAND----------|

|-----|

c-------|

|-----|

|NAND----------|

|-----| |NAND------B

x2------ x1---- |

When c changes from 0 to 1 , (A , B) changes from what

to what ?

(x1 , x2) = (1 , 1)

74)

E = ( A NAND B) NOR (C NAND D)

which of the following is equivalent.

(No answer given , only it is mentioned that only and or gates

are used).

75)

let E = { 10 , 11 , .. 20 }. Define a relation r on x , y

belonging to E as R (x , y) = { (x , y) | X & Y have the same number of

prime factors. What are the equivalence claases into which the set is

partitioned by R ?

76)

Page 101: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 101

The following are coded reprsns of the numbers 2 , 4 , 6, 8.

Which is not a gray code? (a)

a) 1110 , 1010 , 1111 , 0101

b) 1001 , 0011 , 1111 , 1100

c) 1101 , 1000 , 0010 , 0111

77)

begin

b = a + b + c + d + e

c = a + d + b + e;

d = a + c + d + e;

end.

Code optimization , which part of the above expression

can be moved outside the block ?

(a + d + e)

78)

------- A--------

| |

--------B--------C--------

| | |

D E G

| |

F H

What are the result of preorder , postorder and inorder

traversal of this tree ?

79)

Random number generator

n(i) = a0 + (n(i-1) + b0) mod A

Page 102: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 102

What is the length of the cycle of random numbers. (A)

80)

Solving f(x) = 0 by gradient method.

81)

Find the condition of convergence.

82)

pgm-parameter passing.

83)

Which is a tautology?

a) a or b => a and b

b) a => a and b

c) a and b => a or b

d) (a or b) => (a equivalence b)

84)

Two way two state logic.

85)

Every node in a binary tree has the form

lptr|info|rptr

In a binary tree with n nodes , how many nodes will point to null?

(n + 1)

Page 103: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 103

86)

random numbers are generated in the range 0 <= x < 1;

To get #s between -4 & 6, inclusive (int(k) gives integer part

of k)

Answer - int (11 * rand(x) - 4)

87)

#comparisons to find the max and second max among 4 numbers is

a) 2

b 3

c 4 ----------------right

d 5

e 6

88)

programs are wriiten with subroutines because of the following

reasosns except

1) easy debugging

2) No repitition of code.

3) Increase access speed from buffer to main memory -- right.

89)

i = n

P(n) = E a(i) * (x ** i)

i = 0

What is true about the polynomial?

1) It has real roots

2) Any complex root is accompanied by its conjugate.

Page 104: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 104

3) It can be expressed as the product of n linear factors in

a complex field. ------- right.

90)

FUNDUEND

------------------------------------------

AGRE14.TXT

------------------------------------------

/* L.B.HARIKRISHNA */

LBBEGIN

_ _

(17)for what range of values is | log(n+1) | = 1 + |_ log n _|

(1) n >= 1 (2) n >= 2 (3) n > 4 (4) n > 1 (5) for any finite n

(18) A committee of persons is to be selected from N people , each

committee has a particular person as a head. Two sets with the same

persons but different heads is regarded as two diff. committees. Then

the no: of different committee s you can have out os N is

(1) sigma(i = 1..N) NCi (2) sigma(i = 1..N) i*NCi (3) Ni

(19) Consider the program fragments

Procedure;

var: x,y;

Procedure P(a,b,c)

Begin

b := b + 10;

a := b + c;

End;

y = 20; x = 10;

P(y,x,y);

Write(y,x)

End;

with respect to the above program fragment if the procedure P

is call by reference what are the values of x,y printed out:

(1) 40,20 (2) 35,10 (3) 30,20 (4) 25,35

(20) if the procedure P is call by value result what are the values

Page 105: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 105

of x,y (assume ordering is from left to right)

(1) 30,20 (2) 30,40 (3) 15,10 (4) 30,15

(21) \ B

\________________

A| X | | 1 | | In the given three variable K-map

|---------------- X denotes the dont cares, which of

| 1 | | X | | the following do not represent the

|________________ expression given by the K-map

Ans B.~A \/ ~B.A

(22) __________________________

| ________________ |

| | | | One input X is either 0 or 1

---------- | | and does not change while a

| Register | | | transfer is taking place

---------- D0 | | D1

| | A2 _|__|__

| |--------------| |

|--------------------| ROM |

| | A1 --------|______|

| | X A0

What does the configuration represent :

(1) a up counter (2 bit)

(2) a down counter (2 bit)

(3) 2 bit up-down counter

(4) a 3 to 2 bit data compressor

(5) a 8 state computer controller

(23) consider the multiplier shown

~Z

|c0 |c1 |c2 |c3

\|/ \|/ \|/ \|/

----------------------------

X------| A |

| |

Y------| B |

|__________________________|

A table was given .

Page 106: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 106

which of the entries do not represent ~Z.~X.Y \/ X.~Y

(ans: b)

(24) In a new method of retrieval of a record there are 3 processers

as shown

------- -------- --------

| | | | | |

| p1 |------> | p2 |-----> | p3 |

|_____| |______| |______|

processor p1 locates the hash tables

p2 locates the corresponding bucker in the hash table

p3 locates the appropriate record in the bucket

processor p1,p2,p3 are invoked in any sequence. Let the processing

time of each be t1,t2,t3 respectively

Now the maximum time between any two records searched is:

(1) min(t1,t2,t3)(2)t1 + t2 + t3 (3) (t1+t2+t3) / 3

(4) max(t1,t2,t3)

(25) suppose a single processor is used for all the three jobs with the

corresponding processing times t1,t2,tt3 and the order of processing

is 1,2,3 then the min time between any two records retrieved is

(1) (t1+t2+t3) / 3 (2) 3 / ( 1/t1 + 1/t2 + 1/t3 )

(3) max( t1, t2, t3) (4) min(t1,t2,t3)

(26) A certain computer transmits data at 10^7 bits per second and the

transmitted data goes at 1000m/sec . 10000 bits are transmitted

at a station A towards station B which os 10000 m apart. When does

it reach station B.

(27) The number of stack locations needed for evaluating (((a+b)*e)-d)

using a stack is

(1) four (2)five (3)six (4)three (5)seven

(28) Define two operations

T1: complement any two bits

T2 exchange any two bits

starting with 000000 which of the following cannot be generated

using sequence T1 and T2

(1) 110 000 (2) 001 001 (3) 100 001 (4) 000 010

(5) 001 100

(29) with respect to compilers the hash table implementation of

Page 107: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 107

symbol tables is prefered because

(1) information retreival in hash table is of constant time

(2) direct reference for identifiers

|

.

and so on

(30) A Given the binary tree , the postorder traversal

/ \ of the tree is:

/ \

F B

/ \ \

/ \ \

D E C Ans: DEFCBA

(31) Consider the set Sn = {1,2,3 .. n} then the recurrence equation

for the numbering of subsets of Sn such that no two elements in

a set are consecutive numbers:

(1) S0 = 0

Sn = 2Sn-1 + 1

(2) S0 = 1, S1 = 1

Sn = Sn-1 + 1 n >=1

(3) s0 = 1, S1 = 2

Sn = Sn-1 + Sn-2 n > 1

(4) none of the above

(32) Which of the following is not a context free grammar

(1) { 0^i 1^j | i!=j } and so on

[ that is all the info given here]

LBEND

------------------------------------------

AGRE15.TXT

------------------------------------------

/* RAJESH KAMATH */

DADDUMBEGIN

My agre list.

-kamath

1. G: S --> Aa|bB|Sa

A --> b|a

Page 108: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 108

B --> Aa

which of the following is true ?

a)string 'aaaa' proves that G is ambiguous .

b)string 'baaa' .......do .....

c)string 'abab' .......do......

d) there exist ambig. grammars but not from a,b or c

e) not ambiguous.

2. --------------------------------------

| ---------------------------------- |

| | ---------------------------- | |

| | | | | |

------------- -----------

Clk | D1 D2 D3 | | Combin. |

-------------| | | |

| Q1 Q2 Q3 | | ckt. |

------------- -----------

| | | | | |

| | |--------------------------| | |

| ---------------------------------- | Q1=Q2=Q3=0 initially

-------------------------------------

| | |

The following are the values of Q1,Q2 ,Q3 for the other 8 clk cycles

What is the boolean logic implementation for D1,D2 and D3 in terms of

Q1,Q2 and Q3?

a)D1= ~Q1.~Q2.~Q3 b) D2=Q1 c) D3=Q2 \/ Q3.

3. 5 processes are in a queue. The times for completion of each are 6,3,

4,3 and 2 respectively. Find the minimum average turn around time

a) 18/5 b) 9 c)62/5 d) 63/5 e)18 ans: b

4. An array is defined as : A[1..8,-2:2,3:12]. A[1,-2,3] is at location

2000.

a) What is the address of A[5,0,5]? ans : 2222

b) How many locations are there? ans : 400

5. A disk has the following parameters : Tracks-35 ,Sectors-10, Data transfer

rate- 250,000 bits per sec ,speed of rotation-300 rev/min .What is the

total storage in bytes . ans:(?) 6250*1750000

Page 109: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 109

6. Interrupt is used for a byte transfer request from the above disk. If the

interrupt overhead is 10 microsecs, 4 byte transfer time is 8 microsecs,

how much time is available during byte transfers for other work?

ans:(?) 14 microsecs

7. r : rev/min of a disk

s : no. of sectors

k : no. of words /sector

n : no. of bits /word

b : bit rate/sec

what inequality has to hold between sectors? ans :(?) 60b < rskn

8. If the disk accesses memory directly then memory access time can be at

atmost? ans: n/b

9. A stack is initially empty. A program is executed .It is either a PUSH

or a POP instruction. Which of the following cannot represent the stack's

contents after HLT?

program: I1,I2,I3,I4,I5,I6,HLT a)<2> b)<3> c)<5> d)<1,2,5> e)<3,4,5>

10. Define a stack as follows:

i) epsilon --> is a stack

ii) Push(s,x) --> is a stack

iii) Pop(Push(s,x),y) = s

iv) Pop(Push(s,lambda)) = lambda

Which of the following can't be defined using the stack definition

given above: ans: Pop(Pop(Push(epsilon,x),y),y) =X

11. A PARSING AUTOMATON:

e

(S)-------->( S->.) a

(S->.b)-------------->( S->a.)-----<--|

(S->.aS) (S->a.S)----->--|

| |

(check up on Aho and Ullman :Principles of Compiler Design)

12. The following program uses binary search to find if z is in A[1:n]

arranged in increasing order

f:=1;l:=n;

while f<=l do

begin

* ---------> m := |_ f+l/2 _|

Page 110: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 110

if z = A[m] then write(true)

else if z > A[m]

then f := m+1 else l:=m-1;

end

The average search time is : ans: O(log n) BINARY SEARCH

13. If the statement * in 12. is replaced by some arbitrary statement ,which

gives out a vague answer ,which of thew following will be least likely

to detect the error?

i) n odd ii) f=[ |_ n _| ] iii)... iv) n = 0 ans: iv)

14. in the problem 12. if f <= l is replaced by

************************* 10 - 19 has been duplicated by Snoopy ****************

20. procedure P(m;n)

begin

m:= m-n;

n:= n-1;

m:= n-m;

end

begin

i:=2;j:=3;

P(i,j)

end

Find the values of i , j after execution

Ans: 3,2

21. F, L are pointers to the first and last elements of a list

[____]-->--[____]-->--...---[_____]--->-||

*F *L

Which of the following depends on the number of elements in the list?

a) insertion before the first

b) insertion after the last

c) deletion of the first

d) deletion of the last

e) none of the above

22. Given a summation X1 X2 X3 X4

Y1 Y2 Y3 Y4

___________

S1 S2 S3 S4 ,which is the overflow condition?

Page 111: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 111

ANS: X1.Y1.~S1 + ~X1.~Y1.S1

23. G: <S> -> rl|r<s>l|<s><s>

which ones are possible?

i) rrllrlrl A) i only

ii) rllrrrll B) ii only

iii) rrllrlrlrlrll C) iii only

D) i and ii

Ans : A E) ii and iii

24. For i:= 1 to N do v[i] := v[i] +1

which of the following does the same as above?

a) i:= 1; c) i:=0;

while i<= N do while i<= N do

begin begin

v[i] := v[i] +1; v[i+1]:=v[i+1] +1

i := i +1; i:=i+1;

end end

b) i:=0;

while i< N do

begin

i:=i+1;

v[i+1] := v[i+1] +1;

end

A) a only B) b only C)c only D) a and b E) b and c

Ans: A

25) In a new language, the following is possible...

If B1 then S1 If B1 then S1

B2 then S2 else if B2 then S2

. implies> else .

. .

Bn then Sn else if Bn then

Sn

else S(n+1) else S(n+1)

Which of the following have the same meaning as

if B1 then S1

~B2 then S2

Page 112: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 112

else S3

i) if B1 then S1

else if ~B2 then S2

else S3

ii) if ~B1 then if B2 then S3

else if ~B2 then S2

else S3

iii) If B1 then S1 else if B2 then S2

else S3 Ans: i)

26) Procedure ......;

Integer n,x,y,z,w;

begin

read(n);

x:= n;

y:= z:=0;

while x>0 do

begin

x:=y;

y:=z; (doubtful .bad XEROX)

z:=z+1;

x:=x-1;

end

write z

end

What is the final value of z?

a) [n] b) [n/2] c) upperlimit(n/2) d) lowerlimit(n/2) ,i.e. |_ _|

e) n/3 Ans. c

27) Two relations are given...R and T

R T = (a,b,c)

where (a,b) are in R R: a b T: b c

and (b,c) are in T 2 3 3 4

4 5 3 2

What are the possible values of (a,b,c)

Ans: (2,3,4) , (2,3,2)

28) Big:= A[1];

For i:= 2 to N do

Page 113: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 113

if A[i] > Big then Big:= A[i];

If Big can be anywhere with equal probability in A[1:n] find the

average number of executions of the statement Big := A[i]

Ans: (n/2;)

0

|->|

29) | | 0 1 0

---->( 1 )----->--( B )----->-<---(( C ))--->--|

| |--<--|| | \--<----/

|1 0| |->--/ 1 0 |

\->--( A )-------->-<--------/

Which of the following strings does this accept? Ans: 100100

30) 0

|----->------|

1 | 1 | 0

-->-( A )-->-( B )---<---(( C ))--->--( D )

| | 1 ||

| 0 \-------->--------------/|

\----------->----------------------/ r.e.? Ans: 1(01)*0

0

|-----<-----| 0

0 | 1 | 1 |------<--|

-->-( A )-->-( B )--->---(( C ))--->--( D )--->--|

| | 0 ||

| 1 \-------->--------------/|

\----------->----------------------/ r.e.? Ans: 01(01)*

31) Begin

b:= a+b+c+d+e

if c>0 then d:= a+b+c+e;

else c:= a+b+d+e;

z:= a+b+c+d+e;

end

What can be taken out of the compound statement? Ans: a+e

32) Two types of instructions :

Page 114: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 114

|_0_|__3 bits__|_opcode_| |_1_|__6 bits___|_opcode_|

How many instructions are possible? Ans: 72

33) A1:= A; .......a1 A2:=A; .....b1

A1:= A1+10; ..a2 A2:=A2+20; ....b2

A:= A1; .......a3 A:=A2 ......b3

In how many ways can A be incremented by 30 by permuting a1,a2,a3,b1,b2,b3?

a1 before a2 before a3

b1 .......b2 ...... b3 Ans: 2

33b) In how many ways can A be incremented by 10? Ans: 9

34) Next[j] := next[i]

Next[i] := j; What happens to j Ans: j inserted after i

35) Stack machine

Store pops one value and stores it;

MUL and ADD operate on the top two values of the stack

and the result is stored on to the stack

PUSH A

PUSH B

MUL Wgat is stored in T2? ANS: (AB)^2 * C + D

STORE T1

PUSH T1

PUSH T1

MUL

PUSH C

MUL

PUSH D

ADD

STORE T2

HALT

36) ,37 ) microprogramming and KWIC indexing

KWIC indexing -----> removes articles|prepositions from text

38) Two computers A,B exist with machine languages Ma and Mb; Assembly

languages La and Lb; Cross Assembler for B running A is

a) La to Ma b) La to Mb c) Lb to Ma+La d)La to Ma+Mb

Page 115: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 115

e) Lb to Ma Ans: b

DADDUMEND

Page 116: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 116

------------------------------------------

AGRE16.TXT

------------------------------------------

/* KUDIARASU */

GURUJIBEGIN

1) Grammar G : S -> Aa | bB | Sa

A -> b | a

B -> Aa

which of the following is true

A : aaaa proves that G is ambiguous

B : baaa ''

C : abab ''

D : Ambiguous but nnot detectable from above given productions

E : not ambiguos

2) _________________________

| _____________________ |

| | _________________ | |

| | | | | |

________ __________ Initially

clock |D1D2D3| clock | Combin.| Q1 = 0, Q2 = 0, Q3 =

0

-------| FF | ------| ckt |

|Q1Q2Q3| | |

-------- ----------

| | | | | |

| | -------+--------- | |

| | | | |

| | | |

| -----------+--------| |

| | |

| |

| |

----------------+--------

|

For next 8 clock cycles

Page 117: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 117

Q1 Q2 Q3

1 0 0

0 1 0

0 0 1

0 0 1

0 0 1

. . .

. . .

0 0 1

What is the boolean logic implemented for D1 D2 D3 in the Combin.

ckt to get the required o/p

__ __ __

Ans D1 = Q1.Q2.Q3

D2 = Q1

D3 = Q2 V Q3

3) 5 process are in a queue. The times for completion for each are

P1 = 6 units, P2 = 3, P3 = 4, P4 = 3, P5 = 2

Find minimum average turn around time.

a) 18/5 b) 9 c) 62/5 d) 63/5 e) 18

4) An array defined as A[1:8,-2:2,3:12]

A[1,-2,3] is at location 2000

where will be A[5,0,5] be.

Ans : 2222

5) A disk has following properties.

Tracks - 35 Sectors - 10

Bit transfer rate - 250000 bits/sec

Speed of rotation - 300 rev/min

Find total storage in bytes.

6) Interrupt is used for request for a byte. If interrupt overhead = 10us

and byte transfer time = 8us, how mich time is available for a byte

transfer. ( see Dec '85 paper )

7) n - revolution per min

s - #sectors

k - # of words per sector

r - # of bits per word

Page 118: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 118

b - bit rate /s

What in equality holds if there is to be a gap between sectors

d) 60 > rskn e) 60b < rskn

8) If disk accesses memory directly then memory access time can be

atmost

Ans : n/b

9) Stack initially empty :

I1 each of Ii is either a PUSH(X,i) operation

I2 ( X => stack ) or POP(X) operation

I3 which can't be the contents of atsck

I4 after HALT ?

I5

HALT i) <2> ii) <3> iii) <5> iv) <1,2,5> v) <3,4,5>

10) Define stack as follows

1) E is an empty stack

2) PUSH(E,X) is a stack

3) POP( PUSH(S,X),Y ) = S

4) TOP ( PUSH(S,X) ) = X

Which of the following cannot be defined using the above definition.

Ans TOP ( POP ( PUSH(E,X),y ) ) = X

11) Binary search on a sorted ascending order arrey. Find average

search time ( pgm given )

A[1..N] middle most number m

12) If m <= n is replaced in above pgm by m < n when will it affect

search?

13) Linked list, First & Last pointers given. What operation depends on

length of list

Ans : Deleting last element.

14) Two relation given

R T

---------------- --------------- RT => relation => (a,b,c)

A | B B | C where (a,b) E R,(b,c) E T.

---------------- ---------------

2 | 3 3 | 4

4 | 5 3 | 2

Page 119: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 119

What are the possible values of (a,b,c)

15) BIG = A[1]

for i=2 to N do if A[i] > BIG

then BIG = A[i]

In the above pgm if biggest no. can be aywhere in A[1..N] with

equal probability. Find average number of execution of stmt

BIG = A[i].

16) NDFA given

which of the following does it accept. ( see the QB original )

Ans : 100100

17) DFA given

accepts

*

Ans 1(01) 0 (see the QB original)

18) BEGIN

b:= a+b+c+d+e

if c > 0 then d:= a+b+c+e

else c:= a+b+d+e

z := a+b+c+d+e

END

What can be taken out of compound stmt with out any problem.

Ans : a+e

19) Two types of instructions format

---------------------- ---------- -------------

| | instr | operd | | | | | | |.. | |

---------------------- ---------- -------------

->3 bits<- -> 6bits <-

How many instruction are possible.

Ans : 2**3 + 2**6 = 72.

20) A1 = A - a1 A2 = A - b1

A1 = A1 + 10 - a2 A2 = A2 + 20 - b2

A = A1 - a3 A = A2 - b3

Stmt a1,a2,a3 must be in that order but not necessarily together.

Same for b1,b2,b3.

On how many ways can A be incremented by 30?

21) In how many ways can A be incr by 10?

Page 120: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 120

22) Consider a linked list

----- --- -----

---->|i-1|-->|i|---->|i+1|---->after

----- --- ----- next[j] := next[i]

----- next[i] := j

| j |

-----

what happends to j?

23) One problem on micro programming

24) One problem on KWIC indexing

25) stack prblem: MUL or ADD pops top 2 values, perfoms operation

& pushes back value.

STORE pops one value and stores

push A

push B

mul

store T1 What is the value of T2?

push T1 ( in terms of a,b,c,d)

push T1

mul

push c

mul

push d

add

store T2

halt

26) Vector a[j] j = 0 to n

k := 0;

for j:= 1 to n do

if a[j] <= a[k] then

j := j + 1;

else

begin

k := j;

j := j+1;

end;

Page 121: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 121

-------------------------------

k := 0

for j := 1 to n do

if a[j] >= a[k] then

begin

k := j;

j := j + 1;

end

else

j := j + 1;

(i) k's are same for both

(ii) k's are not necessarily the same

(iii) k is the same if no two a[j]'s are same

(iv) k's are different only if two a[j]'s are same

27) Ackerman function

A(1,y) = ?

(a) 2 (b) y+1 (c) y+2

28) 2 way 2 state logic 3 input x,a,b output is 0,1,X,X depending

upon 4 combination of a,b. possible boolean are

_ _

(i) (a+x)(b+x) (ii) ax + bx

_

(iii) abx + abx

(a) (i) (b) (ii) (c) (iii) only (d) (i)&(ii)

(e) (i),(ii)&(iii)

29) sequence i, i+2, i+2x .... j where j <= F

and j+x > F if there is a stmt

FOR k := i to F step x

how many times is the loop executed

Ans : j-i/x + 1

30) Define factional( don't ask me what this word means) for reals as

(n)

X = X(X-1)(X-2).....(X-n+1)

(n) (n)

find (X+1) - X

Page 122: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 122

(n-1)

Ans : nX

31) PROCEDURE L2

VAR V; Role of U in the segment

PROCEDURE L1

VAR U; (a) global

BEGIN (b) local

. (c) parameter

. (d) shared [concurrent process]

.

END

BEGIN

.

.

.

END

32) STACK is implemented by array

stack[1..N] define pop & push as follows

procedure pop( var loc:integer)

begin

loc := stack[top];

decrement(top);

end;

procedure push( var loc:integer)

begin

increment(top);

stack[top] := loc

end;

which of the following will preserve the stack property

(i) interchange pop & push

(ii) interchange order of statement in both pop & push

(iii) interchange increment & decrement

(a) i (b) ii (c) iii (d) ii&iii

33) -----<----------- ->-----

| 0 | | | 1,0

Page 123: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 123

----- 0 ----- ----- 1 ----- |

| A |--->-------| B | | C |----->-----| D |--

----- ----- ----- -----

| | | 1 | | |

| | -------->------- | |

| | 0 | |

| --------------------------------- |

| 1 |

--------------------------------------------------

Find the regular grammar.

34) Minium number of states in a DFA that generates the expression

* *

( 0 + 1 ) 111

35) -----------------------

| 1 | 1010101 | 11000 |

-----------------------

Normalised floating pt no with implied (***) base 2 excess 64

exp. What no. is this

-0.875 X 2**21

36) Min height of binary search tree -- --

| n | | n | | n+1 |

a) | log | b) | log |+1 c) | log |

| 2 | | 2 | | 2 |

-- -- -- --

37) redundancy of terminals, non terminals

38) S->rl | r <S> l | <S><S>

which of the following string can be generated.

39) Disk - 2 questions

1. storage capacity.

2. time for operation other than transfer of data.

40) Seven segment display.

41) Define stack as

E is a stack

push (s,x) is a stack

top ( push(s,x) ) = x

[ question not given ]

Page 124: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 124

_ _

42) implement AB + AC using NOR or NAND

43) var i,p : integer;

procedure k;

begin

i := i + 1;

k := i;

end;

begin

i := 1;

p := k + i;

end.

What is p after execution?

GURUJIEND

------------------------------------------

AGRE17.TXT

------------------------------------------

/* K.SRIKANTH */

KSRIBEGIN

1) function A(L:list)

begin

if length(L) == 2

then A = sum of the elements of the list

else

begin

L1 = First half of L;

L2 = second and third quarters of L;

L3 = second half of L;

A = A(L1) + A(L2) + A(L3);

end

end.

What is A for the input list (1 2 3 4 5 6 7 8)

Ans : 81

2) procedure P(N,A,B,C)

begin

Page 125: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 125

if N <> 0

then

begin

P(N-1, A, C, B);

writeln(A, B, C);

P(N-1, C, B, A);

end

end.

In the call " P(4, A, B, C) ", how many writelns are made ?

Ans : 15

3) var m,n : integer

v : array[1..100] of integer;

procedure p(var i,j:integer)

begin

i = j+2;

j = j+2;

end;

A compiler writer makes the mistake of implementing VAR parameter

passing as call by value-result with left to right copy back instead of

as call by reference.Which of the following 5 calls will detect the

mistake? (Assume that array bound errors are not an issue)

i] p(m,m) ii] p(m,n) iii] p(m,v[m]) iv] p(v[m],v[n])

Ans : [iii]

4) The block takes two inputs and computes the MAX and MIN

_____

a ---| |--- c = MAX(a,b)

b ---| |--- d = MIN(a,b)

-----

_____

---| |-------------------y1 I) y1 >= y2

---| |--------| _____ II) y1 >= y3

----- ----| |--y2 III) y1 >= y4

----| |--y3

_____ | -----

---| |--------|

---| |-------------------y4

Page 126: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 126

-----

Which of the following is true

i] I only ii] II only iii] III only iv] II & III v]

I,II,III

Ans : [ii]

5) A network line can transmit data at the rate of 10^7 bits/sec. The hosts at

the

end of line can take in data at the rate of 1 word ( 8 bits ) every 2

microseconds

Because of this, a memory has to be kept which is organized as a queue to store

the received data. If a data packet is 1000 words, what is the maximum size of

the

buffer?

i] 400 words ii] 2500 w CHAR BAords iii] 600 words iv] 1200 words v]

1000 words

Ans : [iii]

KSRIEND

------------------------------------------

AGRE18.TXT

------------------------------------------

/* C.N.RAMESH */

CNRBEGIN

1) Components A & B , Machine languages MA & MB and Assembly languages LA & LB.

Cross assembler for B running on A is :

a) LA to MA b) LB to MB c) LA to MA and LA

d) LA to MA and MB e) LB to MA.

2) There are two computers running on a machine . One computes very fast, but

doesn't produce an optimal code. The other computes slowly but produces

optimal code. The former is preferred over the latter when

a) the program is short (only a few pages long)

b) the program is being debugged

c) there are few arithmetic operations

d) there are few subroutine calls

e) there are very few arrays in the program

3)

--------------<----------------

Page 127: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 127

| |

| 0/0 0/0 |

-->----O----->-------O--------->-----O

| / \ |

| / \ |

V V | |

| \ / |

|------->----\O/--------<-----|

/ \

/ \

\___/ 0/1

Given an input string , find the output

4) (Same figure) For an input struing of 15 , the maximum number of 1's

that could be obtained in output = ?

5) The number of distinct strings of length 3 , that can be obtained using

the letters a,a,b,b,c.

a) 7 b) 6 c) 12 d) 15 e) 18

6) The following represents a linked list

-->-- --->--- --->--- --->---

| \ / \ / \ /

| O O O ......

| / \ / \ / \

--<-- ---<--- ---<--- ---<---

This represents

a) a circular list b) a test structure in which any node can be accessed

from any other c) an acyclic graph

d) a binary tree e) none of the above

7) a i a 5i

F(x) = E x ; G(x) = E x /* E = Sigma */

i = 0 i = 0

a i

F(x).G(x) = E A . x , then A is

i = 0 i i

a) | i/5 | b) | i/5 | + 1 c) -- -- d) -- --

-- -- -- -- | i/5 | | i/5 | - 1

Page 128: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 128

e) | i + 1 |

| ----- |

| 5 |

-- --

8) delta ( x ) = x - x then the highest subscript of x that

j j+1 j

k

appears in delta (x )

j

( k k-1 k-1

defined as delta (x ) = delta ( x ) - delta (x )

j j+1 j

) is

a) k + j -1 b) k + j c) k + j + 1 d) k + 1 e) j + 1

9) In a connection of n processors find the minimum number of connections

needed to provide 2 distinct paths between any two processors.

n

a) 2 b) n c) n + 1 d) n ( n + 1 ) e) n - 1

-----------

2

k j

1) If N = E b . 2 ( k is integer > 1) then for i <= k,

j=1 j

what is the value of

i

| N/ (2) + 1/2 |

-- --

a) k j-i b) k j-i-1

E b . 2 + b E b . 2 + b

j=i j i-1 j=i j i-1

c) k j-i-1 d) k j-i

E b . 2 E b . 2

j=i j j=i j

Ans. = a)

2) With respect to compilers and interpreters, which of the following is

slash or true

Page 129: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 129

i) Syntax analysis is done by compilers but not in interpreters

ii) A program compiled can be interpreted

iii) Interpreters can always be written in high level language, but

compilers can be written either in high level or assembly language

a) i) only b) ii) only c) iii) only d) i) & ii) e) ii) & iii)

3) |

________V________

| 512 words |

| of |-- Chip select

| 8 bits |

|_______________|

|

V

What is is the use of the chip select -

No. of terminals (pairs) excluding ground & power supply

4) Give the regular expression for a string having exactly two

consecutive 1's

* * * * *

a) 0 11 ( 0 + 01) (1 + 0) b) (0 + 10) 11 (01 + 0)

* *

c) ( 0 + 01) 11 (01 + 0)

5) What is the best string implementation for the operation :

" Insert a character next to the one pointed to by p "

Assuming that P is already set.

a) Sequential locations with 1 character / word

b) Sequential locations with > 1 character / word

c) Singly linked list with 1 character /word

d) Singly linked list with > 1 character /word

c) Doubly linked list with 1 character /word

6) Figure.

How does the output change when c changes from 0 to 1

__ __

a) (x1, x2) --> (x1 , x2) b) (x1, x2) --> (x2, x1)

__ __ __ __

c) (x2,x1) --> (x1, x2) d) (x2,x1) --> (x2, x1)

Page 130: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 130

7) LOAD A

MULT A

STORE T1

LOAD B

MULT B

STORE T2

MULT T2

ADD T1

What is the result in the accumulator �? 2 2

a) (a + b)t1 + b b) a + n b

2 4

c) a + b

8) If A > B then V := F(I)

Else If B > C then V := G(I)

If A > B 75% of the times and B > C 25 % of the time and the segment

is executed 10000 times in all, how many times are functions F & G called

a) 7500 : 625 b) 7500 : 2500 c) 9375 : 625

9) Equivalent of WHILE a DO g in FORTRAN is

a)

10: IF (a) GOTO 20

g

GOTO 10

20: CONTINUE

b)

10: IF ( ~a ) GOTO 20

g

GOTO 10

20: CONTINUE

10) Computer with 36 bit word characters take 8 bits. While storing strings

characters are packed into double words. If necessary the string is

padded with blanks on the right to nearest word boundary. How many

words does a string with k characters require ?

a) 2 | k/a | b) | k/a| c) | 2k/a| d) -- -- e) -- --

-- -- -- -- -- -- 2| k/a | | -2k/a|

11) DO 10 I = 1 , N

Page 131: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 131

DO 20 J = I , N

20 A = B

DO 30 K = 1 , N

30 B = C

10 CONTINUE

How many assignment steps are executed in terms of N

12) Ith power of A is to be calculated. A is real, I is integer,

M is real number multiplication time, L is log calculation time,

E is exponent calculation time. What condition must be satisfied so

that using log & exponentiation is faster than repeated multiplication

a) L + E < M.I b) L + E < M(I - 1) c) L + E < M( I-2)

d) L + E < M(I+1) e) L + E < M(I + 2)

13) Gaussian elimination technique NxN matrice. If multiplication &

addition are to be considered 1 operation each, approximately how

many operations are required ?

2 3 3 4 3

a) N b) 2 N c) N d) N e) 4 N

--- --- ----

3 3 3

14) A multiprocessor is

a) more than 1 processor working on a program

b) more than 1 program on a processor

CNREND

------------------------------------------

AGRE19.TXT

------------------------------------------

AGRE QUESTION BANK - MATERIAL TYPED BY V.BHARGHAVAN.

BAPUBEGIN

1. a. p => !p

b. (p => !p) || (!p => p)

Which is satisfiable and which is valid.

2. +----------+

|0 0|A

|0 1|B

|1 0|C

|1 1|D

Page 132: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 132

+----------+

S0 S1

S0 = x

S1 = y

M = (x xor y) xor z

Find A,B,C,D

3. f : aXa --> a

can be broken down to ??

4. a. T(n) = 2T(n - 2) + 1

b. T(n) = T(n - 1) + n*n

c. T(n) = T(7n/8) + c

Which results in a non-polynomial.

5. Function color(node)

{

if node has label giving color

color of node = given color.

else

color of node = color(parent)

}

|blue|

------------------------

| |

| red | | |

---------------- ----------------------

| | | |

| | NULL |blue| | red |

------------- ------------------

|blue| | | | | | |

find nodes with red color.

In a database with data items, to allow concurrency, locking of data item is

provided. Locking is coarse if % of loacked data items is high and fine if the

% is low. Consider the grapg : Throughput vs Coarseness.

|

| B

| / \

| / \

Page 133: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 133

| / \

| / \

| A C

+-------------------------------

6. Throughput increases with coarseness from A to B because

a. Overhead of loacking decreases

b. ----------do ------- increases.

c. Concurrency decreases.

d. ----------- increases.

7. system throughput decreases from B to C because

a. b. c. d. and

e. No of trans/sec increases.

8. In a computer it was seen that Gaussian elimination for 100X100 matrix

takes 1 sec. What will approximately be time for 500X500 matrix?

1 sec, 5 sec, 25 sec, 125 sec, 625 sec.

9. [ -3..2, 5..7] is an array of bytes in a byte addressable m/c.

Loc[i,j] = Loc[L1,L2] + (i - L1) * mult1 + (j - L2) * mult2.

where mult(i) is the change in address when i alone is changed. To minimize

computation, origin = 0,0.

Then the value of the given array is :

a. Loc[-3,5] + 14

b. Loc[-3,5] + 9

c. Loc[-3,5] + 4

d. Loc[-3,5] - 3

e. Loc[-3,5] - 5

A directed graph is represented by an adjecency matrix A{1..n,1..n]

Findsquarecomputes A*A + A and stores it in A.

In the graph, it computes the path of length 2 also in the graph and adds them

to the edges in the graph.

Some question on this.

11 .to get the transitive closure, we execute

for i = 1 to k

findsquare(A).

What is the minimum k to get the transitive closure.

12. Given a single accumulator m/c, stack based impl. with instructions store,

pop, push, add, mul, sub. How many instructions are needed to execute

Page 134: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 134

G = (A+B) * C - (D+E) * D.

13. What paging strategy ensures minimum page faults?

14. Hashing function with closed hash table.

h(i) = i mod 5. Locns. numbered from 0 to 4.

Given the following numbers 13,8,24,10,3

Where will 3 land up?

15. Which of this is not generated by a FSA.

0**i1**j i>j. etc....

Fn X(N)

if N < 3, X = 1.

else X = X(N - 1) + X(N - 3) + 1.

16. X(X(5)). How many timnes is X called.

17. As a function of N, how many times is X called.

18. As a function of X(N) how many times is X called.

19. x = 3**(5 ** 64)) mod 7

y = 3**(5 ** 64)) mod 9

a. x + y <> (Y + x) mod 63.

b. xy <> yx mod 63.

c. exists z, z = x mod 7 and z = y mod 9.

d. exists y, xy mod 9 = 1.

20. What is the way of parameter passing if G(5) is execvuted and the program

terminates.

Fn f(i,k)

if i < 3, f = k. else f = 1.

Fn G(x)

G = f(x,x*G(x - 1)).

Call by a. name, b. need, c. value, d. reference.

21. What are static and dynamic referencing? Some question on that.

Rather incomprehensible.

23. 1/ (1 - 2z generates

1,2,4,8,16...

What generates 1,1,2,2,3,3,4,4,,....

24. Sally, Sue (Same group)

Ted (S.U)

Which of the following are inconsistant .

Page 135: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 135

Choices..... (Not given in text)

25. A 3 way associative cache.

a. Is more complex than a 4 way cache.

b. Is faster than a direct mapped cache.

c. Is one in which each main mem address maps to a 3 way cache.

d. Is insuffucuent unless 3 processors are alternating.

27. A question on gates.

F = Block1(X,A,B)

G = Block2(B,Y,Z)

H,C0 = Adder(F,G)

F = X'A + XB

G = Y(B xorZ)

Which cannot be obtained?

A,B,A-B,A+B+1,A-B+1

28. Is resolution sound and Complete?

29. Some question on Pure Memory segmenting.

No question No answer.

30. Complexity of Decryption.

31. Some circuit was given and asked to find the delay for the output.

No question on text.

32. Given two grammars generating a**nb**n and a**m,

Are they LR(k) grammars and find the value of k.

33. What kind of a graph is it?

Vertex set = a,b,c,d,e,f.

Edge set = a:b, b:c, c:a, e:a, d:e, d:f, f:c, b:f, b:e.

35. Given some running time complexity for various inputs, find the

complexity of the algo.

36. No of iterations reqd. by Newton-Raphston method to converge.

37. If there are n points and interpolation is done. what is the

order of the resulting equation?

38. Max edges in a DAG.

39. Length of longest path in a DAG.

40. No of nodes to represent : do,dog, door, doors.

41. Enumeration of all words in a trie.

Page 136: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 136

BAPUEND

------------------------------------------

AGRE20.TXT

------------------------------------------

/* T. ARUL SEELAN */

CPBEGIN

1.

Equivalent of WHILE (a) DO r in FORTRAN is

(a) 10 If (a) GO TO 20

r

GO TO 10

20 CONTINUE

(b) 10 IF (~a) GO TO 20

r

GO TO 10

20 CONTINUE

2. Computer with 36 bit word. Characters take 8 bits.While storing

strings chars are packed into double words. If necessary

the string is padded with blanks on the right to the nearest word

boundary. How many words does a string with k characters require?

(a)2(floor)(k/a) (b) (floor)(k/a) (c) (floor)(2k/a)

(d) 2(ceiling)(k/a) (e) (ceiling(2k/a)

3.DO 10 I = 1, N

DO 20 J = 1,N

20 A = B

DO 30 K = 1,N

30 B = C

10 CONTINUE

How many assignment steps are executedd in terms of N?

4. Ith power of A is to be calculated. A is real, I is integer

M is real no. multiplication time, L is log calculation time,

E is exp calculation time. What condition must be satisfied

so that using log and exponentiation is faster than repeated

multiplication?

Page 137: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 137

(a) L + E < MI (b) L + E < M(I-1) (c) L+E < M(I-2)

(d) L+E < M(I+1) (e) L+E < M(I+2)

5.Gaussian elemination technique n x n matrices. If mult and addition

are to be considered one oprn. each approx how many oprns. are reqd?

(a) n ** 2 (b) 2*(n**3)/3 (c) n**3 /3 (d) n**4 (e) 4* (n**3) /3

6.A multiprocessor is

(a) more than 1 processor working on a program

(b) more than 1 program on a processor

7. IF A > B THEN X = A;

If after executing this X = A is the predicate that is

reqd to be true, what is the weakest predicate that is reqd. to

be true before executing this segment.

(a) b > a (b) a > b (c) x > b (d) (a>b) or (x = a) (e)(x=a) and (a>b)

8.A relation is given by

R = { (a,a),(a,b) ,(b,a),(b,b),(c,c) }

Which of the following are true about R ?

1) refl. 2)antisymm. 3)symm. 4)trans.

(a)1 & 3 (b) 1 &2 (c)1 & 4 (d)1,3 & 4 (e) 1,2 & 4

9. The foll. are defined on strings

HD(X) : first char. of X

TL(X) : string remaining after removing HD(X)

JOIN(X,Y) : concat of X & Y

Which of the foll. are true?

(a)JOIN( HD(X),TL(X) ) = (JOIN TL(X) , HD(X) )

(B) JOIN( HD(X) , TL(X) ) = X

10.What is the recursive defn. of REV(X)

(reverse of a string)

(a) REV(X) = REV( JOIN( HD(X),TL(X) ))

(b) REV(X) = REV( JOIN (TL(X) , HD(X) ))

(c) REV(X) = JOIN ( REV(TL(X)), ( HD(X))

(d) REV(X) = JOIN ( HD(X) , REV(TL(X)) )

11. P := if x even then (x/2)

else P(P(3x+1))

If x = (2**k) + 1 & k>2 the value of P is

(a) 3*(2**(k-1)) + 1 (b) 3*(2**(k-2)) + 1 (c) 3*(2**k) + 1

Page 138: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 138

(d) 3*(2**(k+1)) + 1 (e) 3*(2**(k-1)) + 2 ans : b

12. F(0) = 1; F(1) = 3

F(X) = 3F(X-1) + F(X-2) X >= 2

What is F(5)? ans : 360

13. S -> SS|(S)|S*|S+S|a|b

ab* + ba is the string to be generated using left recursion only.

How many distinct derivation trees are possible?

(a) 1 (B) 2 (c) 3 (d) 4 (e) 5 ans : b

14. S -> SS | a

Which of the foll. is true?

1) it is left recursive

2) it is rt. "

3) it is ambiguous

(a) 1 (b) 2 (c) 3 (d) 1, 2 & 3 ( e) 1 & 2

ans : d

15. The no. of permutations of COFFEE ---- 180

16. Define a valid substring as a vowel followed by a 1 or more letters

followed by a vowel. How many substrings are there in FACETIOUS.

ans : 8

17. Give a permutation P

1 2 3 4 5

P = ( )

2 1 5 3 4

What is (P**2)?

18. What is the reason for using a 256 x 256 array for image processing

instead of 1024 x 1024 array

1) faster processing 2) higher resolution 3) more contrast

(a) 1 (b) 2 (c) 3 (d) 1 & 3 (e) 2 & 3

19. z <- 0

p <- x

q <- y

*while p >0 do

begin

z <- z + y

p <- p - 1

end

Page 139: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 139

1) Find loop invariant for this pt *

xy = z + py

z = (x-p)y

2) How many assignment statements are made including p <- p - 1

(2*x) + 3

20. What is the FSA that accepts the regular set given by

the reg. exp (ab)*(cd)*?

21.Game tree

|---|

| 0 |

|---|

22. A system has 4 tape drives. The foll. set of jobs have demand

for tape drives as shown

w : 1; x : 2; y : 3; z : 4;

Which of the foll. combinations of jobs may give rise to dead lock

1)y 2) wy 3) xyz

(a) 1 (b) 2 (c) 3 (d) 2 & 3 (e) none

23. The foll. processes exist in the process Q. The max completion

times are given

p1 - 2 units; p2 - 3 units; p3 - 4 units; p4 - 1 unit; p5 - 6 units

What is the mean time of completion of each process?

24. Z <- Ax | By

A <- Ay | y

B <- x | y

What is the reg. exp for the set of strings generated by the grammar?

25.Let Q[M,N] be the # ways of writing the integer M as a sum if integers

<= N

Def : Q[M,N] = 1 Q[M,N] = Q[M,M] if M < N

Complete the def. expressing Q[M,N] in terms of Q[M-1,N-1],Q[M,N-1] etc.

26. S -> S + T | T

T -> a | S

Which of the foll. tress represent valod derivations of the strings a+a+a

S S S

/ | \ /|\ /|\

/ | \ / | \ / | \

S + \T S + T S + T

Page 140: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 140

/|\ | /|\ | | |

/ | \ | / | \ a T S

S + T a T + T |

| | | a / + \

T a a S T

| | |

a T a

|

a

27.A dept. store has 2,00,000 customers. A data base is maintained.

Each customer record contains his name and a variable # attributes which

are the no. of items he has purchased that month. At the end of the month

the file is processed and a bill is sent to each customer. Updates are done

once a month, and slso when the store purchases special items ( > once a

month). The store finds out which customers have requested the items and

sends info. to them. What kind of file system would be best for the above

application .

(a) Indexed seq. file on name key with inverse file.

(b) Seq. file " " " " " "

28. T1 BUS -> ADDRESS

T2 REQ -> ON

T3 ACK -> ON

T4 BUS -> FLOAT

T5 BUS -> DATA

T6 ACK -> OFF

T7 REQ -> OFF

T8 BUS -> FLOAT

THE FOLL.is the symbolic program for the UNIBUS for communication between

a master device and a slave device. Assume that the master is the CPU and the

slave is one of the peripheral devices. The prog. is of WRITE op. Interchange

2 statements to convert the prog. to READ.

(a) T1 & T2 (b) ..

29. Assume master is CPU and slave is memory. If the memoroy access time

changes, which time difference changes

(a) T1 to T3 (b) T3 to T4 (c) T4 to T6

30. A diagraph has the foll. adjacency matrix

Page 141: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 141

A B C D

A| 1 1 0 0 |

B| 0 1 0 1 |

C| 0 1 1 1 |

D| 1 0 0 1 |

The corresponding relation is

1) refl. 2) symm. 3) antisymm.

(a) 1 (b) 2 (c) 3 (d) 1 & 2 (e) 1 & 3

31. What is the expected length of search for an item on the

binary trees

(4)

/ \

/ \

(2) (3)

/\ /\

/ \ / \

(8) (1) (7) (9)

/

/

(10)

32. In a binary tree with nodes , what is the avg. search time?

33. How many ht. balanced binary trees with 5 nodes are there ?

34. INPUT

||

|----------|

| |--- READ

INC --->| MEMORY |

| |--- WRITE

DEC --->|----------|

||

||

OUTPUT

the foll. sequence of oprns. os valid

1) Inc. addr pointer and enable read

2) Dec. addr pointer and enable write

What does this addressing system implement

Page 142: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 142

(a) stack (b) queue (c) list (d) dequeue

35. when is the memory empty

(a) after (n+1) reads (b) after ...

36. Given a machine with only a stack whose top can be outputted

and on which POP and PUSH are allowed. which of the foll. strings

can be sorted in ascending order

(a) 4312 (b) 3421 (c) 2134 (d) 1243 (e) 3142

37. Define vector v[a:b]. Each element occupies 2 words. If addr.

of v[a] is denoted by A v[a], what is the addr. of the first

word of v[i]

(a) ( A v[a]-2a) - 2ri (b) ( A v[a] - 1) - i A v[a] +2(i-a)

38. An array A[1:8;-2:2;1:5] with 1 word elements reqd. how many locns

reqd. for storage?

39.If A[1,-2,3] is in location 2000 to the base 10 where is A[30,5]?

40.What is the min. hardware reqd for a parity bit generator when the

bits come in serial order

(a) EXOR gates : 1 for each pair of bits

(b) 4 EXOR gates (c) AND gates (d) TOGGLE flip-flop which acts a

mod 2 counter

41.

|--------------------------------------------------------|

| |--------| |--------|0 |--------|0 |

---|D Qa |-------|D Qa |-------|D Qa |--| NOT|--|

-----|clk | |---|clk | |---|clk |

| |--------| | |--------| | |--------|

| | |

|----------------------------------|

Total ring counter implemented by D FFs of initial state is

(Qa Qb Qc) = (1,0,0)

What is the state after 8 clock pulses?

42.What si the time about C, the cost of replacement policy (which

is given as the no. of page faults for a particular reference string?

(a) C(LRU) always < C(FIFO)

(b) C(LRU) always > C(FIFO)

(c) C(LRU) always = C(FIFO)

(d) can't be answered

Page 143: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 143

43.A system has 3 page frames in main memory and uses LRU replacement

policy with the foll. reference string. What is the state of main memory

(the pages existing) after the 5th page fault?

1223413121

44. a & b are 2 nos. such that a >> b. ab, (a+b), (a-b) are given.

What is the best way of calculating a & b?

1) 1/2[(a+b) + (a-b)] , 1/2[(a+b) - (a-b)]

2) 1/2[(a+b) + (a-b)] , ab/a

45. z := 1

x := p

y := q

while (y > 0) do begin

if odd (y) then z:= z * x;

y := y div 2;

x := x * x;

end

If q =13 what is the sequence of values z takes until the program halts?

CPEND

Page 144: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 144

------------------------------------------

AGRE21.TXT

------------------------------------------

/* P. SRINATH */

WOODYBEGIN

AGRE Questions 70..109(march ,86)

_________________________________

70) What is the ratio of the number of characters needed for integer

'a' in bases 'b' and 'c' ?

Ans: ceiling(log a (base b))/ceiling(log a (base c))

71) [[set A XOR set B]-set C] =? Ans: Only non_common elements.

73) 84(base 16) +121(base 4) =? Ans: 2131(base 4)

74) The minimum height of a binary search tree is

a)[ceiling(log to base 2 (n+1))] b)floor(log to base 2 (n))

c)floor(log to base 2 (n)) + 1

75) var i,p:integer

fn k

begin

i=i+1;

k=k+1;

end

begin

i=1;

p=k+i;

end

What is the value of k? Ans: 5.

76) Horner's rule :

Pn(x)=A0 + A1x + A2x^2 +....+ Anx^n

(...((Anx + An-1)x + An-2)x.....)x + A0 minimises

the number of multiplications.

77) If N=Summation(1 to k) of B(i)2^i (k>1)

then for i<= k what is the value of floor(N/2^i +1/2). Bi=0 or 1.

Ans: Summation(i to k) B(j)*2^(j-1) + B(i-1)

Page 145: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 145

78) With respect to compilers and interpreters which of the following

is true ?

1)Syntax analysis is done by compilers but not by interpreters.

2)A program that can be compiled can be interpreted .

3)Interpreters are always written in a high level language but

compilers are written in high or assembly language.

Ans: 2.

79)

|

|address

__\|/_____

| |

| |

|512 words| <-----chip select

| |

|_________|

|

\|/

data(8 bits)

1)What is the use of chip select ?

Ans.: To increase the address space .

2)No. of pins excluding power ?

Ans.: 18

79) a)Give a regular expression containing exactly 2 consecutive 1s .

b) No 2 consecutive 1s.

Ans: a) (0 + 10)*11(01 + 0)* b)(0 + 10)* + (0 +01)*

80) What is the best representation for strings for the operation

'Insert a character next to the one pointed by P'?

a) Sequential locations -1 char. per word.

b) " " >1 " "

c)Singly linked list - 1 char. per word.

d) " " " - > 1 " " .

e)Doubly " " -1 char. per word.

Page 146: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 146

Ans:c).

81)

82) LOAD A

MULT A

STORE T2

LOAD B

MULT B

STORE T2

MULT T2

ADD T1

What is the result of the above program?

Ans: B^4 + A^2

83) What is the equivalent statement of 'while A do B ' in Fortran?

Ans:

10 if (not A) goto 20

B

goto 10

20 continue

84) do 10 i= 1,N

do 20 j= 1,N

20 A=B

do 30 k= 1,N

30 B=C

10 continue

How many assignments are executed?

Ans: N(3N + 1)

85) I-th power of A is to be calculated.

A is real and I is an integer.

M: real multiplication time.

L: logarithm evaluation time.

E: exponentiation time.

If using algorithms should be more efficient , which of the following

is true?

Ans: L + E < M(I - 2).

Page 147: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 147

86) In a memory scheme ,the address of a location is specified by

a page address and a displacement within a page , in hexadecimal.

# of pages = 16.

# of words per page = 256.

The address of the 11th page,94th word is :

1.B5E

2.A5D

3.5EB

4.E9C

Ans: 1

87) procedure ZAP(n)

begin

if n<= 1 then zap=1;

else zap = ZAP(n-1) + ZAP(n-3);

end

Find zap(6).

Ans: 9.

88) F(x)= if odd(x) then (x-1)/2

else F(F(x-1)).

Find F(16).

Ans: 3.

89) In bubble sort ,the number of operations needed is :

a) 2N b) N(N-1)/2 c) N(N+1)/2 d) N^2 e) N-1

Ans: 2

90) No. of productions used to generate a string of length x

for a grammer in CNF is :

a)x+1 b)x c)2x d)2x-1 e)x^2

Ans: d

91) A 2,3 tree is a tree in which every node has either 1,2 or 3 sons,

except the leaves, and also has equel path length from root to any

leaf. The number of leaves is 9 . The number of internal nodes

could be :

a) 7 b) 8 c) 9 d) 6 e) 3

92) Solution of :

T(n)= 2T(n/2) + n ,n>1

Page 148: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 148

= 1 ,n=1

a) nlogn + n b) n^2 c) nlogn -n +2 d) n+1 e) n+3

Ans: a

93) There are 2 resources R1 and R2 and two processors P1 and P2.

A directed graph represention :

Pi-->Ri means Pi requests Ri;

Ri--> Pi means Ri is alloted to Pi;

Which of the following diagrams represents a possible deadlock?

a) R1--> P1--> R2

|____>P2____>|

94) Given

x -2 0 2 4

f(x) 3 5 6 12

find f(2.4) by linear interpolation.

Ans: 7.2

95)

96) What is the reason for using a 256 * 256 array for image processing

instead of a 1024 * 1024 array?

Ans: 1) faster processing 2) higher resolution

3) more contrast/brightness

97) A system has 4 tape drives . The following set of jobs have demand

for tape drives as shown:

W-->1 X-->2 Y-->3 Z-->4

Which of the following combinations may give rise to deadlock?

1) Y 2) WY 3) WYZ

Ans: a)1 b)2 c)3 d)2 & 3 e)none

98) The following processes exist in the process queue . Completion times

required are

P1:2 P2:3 P3:4 P4:1 P5:6

What is the mean completion time? Ans: 7.2

99) Z--> Ax|By

A--> Ay|y

B--> x|y

What is the regular expression for the set of strings generated by

the grammer?

Page 149: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 149

Ans: xy + yy + y(y)*x

100) S--> S+T | T

T--> a | s

Which of the following is a valid derivative tree for a+a+a?

1) S 2) S 3) S

/|\ /|\ /|\

S + T S + T S + a

| \ /|\ \ /|\

T S S + T a T + T

| /|\ | | | |

a S + T T a a a

| | |

T a a

|

a

Ans: 1 & 2 ?

101) The following is a symbolic program for unibus communication between a

master and a slave . Assume CPU and a peripheral ,say and the

operation is write . Interchange any two statements to make a read .

T1: BUS --> address

T2: REQ --> on

T3: ACK --> on

T4: BUS --> float

T5: BUS --> data

T6: ACK --> off

T7: REQ --> off

T8: BUS --> float

Ans: T5 & T6 1) T1 & T5 2) T5 & T8

102) Which interval is affected by removing access time variations?

Ans: T5 to T6

103) Recurrence relation for Q(m,n)-->Number of ways of writing M as a

sum of integers <= N ; is as follows:

Q(m,1)=1;

Q(m,n)=Q(m,m) if m<n;

Page 150: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 150

Complete the definition.

Ans: Q(m,n)=Q(m,n-1)+Q(m-n,n-1) if m>=n;

104) A digraph has the following adjacency matrix. Is it

1)reflexive 2)antisymmetric 3)symmetric ?

1 1 0 0

0 1 0 1

0 1 1 1

1 0 0 1

Ans: 1) & 3)

105) ***************

106) ***************

107) In a binary tree with n nodes what is the average search time?

1)n 2) logn 3)n^2

Ans:2)

108) How many height-balanced trees with ? nodes are there ?

Ans: 6.

109) || I/P

\/

INC _____________

------->| |--->READ

| |

------->|____________|--->WRITE

DEC

|| O/P

\/

The following sequence of operations is valid :

1)Increment address pointer and enable read.

2)Enable write and decrement address pointer.

What does this implement?

1)stack 2)queue 3)list 4)deque

Ans:stack

WOODYEND

------------------------------------------

AGRE22.TXT

------------------------------------------

Page 151: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 151

/* Snoopy Narasimhan */

THIS PART OF THE QB IS BROUGHT TO YOU BY SNOOPY. IF YOU FIND THE

QUESTIONS STIMULATING SEND YOUR CONTRIBUTIONS WITHOUT FAIL TO

302 , MANDAK .

-- SNOOPY

****************************************************************************

Two compilers. First one is fast but does not produce

the optimal code. The second one is slow but produces optimal code.

The former is preferred when

a) The pgm. is short (only a few pages)

b) The pgm is being debugged

c) There are few arithmetic operations

d) There are few sub-routine calls

e) There are few arrays in the pgm.

**************************************************************************

Given a DFA (a GSH) and an input string find the output

ans: 00100 0 -------> 0 <------- 0

| | | ^

---------- 0 ---------|

***************************************************************************

for the above problem ,for an input string of length 15 the max. no.

of 1's that could be obtained in the output is

******************************************************************************

The number of distinct strings of length 3 that can be obtained using

a,a,b,b,c is

a) 7

b) 6

c) 12

d) 15

e) 18

ans. 18

***************************************************************************

The following represents a linked list

0 <--------> 0 <---------> 0 <----------> 0

(2-way links)

This represents a

Page 152: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 152

a) A circular list

b) A list structure from which any node can access any other node.

c) An acyclic graph

d) A binary tree

e) None of the above

****************************************************************************

F(x) = SIGMA (x^i) 0 <= i< infinity

G(X) = SIGMA (x^5i) 0 <= i < infinity

F(x) G(x) = SIGMA ( Ai x^i)

Ai is

a) floor(i/5)

b) floor(i/5) + 1

c) ceiling (i/5)

d) ceiling (i/5) - 1

e) floor( (i+1)/5)

***************************************************************************

In connection of n processors find the min. number of connections

needed to provide two distinct paths between any two processors.

a) 2^n

b) n

c) n+1

d) n(n+1)/2

e) n-1

Ans : e

*************************************************************************

In pocket calculators excess-3 code is used instead of BCD because

a) Xs-3 counters are easy to make

b) Xs-3 is a self-complementary code

c) A division by zero can never occur

*************************************************************************

In a linked list with fields 'value' and 'next' , insert

p after q is done by

a) next(p) := next(q);

next(q) := p;

b) next(q) := next(p);

Page 153: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 153

next(p) := q;

***************************************************************************

a := x;

b := y;

p := 0;

while (a>0) {

p := p + b;

a := a - 1;

}

What is the loop invariant ?

ans. p+ab = xy

***************************************************************************

S --> aAa | BDB

A --> aS | c

B --> b|bD

D --> S

What is the min. length string possible ?

ans. 3

What is true about the language generated ?

a) start(first) and end(last) symbols are the same for any string.

b) only odd length strings are generated.

c) consists of atmost one 'c' in any string.

ans. c

************************************************************************

Which of the following does a FSA accept

1) 0^n1^n n>=1

2) a^n b^m m<n

3) balanced paranthesis

4) A string of 0's and 1's and in the prefix the difference between #1's

and #0's is 1.

5) equal no. of 0's and 1's

ans. 4

************************************************************************

temp := a[N] ;

do (i := 1 to N-1 ) {

Page 154: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 154

k := ...... ;

a[k+1] := a[k] ;

}

a[1] := temp ;

The pgm. shifts right by one element a vector a[N].

Fill in the blank.

a) N-i+1

b) i-1

c) N-1

d) N-i

ans. d

***********************************************************************

In the above code if k := .... is deleted and if a[k=1] := a[k] is

replaced by a[i+1] = a[i] , the modified code does the same fn. provided

a) a[i] =0 for i = 1,2,...n

b) a[i] =0 for i = 1,2,...n-1

c) a[i] is not neccesarily zero but some const. for i=1,2,...n-1

d) a[i] are equal for i=2,3..n

ans. c

**********************************************************************

No. of bits needed to address 10,000 words is ...

ans. 14

************************************************************************

no. of comparisions needed to find the max. and the second max. of 4 nos.

is ...

ans. 4

**********************************************************************

5 profs. and 5 courses.Each prof. can't take more than 1 course.

prof courses

A 1,4

B 1,2,3,4

C 1,2,3

D 1,5

E 1,4

Page 155: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 155

Which are true .

1) Prof D has to take 1

2) prof E has to take 4

3) either A or E has to take 1

4) D has to take 5

ans. 3 and 4

*************************************************************************

If P(x) = a0 + a1 x + a2 x^2 + a3 x^3 + ..... an x^n

then

1) It has n real roots

2) Whenever there is a complex root it always has a conjugate

3) It can be expressed as a product of n linear factors in the complex

field.

ans. 2 and 3 only

************************************************************************

Linked lists are prefeered over arrays when ...

ans. there are frequent insertions and deletions

***************************************************************************

what is c - a/b - a when a=4,b=2,c=4 if the exp. is evaluated from right

to left (with ops. right assocoative)

ans. 6

****************************************************************************

Page 156: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 156

The starred univs have to be visited as their addresses werent listed

in Sita's latest list.

[email protected] 98 req.TSE+$13 preapp fee

[email protected] - accepted.req TSE,send 98?-online(http://www.uiuc.edu)

[email protected]

*[email protected] TSE-use

http://coho.grad.washington.edu/isapi/ia/ianew.idc

[email protected]

[email protected] form that they sent (~/Mail/app).

[email protected] -- accepted.

[email protected]

[email protected]

[email protected] -- correct,checked on web

[email protected].

*[email protected] -- requires minimum GPA of 3.5

[email protected],with "no WWW access".

[email protected]

*[email protected] -- changed: [email protected]

[email protected]

[email protected]

[email protected] not printed

[email protected] -- correct-accepted

[email protected] unknown

[email protected] form to be filled,reject on 1997 in subject

*[email protected]

[email protected] -- 10$ preapp fee

[email protected]

[email protected]

[email protected] -- accepted -requires TSE

[email protected]

*[email protected]

[email protected] form for filling.

*[email protected]

Page 157: GRE Subject CS

http://www.cs.rice.edu/~santa/CD/app/A-GRE/ 의모든자료 157

http://www.cse.iitb.ernet.in/docs/pages/node70.html