Docsity

GATE Study Materials, Exercises of Computer Science

Partial preview of the text

Download GATE Study Materials and more Exercises Computer Science in PDF only on Docsity!

byjusexamprep.com

SECTION: GENERAL APTITUDE

1. The expenditure on the project _________ as

follows: equipment Rs.20 lakhs, salaries Rs.

lakhs, and contingency Rs.3 lakhs.

A. break down B. break

C. breaks down D. breaks

Ans. C

Sol.

Break down means to separate something into

smaller parts. The subject-word agreement states

that Singular nouns go with singular verbs while

plural nouns go with plural verbs. Expenditure is

singular noun, and its plural form is expenditures.

The expenditure ( singular noun ) in the project

breaks ( singular verb used in the phrase ) down

as follows. The above statement satisfies the

subject verb agreement and hence, the correct

option is C.

2. The search engineโ€™s business model ___________

around the fulcrum of trust.

A. revolves B. plays

C. sinks D. bursts

Ans. A

Sol.

The search engine business model revolves around

the fulcrum of trust.

Fulcrum is anything that plays a central or

essential role in an activity, event, or situation.

3. Two cars start at the same time from the same

location and go in the same direction. The speed of

the first car is 50 km/h and the speed of the

second car is 60 km/h. The number of hours it

takes for the distance between the two cars to be

20 km is ____________.

A. 1 B. 2

C. 3 D. 6

Ans. B

Sol.

Speed of car A = 50 km/hr

Speed of car B = 60 km/hr

Since, both cars A and B are moving in same

direction, the relative speed = 60 โ€“ 50 = 10 km/hr

Distance required between them = 20 km

dis tance 20

Time 2hrs

speed 10

4. Ten friends planned to share equally the cost of

buying a gift for their teacher. When two of them

decided not to contribute, each of the other friends

had to pay Rs 150 more. The cost of the gift was Rs.

___________.

A. 666 B. 3000

C. 6000 D. 12000

Ans. C

Sol.

Let share of each student = x

Total cost of gift = 10 * x

10x = 8(x + 150)

10x = 8x + 1200

2x = 1200

x = 600

Thus, Total cost of gift = 10 ร— 600 = 6000.

5. A court is to a judge as ___________ is to a

teacher.

A. a student B. a punishment

C. a syllabus D. a school

Ans. D

Sol.

A โ€˜courtโ€™ is for a โ€˜judgeโ€™ as a โ€˜schoolโ€™ is for a

โ€˜teacherโ€™.

Court is a place where a judge works.

Similarly, school is a place where a teacher works.

6. The police arrested four criminals โ€“ P, Q, R and S.

The criminals knew each other. They made the

following statements:

P says, โ€œQ committed the crime.โ€

Q says, โ€œS committed the crime.โ€

R says, โ€œI did not do it.โ€

S says, โ€œWhat Q said about me is false.โ€

Sol.

The passage states that the underlying disease

behind begging is the failure of the state to protect

citizens who fall through the social security net.

Thus, Option B can be concluded from the above.

9. In a college, there are three student clubs. Sixty

students are only in the Drama club, 80 students are

only in the Dance club, 30 students are only in the

Maths club, 40 students are in both Drama and

Dance clubs, 12 students are in both Dance and

Maths clubs, 7 students are in both Drama and

Maths clubs, and 2 students are in all the clubs. If

75% of the students in the college are not in any of

these clubs, then the total number of students in the

college is ___________.

A. 1000 B. 975

C. 900 D. 225

Ans. C

Sol.

Total number of students in all three clubs = 60 +

Total number of students in the college = X

Given that 75% of students are not of any of these

three clubs.

Remaining 25% of X = 225

0.25X = 225 โ‡’ X = 225/0.

10. Three of the five students allocated to a hostel put

in special requests to the warden. Given the floor

plan of the vacant rooms, select the allocation plan

that will accommodate all their requests.

Request by X: Due to pollen allergy, I want to

avoid a wing next to the garden.

Request by Y: I want to live as far from the

washrooms as possible, since I am very sensitive

to smell.

Request by Z: I believe in Vaastu and so want to

stay in the South-west wing.

The shaded rooms are already occupied. WR is

washroom.

A.

B.

C.

D.

Ans. D

Sol.

In such type of question use the Option

elimination method

Because of Request from X : Option B is eliminated

as it cannot be satisfied in that option.

Because of Request from Y : None of the option

can be eliminated as it can is satisfied in all

options.

Because of Request from Z : We can select D as an

answer because none of the other option satisfy it.

So according to conditions mentioned in the

question โ€˜Dโ€™ is the best suited option.

The number of possible ordered pairs (x, X) where

x โˆˆ X is then 2

n- 1

sets. Now, for n elements total

n โ‹… 2

n- 1

number of order pairs are possible.

Thus, statement I is true.

But since by the combinatoric identity

n

n 41

k 1

n

k n.

k

โˆ’

=

๏ƒฅ

Statement II is identity similar to statement I, thus

also true.

6. Which one of the following is NOT a valid identity?

A. (x โจ y) โจ z = x โจ (y โจ z)

B. (x + y) โจ z = x โจ (y + z)

C. x โจ y = x + y, if xy = 0

D. x โจ y = (xy + xโ€ฒyโ€ฒ)โ€ฒ

Ans. B

Sol.

A. XOR is associative so(xโŠ•y)โŠ•z=xโŠ•(yโŠ•z)

B. For 2 input, XOR and XNOR are complement to

each other, i.e., xโŠ•y=(xy+xโ€ฒyโ€ฒ)โ€ฒ

C. xโŠ•y=x+y , if xy=

Only false statement is option B.

7. If ๐ฟ is a regular language over ฮฃ = {๐‘Ž,b}, which

one of the following languages is NOT regular?

A. ๐ฟ โ‹… ๐ฟ

๐‘…

= {๐‘ฅ๐‘ฆ | ๐‘ฅ โˆˆ ๐ฟ, ๐‘ฆ

๐‘…

โˆˆ ๐ฟ}

B. {๐‘ค๐‘ค

๐‘…

| ๐‘ค โˆˆ ๐ฟ}

C. Prefix (๐ฟ) = {๐‘ฅ โˆˆ ๐›ด

โˆ—

|โˆƒ๐‘ฆ โˆˆ ๐›ดโˆ— such that ๐‘ฅ๐‘ฆ โˆˆ ๐ฟ}

D. Suffix (๐ฟ) = {๐‘ฆ โˆˆ ๐›ด

โˆ—

|โˆƒ๐‘ฅ โˆˆ ๐›ดโˆ— such that ๐‘ฅ๐‘ฆ โˆˆ ๐ฟ}

Ans. B

Sol.

If L is regular, L โ‹… L

R

is also regular by closure

property.

Suffix (L) and Prefix (L) are also regular by closure

property.

However option (b) {ww

R

|w โˆˆ L} need not be

regular since if L is an infinite regular language, then

{ww

R

|w โˆˆ L} will not only be infinite, but also non-

regular. Since it involves string matching and we

can increase in length indefinitely and then finite

automata FA will run out of memory.

8. Consider Z = X โ€“ Y, where X, Y and Z are all in sign-

magnitude form. X and Y are each represented

in ๐‘› bits. To avoid overflow, the representation of Z

would require a minimum of:

A. n bits B. n - 1 bits

C. n + 1 bits D. n + 2 bits

Ans. C

Sol. For example:

Let,

X n

X Y

Y n

Hence,

Z = 11 which required 5 bits which is (n + 1) bits

9. Let X be a square matrix. Consider the following

two statements on X.

I. X is invertible.

II. Determinant of X is non-zero.

Which one of the following is TRUE?

A. I implies II; II does not imply I.

B. II implies I; I does not imply II.

C. I does not imply II; II does not imply I.

D. I and II are equivalent statements.

Ans. D

Sol. Matrix is invertible if and only if it has nonzero

determinant.

And if the matrix has nonzero determinant, we can

find the inverse as well.

So, both I and II are equivalent statements.

10. Let G be an arbitrary group. Consider the following

relations on G:

R

1

: โˆ€๐‘Ž, b โˆˆ ๐บ, ๐‘Ž ๐‘… 1

๐‘ if and only if โˆƒ๐‘” โˆˆ ๐บ such that

a = g

  • 1

bg

R

2

: โˆ€๐‘Ž, b โˆˆ ๐บ, ๐‘Ž ๐‘… 2

๐‘ if and only if a = b

  • 1

Which of the above is/are equivalence

relation/relations?

A. R

1

and R 2

B. R

1

only

C. R

2

only D. Neither R 1

nor R 2

Ans. B

Sol. R 1

: โˆ€a, b โˆˆ G, a R 1

b if and only if โˆƒg โˆˆ G such that

a = g

  • 1

bg

Reflexive: a = g

  • 1

ag can be satisfied by putting g =

e, identity โ€œeโ€ always exists in a group.

So, reflexive.

Symmetric: aRb โ‡’ a = g

  • 1

bg for some g

โ‡’ b = gag

  • 1

= (g

  • 1
  • 1

ag

  • 1

g

  • 1

always exists for every g โˆˆ G.

So, symmetric.

Transitive: aRb and bRc โ‡’ a = g

  • 1

bg 1

and b = g 2

1

cg 2

for some g 1

g 2

โˆˆ G.

Now a = g 1

  • 1

g 2

  • 1

cg 2

g 1

= (g 2

g 1

  • 1

cg 2

g 1

g 1

โˆˆ G and g 2

โˆˆ G โ‡’ g 2

g 1

โˆˆ G since group is closed so

aRb and aRb โ‡’ aRc hence transitive

Clearly R 1

is equivalence relation.

R

2

is not equivalence it need not even be reflexive,

since aR 2

a โ‡’ a = a

  • 1

โˆ€a which not be true in a

group.

R

1

is equivalence relation and thus B is the correct

answer.

11. Consider the following two statements about

database transaction schedules:

I. Strict two-phase locking protocol generates

conflict serializable schedules that are also

recoverable.

II. Timestamp-ordering concurrency control

protocol with Thomasโ€™ Write Rule can generate

view serializable schedules that are not conflict

serializable.

Which of the above statements is/are TRUE?

A. I only B. II only

C. Both I and II D. Neither I nor II

Ans. C

Sol. I. Strict 2PL guaranteed conflict serializable

because of 2PL condition and also strict

recoverable.

II. Thomas Write timestamp ordering ensures

serializable. Thomas write rule timestamp ordering

allowed to execute schedule which is view equal

serial schedule based on timestamp ordering.

12. Let G be an undirected complete graph

on ๐‘› vertices, where n > 2. Then, the number of

different Hamiltonian cycles in G is equal to

A. n! B. (n โ€“ 1)!

C. 1 D.

n โˆ’

Ans. C or D

Sol. In a complete graph we can traverse the n vertices

in any order and return to the starting vertex and

form a Hamiltonian cycle. The number of such

cycles will be n!

However, since circular rotations will have to

ignored. Since for example K 4

with vertices {1, 2,

3, 4}, the cycle 1 - 2 - 3 - 4 is same as 2- 3 - 4 - 1 is

same as 3- 4 - 1 - 2 etc. we now get only (n โ€“ 1)!

distinct Hamiltonian cycles. Further, the cycle 1- 2 -

3 - 4 and 1- 4 - 3 - 2 are also same (clockwise and

anticlockwise).

So, ignoring this orientation also we finally get

( )

n 1!

distinct Hamiltonian cycles.

However, in gate answer key, the answer key was

given as C or D.

13. Compute

4

2

x 3

x 81

lim

2x 5x 3

โ†’

A. 1 B. 53/

C. 108/7 D. Limit does not exist

Ans. C

Sol.

4

2

3

lim

โ†’

x

x

x x

form.

So, apply Lโ€™H rule:

3

x 3

4x 108

lim

4x 5 7

โ†’

14. Which one of the following statements is NOT

correct about the B

tree data structure used for

creating an index of a relational database table?

A. B+ Tree is a height-balanced tree

B. Non-leaf nodes have pointers to data records

C. Key values in each node are kept in sorted order

D. Each leaf node has a pointer to the next leaf

node

Ans. B

Sol.

B+ tree non leaf node have pointer to data records

is false statement.

B+ tree non leaf node consists of only keys and

tree pointers (node pointers).

Below is the structure of B+ tree non leaf node

Compute the FOLLOW set of the non-terminal B and

write the index values for the symbols in the

FOLLOW set in the descending order. (For example,

if the FOLLOW set is {a, b, d, $}, then the answer

should be 3210)

Ans. 31

Sol.

S โ†’ Aa

A โ†’ BD

B โ†’ b | โˆˆ

D โ†’ d | โˆˆ

Follow (B) = {d, a}

Hence their index in descending order is 31.

20. An array of 25 distinct elements is to be sorted using

quicksort. Assume that the pivot element is chosen

uniformly at random. The probability that the pivot

element gets placed in the worst possible location in

the first round of partitioning (rounded off to 2

decimal places) is ________.

Ans. 0.

Sol.

Given an array of 25 distinct elements, and pivot

element is chosen uniformly randomly. So, there are

only 2 worst case position in the pivot element, that

is, it is either first (or) last.

Therefore, required probability is,

21. The value of 3

51

mod 5 is ________.

Ans. 2

Sol.

By Fermatโ€™s theorem

(5 โ€“ 1)

mod 5 = 1

4

mod 5 = 1

Now, 3

51

mod 5 = (

4

12

3

mod 5

3

mod 5

22. Two numbers are chosen independently and

uniformly at random from the set

{1, 2,...,13}. The probability (rounded off to 3

decimal places) that their 4-bit (unsigned) binary

representations have the same most significant bit

is ___________.

Ans. 0.502 to 0.

Sol.

The binary representation of numbers

(1,2,3......13) in 4-bits:

As it can be seen that there are 6 numbers whose

MSB is 1, and 7 numbers which start with 0.

So the probability that their 4-bit binary

representation have the same MSB is :

= P(MSB is 0) + P(MSB is 1)

23. Consider three concurrent processes P1, P2 and P

as shown below, which access a shared variable D

that has been initialized to 100

P1 P2 P

D = D +

D = D โ€“ 50 D = D + 10

The processes are executed on a uniprocessor

system running a time-shared operating system. If

the minimum and maximum possible values of D

after the three processes have completed

execution are X and Y respectively, then the value

of Y โ€“ X is _____________.

Ans. 80

Sol.

Total possible sequences of execution are: P1 P

P3, P1 P3 P2, P2 P1 P3, P2 P3 P1, P3 P1 P2 and P

P2 P1.

Whatever the sequence we will use to execute, we

will get 80 as answer.

So, X= 50 and Y= 130

Hence, Y-X = 80

24. Consider the following C program:

#include <stdio.h>

int main(){

int arr[]={1,2,3,4,5,6,7,8,9,0,1,2,5},

*ip=arr+4;

printf(โ€œ%d\nโ€, ip[1]);

return 0;

The number that will be displayed on execution of

the program is ___________.

Ans. 6

Sol.

Here answer will be 6.

ip is an integer pointer. The initial assignment sets

it to the element at array index 4 i.e. 5.

Hence ip holds address of array index 4

The next statement refers to the next integer after

it which is 6(ip[1]=โˆ—(ip+1))

25. Consider a sequence of 14 elements: A = [โˆ’5, โˆ’10,

6, 3, โˆ’1, โˆ’2, 13, 4, โˆ’9, โˆ’1, 4, 12, โˆ’3, 0]. The

subsequence sum ๐‘†

[

]

๐‘—

๐‘˜=๐‘–

. Determine the

maximum of S(i, j), where 0 โ‰ค i โ‰ค j < 14. (Divide

and conquer approach may be used.)

Ans. 29

Sol.

The maximum sum of the array

which sum up to 29.

26. Consider the following C function.

void convert(int n){

if(n<0)

printf(โ€œ%dโ€,n);

else {

convert(n/2);

printf(โ€œ%dโ€,n%2);

Which one of the following will happen when the

function convert is called with any positive integer

n as argument?

A. It will print the binary representation of n and

terminate

B. It will print the binary representation of n in the

reverse order and terminate

C. It will print the binary representation of n but

will not terminate

D. It will not print anything and will not terminate

Ans. D

Sol.

Let n=5,

function calling goes as: convert(5) โ†’ convert(2)

โ†’ convert(1) โ†’ convert(0) now when we go for

convert(0) then in if condition its mentioned as

if(n<0) but our n = 0 , so still the condition is

false, it will go into else block and implement

convert(0/2) which is convert(0) , so it will go on

calling the same way again and again leading to

stack overflow.

Hence, the program will not print anything (as

after every function call, the value returned is

greater than 0) and will not terminate.

27. Consider the following C program:

#include<stdio.h>

int r(){

static int num=7;

return num--;

C. ฮฃ (2, 14)

D. ฮฃ (0, 2, 3, 5, 6, 7, 8, 11, 14, 15)

Ans. A

Sol.

f 1

. f 2

f = f 3

โŠ• (f 1

. f 2

31. Which one of the following languages over ฮฃ = {a,

b}is NOT context-free?

A. {ww

R

|w โˆˆ {a,b}

B. {wa

n

b

n

w

R

|w โˆˆ{a, b}

, n โ‰ฅ 0}

C. {wa

n

w

R

b

n

|w โˆˆ{a,b}

, n โ‰ฅ 0}

D. {a

n

b

i

|i โˆˆ {n, 3n, 5n}, n โ‰ฅ 0}

Ans. C

Sol.

(a) {ww

R

|w โˆˆ {a, b}* } is a CFL

(b) {wa

n

b

n

w

R

|w โˆˆ {a, b}*, n โ‰ฅ 0} is a CFL, since

we can first push w, then aโ€™s, bโ€™s pop with aโ€™s and

w

R

pops with the w. So PDA can accept the

language.

(c) {wa

n

w

R

b

n

|w โˆˆ {a, b}*, n โ‰ฅ 0} is a not CFL

because after pushing w, we need to push aโ€™s into

stack which will stop the w from being matched with

w

R

. If we donโ€™t push aโ€™s after w, than later we cannot

match with bn. So this language is not acceptable

by a PDA and hence not a CFL.

(d) {a

n

b

i

|i โˆˆ {n, 3n, 5n}, n โ‰ฅ 0}

= a

n

b

n

โˆช a

n

b

3n

โˆช a

n

b

5n

is CFL since each of the three

parts is a CFL and closure under union guarantees

that result also is a CFL.

32. Let the set of functional dependencies F =

{QR โ†’ S, R โ†’ P, S โ†’ Q} hold on a relation

schema X = (PQRS). X is not in BCNF. Suppose X

is decomposed into two schemas Y and Z, where Y

= (PR) and Z = (QRS).

Consider the two statements given below.

I. Both Y and Z are in BCNF.

II. Decomposition of X into Y and Z is dependency

preserving and lossless.

Which of the above statements is/are correct?

A. Both I and II B. I only

C. II only D. Neither I nor II

Ans. C

Sol. X(PQRS) {QR โ†’ S, R โ†’ P, S โ†’ Q} decomposed

into

Y(PR) Z(QRS)

{R โ†’ P} {QR โ†’ S, S โ†’ Q}

Candidate key : R Candidate key : QR,RS

Relation Y in BCNF Relation Z in 3NF but not in

BCNF

Common attribute between Y and Z relations is R

which is key for relation Y.

So that given decomposition is lossless join

decomposition.

R โ†’ P in Y

QR S

S Q

are in Z

and dependency preserving decomposition.

Hence, C is the correct answer.

33. Assume that in a certain computer, the virtual

addresses are 64 bits long and the physical

addresses are 48 bits long. The memory is word

addressable. The page size is 8 kB and the word size

is 4 bytes. The Translation Look-aside Buffer (TLB)

in the address translation path has 128 valid entries.

At most how many distinct virtual addresses can be

translated without any TLB miss?

A. 16 ร— 2

10

B. 256 ร— 2

10

C. 4 ร— 2

20

D. 8 ร— 2

20

Ans. B

Sol. 1 word = 4 bytes

Page size = 8 kB = 2

13

B

Number of words in 1 page

13

11

2

TLB can hold 128 valid entries so, at most 128 ร—

11

memory address can be addressed without TLB

miss.

128 ร— 2

11

= 256 ร— 2

10

34. Consider the following sets:

S1 Set of all recursively enumerable languages

over the alphabet {0,1}

S2 Set of all syntactically valid C programs

S3 Set of all languages over the alphabet {0,1}

S4 Set of all non-regular languages over the

alphabet {0,1}

Which of the above sets are uncountable?

A. S1 and S2 B. S3 and S

C. S2 and S3 D. S1 and S

Ans. B

Sol.

S

1

: The set L RE

is known to be countably infinite

since it corresponds with set of turing machines.

S

2

: Since syntactically valid C programs surely run-

on Turing machines, this set is also a subset of set

of Turing machines, which is countable.

S

3

: Set of all languages = 2

ฮฃ

which is known to be

uncountable. ฮฃ

countably infinite

ฮฃ

is uncountable.

S

4

: Set of all non-regular languages includes set L NOT

RE

which is uncountable infinite and hence is

uncountable.

So, S 3

and S 4

are uncountable.

Hence, B is the correct answer.

35. Consider the first order predicate formula ๐œ‘:

โˆ€๐‘ฅ [(โˆ€๐‘ง ๐‘ง|๐‘ฅโ‡’((๐‘ง=๐‘ฅ)โˆจ(๐‘ง=1)))โ‡’โˆƒ๐‘ค (๐‘ค>๐‘ฅ)โˆง(โˆ€๐‘ง ๐‘ง|๐‘คโ‡’((๐‘ค

=๐‘ง)โˆจ(๐‘ง=1)))]

Here โ€˜a|bโ€™ denotes that โ€˜a divides bโ€™, where a and b

are integers. Consider the following sets:

S1: {1,2, 3,โ€ฆ,100}

S2: Set of all positive integers

S3: Set of all integers

Which of the above sets satisfy ๐œ‘?

A. S1 and S2 B. S1 and S

C. S2 and S3 D. S1, S2 and S

Ans. C

Sol.

โˆ€x[โˆ€zโŠ—x โ‡’ ((z = x) โˆจ (z = 1)) โ‡’ โˆƒw (w > x) โˆง (โˆ€z

zโŠ—w โ‡’ ((w = z) โˆจ (z = 1)))]

The predicate ฯ• simply says that if z is a prime

number in the set then there exists another prime

number is the set which is larger.

Clearly ฯ• is true in S 2

and S 3

since in set of all

integers as well as all positive integers, there is a

prime number greater than any given prime

number.

However, in S 1

: {1, 2, 3, .....100} ฯ• is false since

for prime number 97 โˆˆ S 1

there exists no prime

number in the set which is greater.

So correct answer is C.

36. Consider the following grammar and the semantic

actions to support the inherited type declaration

attributes. Let X 1

, X

2

, X

3

, X

4

, X

5

, and X 6

be the

placeholders for the non-terminals D, T, L or L1 in

the following table:

Production

rule

Semantic action

D โ†’ T L

X

1

.type = X 2

.type

T โ†’ int

T.type = int

T โ†’ float T.type = float

L โ†’ L

1

, id

X

3

.type = X 4

.type

addType(id.entry, X 5

.type)

L โ†’ id addType(id.entry, X

6

.type)

Which one of the following are the appropriate

choices for ๐‘‹ 1

2

3

and ๐‘‹ 4

A. ๐‘‹

1

= L, ๐‘‹

2

3

1

4

B. ๐‘‹

1

= L, ๐‘‹

2

3

1

4

C. ๐‘‹

1

= L, ๐‘‹

2

3

1

4

D. ๐‘‹

1

= L, ๐‘‹

2

3

4

1

Ans. A

Sol.

SDT for inserting type information in the symbol

table

D โ†’ TL {L.idtype = T.stype}

T โ†’ int {T.stype = int}

T โ†’ float {T.stype = float}

L โ†’ L1, id {L1.itype = L.itype}

addtype(id.entry, L.itype)

L โ†’ id addtype(id.entry, L.itype)

III. A max-heap can be constructed from a binary

search tree in ฮ˜(๐‘›) time

IV. A binary search tree can be constructed from a

max-heap in ฮ˜(๐‘›) time

Which of the above statements are TRUE?

A. I, II and III B. I, II and IV

C. I, III and IV D. II, III and IV

Ans. A

Sol.

The smallest element in a max-heap is always at a

leaf node โ€“ TRUE because by definition of a max-

heap every parent node must be larger than its

child node.

The second largest element in a max-heap is

always a child of a root node โ€“ TRUE. The k

th

largest element cannot have more than kโˆ’

parents (larger value nodes) and so cannot be

lower than level k.

A max heap can be constructed from a binary

search tree in ฮ˜(n) time. Build heap for any array

of size n (even unsorted) can be done in O(n) time.

Thus, A is the correct answer.

41. Consider the following four processes with arrival

times (in milliseconds) and their length of CPU

bursts (in milliseconds) as shown below:

These processes are run on a single processor using

preemptive Shortest Remaining Time First

scheduling algorithm. If the average waiting time of

the processes is 1 millisecond, then the value of Z

is________.

Ans. 2

Sol. Till time = 4 units, this is the Gantt chart:

At this point P4 arrives with burst 2 & P3 is in

queue with burst 3.

P1 & P2 have executed with P1 incurred delay of 1

unit & P2 with 0 units.

Hence, Average = 0+1+x/4 =

โ‡’ x=3, the next delay should be at 3. It would

happen if assume Z=2.

It executes and completes at 6.

P3 will wait totally for 3 units.

Hence, Average =1.

Z=

42. The index node (inode) of a Unix-like file system has

12 direct, one single-indirect and one double-

indirect pointers. The disk block size is 4 kB, and the

disk block address is 32-bits long. The maximum

possible file size is (rounded off to 1 decimal place)

_________ GB.

Ans. 4

Sol.

Given 12 direct, 1 single indirect, 1 double indirect

pointer.

Size of Disk block = 4kB

Disk Block Address = 32 bit = 4B

Number of addresses = Size of disk block/address

size =

Maximum possible file size = 12 * 4kB + 2

10

  • 4kB

10

10

  • 4kB

= 4.00395 GB โ‰ƒ 4 GB

Hence 4GB is the correct answer.

43. Consider the augmented grammar given below:

S' โ†’ S

S โ†’ โŒฉLโŒช | id

L โ†’ L, S | S

Let I 0

= CLOSURE ({[S' โ†’ โ€ข S]}). The number of

items in the set GOTO (I 0

, โŒฉ) is: ________.

Ans. 5

Sol.

Total number of items in the set GOTO

(I

0

, โŒฉ) is 5.

44. Consider the following matrix:

R

The absolute value of the product of Eigen values

of R is ___ _________.

Ans. 12

Sol.

Product of eigenvalues is same as the determinant

of a matrix.

2 3 2 3

2 3 2 2 3 3

2 3 2 2 3 3

2 3 2 2 3 3

( ) ( ) ( )

45. A certain processor deploys a single-level cache. The

cache block size is 8 words, and the word size is 4

bytes. The memory system uses a 60-MHz clock. To

service a cache miss, the memory controller first

takes 1 cycle to accept the starting address of the

block, it then takes 3 cycles to fetch all the eight

words of the block, and finally transmits the words

of the requested block at the rate of 1 word per

cycle. The maximum bandwidth for the memory

system when the program running on the processor

issues a series of read operations is __________ร—

6

bytes/sec.

Ans. 160

Sol.

Time to transfer a cache block =1+3+8=12 cycles.

i.e., 4 bytes ร—8=32 bytes in 12 cycles.

So, memory bandwidth =32/12 cycle time=32/ 12/

(60ร—

6

) = 160ร—

6

bytes/s

46. Let T be a full binary tree with 8 leaves. (A full binary

tree has every level full.) Suppose two leaves a and

b of T are chosen uniformly and independently at

random. The expected value of the distance

between a and b in T (i.e., the number of edges in

the unique path between a and b) is (rounded off to

2 decimal places) ___________.

Ans. 4.

Sol.

See the word "independently" here. It means that

choice of โ€˜aโ€™ must not affect choice of โ€˜bโ€™ and vice

versa. This implies that both โ€˜aโ€™ and โ€˜bโ€™ can even be

the same node.

Now, we are given that the binary tree has 8leaves.

3

=8) โŸนwe have 3 levels in the tree starting from

  1. The distance I n terms of number of

edges between any two leaf nodes will always

be even. If we consider any two leaves (not

necessarily distinct)

  • No. of pairs with path length0= 8. (When a=b)
  • No. of pairs with path length2=8. (For each of the 8

leaf nodes, we have a pair and since the selection

is independent order of the pair is also significant)

  • No. of pairs with path length4=16. (For each leaf

node we must go two levels up and while coming

down we have 2 choices. So, we get 8ร—2=

pairs)

  • No. of pairs with path length6=32. (For each leaf

node we must go till the root, and from there while

coming down it has 2ร—2=4 choices. Thus, we

get8ร—4= 32 pairs.

  • Total number of possible pairs=8ร—8=

No. of pairs with path length 0=8.

No. of pairs with path length 1=0.

No. of pairs with path length 2=8.

No. of pairs with path length 3=0.

No. of pairs with path length 4=16.

No. of pairs with path length 5=0.

No. of pairs with path length 6=32.

( ) ( )

f = B + D B +D

51. A relational database contains two tables Student

and Performance as shown below:

Student

Performance

The primary key of the Student table is Roll_no.

For the Performance table, the columns Roll_no.

and Subject_code together form the primary key.

Consider the SQL query given below:

SELECT S.Student_name, sum(P.Marks)

FROM Student S, Performance P

WHERE P.Marks > 84

GROUP BY S.Student_name;

The number of rows returned by the above SQL

query is ________.

Ans. 5

Sol.

SELECT S.Student_name,sum(P.Marks)

FROM Student S,Performance P

WHERE P.Marks>

GROUP BY S.Student_name;

Student Sum

(P.Marks)

Rohan 452

Vinit 452

Priya 452

Amit 452

Smita 452

The number of rows returned is 5.

52. Consider the following C program:

#include<stdio.h>

int main () {

float sum = 0.0, j = 1.0, i = 2.0;

while (i/j > 0.0625) {

j = j + j;

sum = sum + i/j;

printf("%f\n", sum);

return 0;

The number of times the variable sum will be

printed, when the above program is executed, is

_________________.

Ans. 5

Sol.

initially j=1.0; i=2.

1st iteration- i/j=

= ๏€พ true j=1+1=2---> print sum

2nd iteration- i/j=

true j=2+2=4---> print sum

3rd iteration- i/j=

true j=4+4=8---> print sum

4th iteration- i/j=

true j=8+8=16--->print sum

5th iteration- i/j=

true j=16+16=32---> print sum

6th iteration- i/j=

= ๏‚น false --

  • loop terminates

Hence Sum is printed 5 times.

53. Consider the following C program:

#include <stdio.h>

int main()

int a[] = {2, 4, 6, 8, 10};

int i, sum = 0, *b = a + 4;

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

sum = sum + (*b โ€“ i) โ€“ *(b โ€“ i);

printf (โ€œ%d\nโ€, sum);

return 0;

The output of the above C program is __________.

Ans. 10

Sol.

sum=0,โˆ—b=a+4 i.e. pointing to 10

sum=sum+(โˆ—bโˆ’i)โˆ’โˆ—(bโˆ’i)

i=

sum=0+(10โˆ’0)โˆ’(10)=

i=

sum=0+(10โˆ’1)โˆ’(8)=

i=

sum=1+(10โˆ’2)โˆ’(6)=

i=

sum=3+(10โˆ’3)โˆ’(4)=

i=

sum=6+(10โˆ’4)โˆ’(2)=

54. In an RSA cryptosystem, the value of the public

modulus parameter ๐‘› is 3007. If it is also known

that ฯ†(๐‘›) = 2880, where ฯ†() denotes Eulerโ€™s Totient

Function, then the prime factor of ๐‘› which is greater

than 50 is ____________________.

Ans. 97

Sol.

n = p ร— q = 3007

By RSA algorithm, n = 31 ร— 97 in which 97 is

prime factor which greater than 50.

55. Consider the following relations P(X,Y,Z), Q(X,Y,T)

and R(Y,V).

How many tuples will be returned by the following

relational algebra query?

x (P.Y R.Y R.V V2) x (Q.Y R.Y Q.T 2)

P R Q R

= ๏ƒ™ = = ๏ƒ™ ๏€พ

๏ฐ ๏ณ ๏‚ด โˆ’ ๏ฐ ๏ณ ๏‚ด

Ans. 1

Sol.

ฯƒ (P.Y=R.Y โˆง R.V=V2)

(P ร— R)

X Y Z V

X2 Y2 Z2 V

x

(ฯƒ (P.Y=R.Y โˆง R.V=V2)

(P ร— R))

X

X

ฯƒ (Q.Y=R.Y โˆง Q.T>2)

(Q ร— R)

X Y T V

X

X

X

Y

Y

Y

V

V

V

x

(ฯƒ (Q.Y=R.Y

โˆง Q.T>2)

(Q ร— R))

Y

X

x

(ฯƒ (P.Y=R.Y โˆง R.V=V2)

(P ร— R)) - โˆ

x

(ฯƒ (Q.Y=R.Y โˆง Q.T>2)

(Q ร—

R))