Official Paper

GATE CS 2012 Official Paper (Previous Year Paper)

65 questions · 180 minutes · with answers · free

General Aptitude (10 questions)

1

Given the sequence of terms, AD CG FK JP, the next term is

  1. ((a))

    OV

  2. ((b))

    OW

  3. ((c))

    PV

  4. ((d))

    PW

Show Answer
Answer: ((a))

OV

The given sequence is:

2

Which of the following assertions are CORRECT?

P: Adding 7 to each entry in a list adds 7 to the mean of the list

Q: Adding 7 to each entry in a list adds 7 to the standard deviation of the list

R: Doubling each entry in a list doubles the mean of the list

S: Doubling each entry in a list leaves the standard deviation of the list unchanged

  1. ((a))

    P. Q 

  2. ((b))

    Q. R 

  3. ((c))

    P. R

  4. ((d))

    R. S

Show Answer
Answer: ((c))

P. R

Explanation:

Let E(x) represent mean

Then by the property of mean

E(Cx) = cE(x) where c is constant

And E(x + c) = E(x) + E(c) = E(x) + c

 Options P and R always holds true.

Now,

Let Var (x) represent the variance

Then var (x + c) = var (x) + var (c)

 var (x + c) = var (x)    {∵ var (c) = 0}

S.D (x + c) = S.D (x)

Now,

var (cx) =(c2)var (x)

S.D (cx) = (c)S.D (x)

Options Q and S are incorrect.

3

An automobile plant contracted to buy shock absorbers from two suppliers X and Y. X supplies 60% and Y supplies 40% of the shod absorbers. All shock absorbers are subjected to a quality test. The ones that pass the quality test are considered reliable Of X's shock absorbers, 96% are reliable. Of Y's shock absorbers, 72% are reliable. The probability that a randomly chosen shock absorber, which is found to be reliable is made by Y is

  1. ((a))

    0.288

  2. ((b))

    0.334

  3. ((c))

    0.667

  4. ((d))

    0.720

Show Answer
Answer: ((b))

0.334

Calculation: 

Let 100 shock absorbers are supplied

so, X supplies = 60 (60% of 100)

Y supplies = 40 (40% of 100)

Reliable supply by X = 96% of 60 = 57.6

Reliable supply by Y = 72% of 40 = 28.8

Required probability P(Y)=28.857.6+28.8=0.33P\left( Y \right) = \frac{{28.8}}{{57.6 + 28.8}} = 0.33

4

A political party orders an arch for the entrance to the ground in which the annual convention is being held. The profile of the arch follows the equation y = 2x - 0.1x2 where y is the height of the arch in meters. The maximum possible height of the arch is

  1. ((a))

    8 meters

  2. ((b))

    10 meters

  3. ((c))

    12 meters

  4. ((d))

    14 meters

Show Answer
Answer: ((b))

10 meters

Given:

y = 2x – 0.1x2

differentiating w.r.t x

dydx=20.2x=0\frac{{dy}}{{dx}} = 2 - 0.2x = 0

x=20.2=10x = \frac{2}{{0.2}} = 10

(d2ydx2)x=10=0.2<0{\left( {\frac{{{d^2}y}}{{d{x^2}}}} \right)_{x = 10}} = - 0.2 < 0

At x = 10, y will have a maximum value.  

ymax = y(10) = (2 × 10) - 0.1(102) = 10

5

Wanted Temporary, Part-time persons for the post of Field Interviewer to conduct personal interviews to collect and collate economic data. Requirements: High School-pass, must be available for Day, Evening, and Saturday work. Transportation paid, expenses reimbursed. which one of the following is the best inference from the above advertisement?

  1. ((a))

    Gender-discriminatory

  2. ((b))

    Xenophobic

  3. ((c))

    Not designed to make the post attractive

  4. ((d))

    Not gender-discriminatory

Show Answer
Answer: ((d))

Not gender-discriminatory

Explanation:

  • Clearly, in the given question there is nothing related to gender is mentioned in the advertisement, eliminating options 1)
  • Xenophobic means having or showing a dislike of or prejudice against people from other countries. There, is no such thing related to people of other countries is mentioned in the advertisement, eliminating it too.
  • The requirements that are mentioned for the post is designed to make the post attractive, Transportation paid, expenses reimbursed are mentioned. So option 4) is the most suitable answer.
6

Choose the most appropriate alternative from the options given below to complete the following sentence:

Suresh's dog is the one ________ was hurt in the stampede.

  1. ((a))

    that

  2. ((b))

    which

  3. ((c))

    who

  4. ((d))

    whom

Show Answer
Answer: ((a))

that

The correct answer is option 1- that

Explanation 

To answer this question, we need to understand the meaning of defining and non-defining clauses. 

  • A defining clause (also called an essential clause or a restrictive clause) gives information essential to the meaning of the sentence. We always use 'that' with defining clauses.

Example: My bike that has a broken seat is in the garage.

  • Unlike defining clauses, non-defining clauses (also called nonessential or nonrestrictive clauses) don’t limit the meaning of the sentence. You might lose interesting details if you remove them, but the meaning of the sentence wouldn’t change. We always use 'which' with non-defining clauses.

Example: The goat was standing on the roof of the house which was abandoned.

In the given sentence, if we consider the first clause, the information given is incomplete and it can only be completed via the introduction of the second clause. Hence, we have to use 'that' in this sentence.

7

Choose the grammatically INCORRECT sentence:

  1. ((a))

    They gave us the money back less the service charges of Three Hundred rupees.

  2. ((b))

    This country's expenditure is not less than that of Bangladesh.

  3. ((c))

    The committee initially asked for a funding of Fifty Lakh rupees, but later settled for a lesser sum.

  4. ((d))

    This country's expenditure on educational reforms is very less

Show Answer
Answer: ((d))

This country's expenditure on educational reforms is very less

The correct answer is option 4. 

Explanation 

As we can see, the question has been framed to test our grammatical knowledge regarding the use of the adjective 'less'. 

  • 'Less' has been used correctly in option 1. Here, 'less' means 'minus'.
  • 'Less' has been used correctly in option 2 as well. It has been used here to compare the country's expenditure to that of Bangladesh.
  • 'Less' has been used correctly in option 3 as well. If we don't use the word 'than' after 'less', we have to use the comparative form of less- 'lesser'.
  • The usage of 'less' is wrong in option 4. 'Less' is generally used as a way of comparing two quantities or amounts. Here, the word 'less' needs to be replaced with the words 'little' or 'low'.
8

Which one of the following options is the closet in meaning to the word given below?

Mitigate

  1. ((a))

    Diminish

  2. ((b))

    Divulge

  3. ((c))

    Dedicate

  4. ((d))

    Denote

Show Answer
Answer: ((a))

Diminish

The correct answer is option 1- Diminish Explanation

Mitigate: make (something bad) less severe, serious, or painful; lessen the gravity of (an offence or mistake)

Diminish: make or become less; decrease in size, degree etc.

Thus we can see that among the options, 'diminish' is closest in meaning to the word 'mitigate'. They are near-synonyms.

The meaning of the other words:

  • Divulge: make known (private or sensitive information)
  • Dedicate: devote (time or effort) to a particular task or purpose
  • Denote: be a sign of, indicate; stand as a name or symbol for
9

Choose the most appropriate alternative from the options given below to complete the following sentence:

Despite several ________ the mission succeeded in its attempt to resolve the conflict.

  1. ((a))

    attempts

  2. ((b))

    setbacks

  3. ((c))

    meetings

  4. ((d))

    delegations

Show Answer
Answer: ((b))

setbacks

The correct answer is option 2- setbacks

Explanation   

Setback: something that happens that delays or prevents a process from developing

From the given context, it is clear that the mission finally resolved the conflict after many failed attempts and obstacles. Thus, 'setback' is the correct word for the given blank.

   

The meaning of the other words:

  • Attempt: an effort to achieve or complete a difficult task or action
  • Meeting: an assembly of people for a particular purpose, especially for formal discussion
  • Delegation: a group of people who have been sent somewhere to have talks with other people on behalf of a larger group of people.

You may be confused regarding the use of 'attempts' and 'setbacks'. Attempt does not have any negative connotation to it, whereas setback has one. As the sentence is specifically referring to fruitless attempts taken in the past, 'setbacks' would be a more apt choice.

10

The cost function for a product in a firm is given by 5q2, where q is the amount of production. The firm can sell the product at a market price of Rs.50 per unit. The number of units to be produced by the Emi such that the profit is maximized is

  1. ((a))

    5

  2. ((b))

    10

  3. ((c))

    15

  4. ((d))

    25

Show Answer
Answer: ((a))

5

As q = total number of quantities produced.

Total cost = 5q2

Total sales = 50q

Profit (P) = total cost – total sales

P = 5q2 – 50q

Differentiating w.r.t q

dPdq=10q50=0\frac{{dP}}{{dq}} = 10q - 50 = 0

q=5010=5q = \frac{{50}}{{10}} = 5

d2Pdq2=10>0\frac{{{d^2}P}}{{d{q^2}}} = 10 > 0

∴ At q = 5, profit (P) is maximum.

Computer Science and Information Technology (55 questions)

11

Consider the following logical inferences.

I1: If it rains then the cricket match will not be played.

The cricket match was played.

Inference: There was no rain.

I2: If it rains then the cricket match will not be played.

It did not rain

Inference: The cricket match was played.

Which of the following is TRUE?

  1. ((a))

    Both I1 and I2 are correct inferences

  2. ((b))

    I1 is correct but I2 is not a correct inference

  3. ((c))

    I1 is not correct but I2 is a correct inference

  4. ((d))

    Both I1 and I2 are not correct inferences

Show Answer
Answer: ((b))

I1 is correct but I2 is not a correct inference

The correct answer is “option 2”.

EXPLANATION:

I1 states that:

Statement

Consider A = it rains,

B = match played

So, If (it rains) then (match will not be played) that means,

A → (¬ B)

Inference states that “there was no rain” means A = false (F)

Therefore, for any F(¬ B) i.e. for any "F that implies not B" is true.

So this inference is valid.

Here the only condition is if it rains the match will not be played. That doesn’t mean if it will not rain then the match will be played.

If the match was played then it means it doesn’t rain.

So this inference is valid.

I2 states that:

Statement

Consider A = it rains,

B = match played

So, If (it rains) then (match will not be played) that means,

A → (¬ B)

Inference states that “the match was played”.

Here the only condition is if it rains the match will not be played. If the match was played then it means it doesn’t rain.

That doesn’t mean if it will not rain then the match will be played.

So this inference is invalid.

Hence, the correct answer is "option 2".

12

Which of the following is TRUE?

  1. ((a))

    Every relation in 3NF is also in BCNF

  2. ((b))

     A relation R is in 3NF if every non-prime attribute of R is fully functionally dependent on every key of R

  3. ((c))

    Every relation in BCNF is also in 3NF

  4. ((d))

    No relation can be in both BCNF and 3NF

Show Answer
Answer: ((c))

Every relation in BCNF is also in 3NF

The correct answer is "option 3".

CONCEPT

Normalization is used to minimize redundancy from a set of relations.

It is used to organize data effectively in the database.

Normal forms are used to reduce redundancy from the database.

Third Normal form: A relation is said to be in third normal form if it is in 2NF & there must not exist any transition dependency.

Also, it must satisfy these properties:

  1. For the function A → B, A should be a super key.
  2. B should be a part of a key attribute or prime attribute i.e. B should be a part of a candidate key.

BCNF: A relation is said to be in Boyce-Codd normal form (BCNF) if it is in 3NF & must satisfy this property: 

  1. For the function A → B, A should be a super key.

EXPLANATION:

Option 1: FALSE

Any relation in BCNF must be in 3NF.

Option 2: FALSE

A relation R is in 3NF if every non-prime attribute of R is fully functionally dependent on every key of R but this does not guarantee transitive dependency.

Option 3: TRUE

Every relation is BCNF must be in 3NF.

Option 4: FALSE

Any relation can be in both BCNF & 3NF if it satisfies the condition of BCNF.

Hence, the correct answer is “option 3”.

13

What will be the output of the following C program segment?

char inChar = ‘A’ ;

switch ( inChar )

{

case ‘A’ : printf (“Choice A\n”) ;

case ‘B’ :

case ‘C’ : printf (“Choice B”) ;

case ‘D’ :

case ‘E’ : default : printf ( “ No Choice” ) ;

}

  1. ((a))

    No Choice

  2. ((b))

    Choice A

  3. ((c))

    Choice A

    Choice B No Choice

  4. ((d))

    Program gives no output as it is erroneous

Show Answer
Answer: ((c))

Choice A

Choice B No Choice

The correct answer is "option 3".

CONCEPT:

The expression in switch condition is evaluated once and compared with values of each case value.

Also, the break statement is used to move the control out of the switch case after matching case statements gets executed.

If there is no match, then the default clause is used.

The default clause is optional

EXPLANATION:

char inChar = ‘A’ ; 

<br>

// inChar variable having char datatype is initialized with value “A”.

switch ( inChar )   // switch condition is compared

 

case ‘A’: printf("Choice A\n"); 

<br>

// the case value is matched & statement gets executed but since there is no break it will move to case value B

 

case 'B':                                     

<br>

//no statement & no break so it will move to case value C

case ‘C’: printf ("Choice B");         

<br>

// print given statement & since no break so it will move to case value D

case 'D':                                 

<br>

 //no statement & no break so it will move to case value E

case 'E':                               

         

//no statement & no break so it will move to the default case

default: printf ( "No Choice" ) ; }     

<br>

// print the statement and move out of the switch case.

So the output will be:

Choice A

Choice B No Choice

Hence the correct answer is "option 3".

14

Assuming P ≠ NP, which of the following is TRUE?

  1. ((a))

    NP-complete = NP

  2. ((b))

    NP-complete ∩ P = Φ

  3. ((c))

    NP-hard = NP

  4. ((d))

    P = NP-complete

Show Answer
Answer: ((b))

NP-complete ∩ P = Φ

The correct answer is option 2

CONCEPT:

From Diagram: NP-complete ⋂ P = ϕ

NP-complete problems:

They are those for which no polynomial-time algorithm exists. We can say a problem is NP-complete if it is NP and belongs to NP-hard.

NP problems:

A problem is a member of the NP class if there exists a non-deterministic machine that can solve it in polynomial time.

NP-Hard:

A problem is called NP-hard if all the NP class problems are polynomial-time reducible to that and as hard as any problem of NP class

EXPLANATION:

  • Every problem in P is also in NP
  • Given that P ≠ NP, this means there exists a problem that is in NP but not in P

So the option NP-complete ∩ P = Φ is correct

15

The worst case running time to search for an element in a balanced binary search tree with n2n elements is

  1. ((a))

    Θ (n log n)

  2. ((b))

    Θ (n2n)

  3. ((c))

    Θ (n)

  4. ((d))

    Θ (log n)

Show Answer
Answer: ((c))

Θ (n)

The correct answer is "option 3".

CONCEPT:

There are three types of complexities:

  1. Worst case: It is the maximum running time taken by any algorithm. 
  2. Average case: It is the average running time taken by any algorithm. 
  3. Best case: It is the minimum running time taken by any algorithm. 

EXPLANATION:

Since the worst-case running time to search ‘n’ elements in a balanced Binary Search Tree (BST) is (log2n).

If the number of elements is (n2n) then,

Search time will be: T(n) = (log2n.2n)

Since log2(A.B) = log2A + log2B

∴T(n) =log2n + log22n

∴T(n)  = log2n + n.log22 = log2n + n

T(n) = O(n)

Hence the correct answer is "option 3".

16

The truth table

XYF(X, Y)
000
010
101
111

represents the Boolean function

  1. ((a))

    X

  2. ((b))

    X + Y

  3. ((c))

    X ⊕ Y

  4. ((d))

    Y

Show Answer
Answer: ((a))

X

The correct answer is "option 1".

EXPLANATION:

Option 1: TRUE

The truth table X is**:**

XYFX
0000
0100
1011
1111

 

F is equal to X.

Option 2: FALSE

The truth table X+Y is**:**

XYFX+Y
0000
0101
1011
1111

F is not equal to X+Y.

Option 3: FALSE

The truth table X’Y + XY' is**:**

XYFX’ Y + XY'
0000
0101
1011
1110

F is not equal to X’.Y +X.Y'.

Option 4: FALSE

The truth table Y is :

XYFY
0000
0101
1010
1111

 F is not equal to Y.

Hence, the correct answer is "option 1".

From truth table, the sum of minterms

F(X, Y) = X.Y̅ + X.Y = X(Y̅ + Y) = X

17

The decimal value 0.5 in IEEE single precision floating point representation has

  1. ((a))

    fraction bits of 000…000 and exponent value of 0

  2. ((b))

    fraction bits of 000…000 and exponent value of −1

  3. ((c))

    fraction bits of 100…000 and exponent value of 0

  4. ((d))

    no exact representation

Show Answer
Answer: ((b))

fraction bits of 000…000 and exponent value of −1

The correct answer is option 2:

Concept:

32-bit floating-point representation of a binary number in IEEE- 754 is

Sign (1 bit)Exponent E (8 bit)Mantissa M (23 bits)

In IEEE-754 format, 32-bit (single precision)

Decimal value = (-1)s × 1.M × 2E – 127

Option 2: Correct

If E = 126 then exponent part = 126 - 127 = -1

Fraction part = M = 0

Since 0.5 is positive and hence S = 0

Decimal value = (-1)s × 1.M × 2E – 127 

Decimal value = (-1)0 × 1.0 × 2126 – 127 = 0.5

18

A process executes the code

fork();

fork();

fork();

The total number of child processes created is

  1. ((a))

    3

  2. ((b))

    4

  3. ((c))

    7

  4. ((d))

    8

Show Answer
Answer: ((c))

7

The correct answer is option 3.

Concept:

Fork () is a system call that creates a new process. After a new child process is created, both processes will execute the next instruction. If fork() returns a negative value, the creation of the child process was unsuccessful. Return zero to the newly created process.

Explanation:

If there are n fork() calls, then the number of child processes created is 2n – 1.

Calculation:

n = 3,

Number of child processes created = 23 – 1 = 7

19

Consider the function f(x) = sin(x) in the interval x ∈ [π/4, 7π/4]. The number and location(s) of the local minima of this function are

  1. ((a))

    One, at π/2

  2. ((b))

    One, at 3π/2

  3. ((c))

    Two, at π/2 and 3π/2

  4. ((d))

    Two, at π/4 and 3π/2

Show Answer
Answer: ((b))

One, at 3π/2

The correct answer is option 2

CONCEPT:

y = f(x)

x ∈ [a,e]

f(a) is local minima

f(c) is local maxima

f(d) is local minima

f(e) is local maxima

Absolute max OR global max OR greatest value = max(f(c),f(e)) =f(e)

Absolute min OR global min OR least value = max(f(a),f(d)) =f(d)

EXPLANATION:

Graph of sin(x)

So local minima One, at 3π/2 in the interval x ∈ [π/4, 7π/4].

20

The protocol data unit (PDU) for the application layer in the Internet stack is

  1. ((a))

    Segment

  2. ((b))

    Datagram

  3. ((c))

    Message

  4. ((d))

    Frame

Show Answer
Answer: ((c))

Message

The correct answer is option 3

CONCEPT

PDU for the application layer is messages.

Additional Information

  • A protocol data unit (PDU) is a single unit of information transmitted among peer entities of a computer network.
  • PDU for the physical layer is bits.
  • PDU for the data link layer is a frame.
  • PDU for the network layer is packets.
  • PDU for the transport layer is a segment.
21

Let A be the 2 × 2 matrix with elements a11 = a12 = a21 = +1 and a22 = −1. Then the eigenvalues of the matrix A19 are

  1. ((a))

    1024 and −1024

  2. ((b))

    1024√2 and −1024√2

  3. ((c))

    4√2 and −4√2

  4. ((d))

    512√2 and −512√2

Show Answer
Answer: ((d))

512√2 and −512√2

The correct answer is "option 4".

CONCEPT:

According to Cayley Hamilton theorem:

If matrix A has Eigenvalue ‘x’ then An has Eigenvalue as xn.

DATA:

According to the given values,

a11 = a12 = a21 = 1, a22 = -1

The 2 x 2 matrix will be: A=[11 11 ]A = \left[ \begin{matrix} 1 & 1 \ 1 & -1 \ \end{matrix} \right]

CALCULATION:

Considering characteristic equation is |A - λ I| = 0

where λ is eigen value and I is identity matrix

∴ Characteristics equation is given by

\(\left| \begin{array}{*{35}{r}} 1-\lambda & 1 \ 1 & -1-\lambda \ \end{array} \right|=0\)

Solving the matrix,

−(1 − λ).(1 + λ) − 1 = 0

−(1 − λ2) – 1 = 0

− 2 + λ2 = 0

λ2 = 2

λ = ±(2)1/2

Therefore the Eigen values are:

((2)1/2)19= 29 x (2)1/2 = 512√2

((-2)1/2)19= (−1)9  x 29 x (2)1/2 = −512√2

Hence the correct answer is "option 4".

22

What is the complement of the language accepted by the NFA shown below?

Assume ∑ = {a} and ϵ is the empty string

  1. ((a))

    Φ

  2. ((b))

    {ϵ}

  3. ((c))

    a*

  4. ((d))

    (a, ϵ)

Show Answer
Answer: ((b))

{ϵ}

The correct answer is "option 2".

EXPLANATION:

NFA is:

Consider, ∑ = {a} and ϵ is the empty string

The ∑ = {a} and the NFA accept the following strings:

{a, aa, aaa, aaaa,……}

That means, the language accepted by the regular expression is {a+}

Therefore, the complement of the language is:

= {a* - a+}

= ϵ

Hence, the correct answer is "option 2".

23

What is the correct translation of the following statement into mathematical logic?

“Some real numbers are rational”

  1. ((a))

    ∃x (real(x) ∨ rational(x))

  2. ((b))

    ∀x (real(x) → rational(x)) 

  3. ((c))

    ∃x (real(x) ∧ rational(x)) 

  4. ((d))

    ∃x (rational(x) → real(x))

Show Answer
Answer: ((c))

∃x (real(x) ∧ rational(x)) 

The correct answer is option 3.

STATEMENT:

“Some real numbers are rational”

Option 1: Incorrect

There exist some numbers which are either real OR rational

Option 2: Incorrect

All real numbers are rational

Option 3: Correct

There exist some numbers which are both real and rational

Option 4: Incorrect

There exists a number such that if it is rational, it is real​

24

Given the basic ER and relational models, which of the following is INCORRECT?

  1. ((a))

    An attribute of an entity can have more than one value

  2. ((b))

    An attribute of an entity can be composite

  3. ((c))

    In a row of a relational table, an attribute can have more than one value

  4. ((d))

    In a row of a relational table, an attribute can have exactly one value or a NULL value

Show Answer
Answer: ((c))

In a row of a relational table, an attribute can have more than one value

The correct answer is "option 3".

EXPLANATION:

Option 1: CORRECT

In the Entity-Relationship model or ER model, the Multi-valued attributes of any entity can have one or more attribute values.

In a single-valued attribute, any entity can only have a single attribute value.

Option 2: CORRECT

In ER model, the attribute which can be further broken down into more attribute values is known as the “composite attribute”.

So, an attribute of an entity can be composite.

Option 3: INCORRECT

In the Entity-Relationship model or ER model, the Multi-valued attributes of any entity can have one or more attribute values.

An attribute can have multiple attribute values but not in a row of relational tables.

In a relational table, rows must contain atomic values.

Option 4: CORRECT

In the Relational model, the values of the intersection of one row & column should contain either:

  1. Exactly one value or
  2. Null value.

Hence the correct answer is “option 3”.

25

Which of the following statements are TRUE about an SQL query?

P: An SQL query can contain a HAVING clause even if it does not have a GROUP BY clause

Q: An SQL query can contain a HAVING clause only if it has a GROUP BY clause

R: All attributes used in the GROUP BY clause must appear in the SELECT clause

S: Not all attributes used in the GROUP BY clause need to appear in the SELECT clause

  1. ((a))

    P and R

  2. ((b))

    P and S

  3. ((c))

    Q and R

  4. ((d))

    Q and S

Show Answer
Answer: ((c))

Q and R

The correct answer is option 3

EXPLANATION:

GROUP BY clause:

  • The GROUP BY statement groups rows that have the same values into summary rows, like "find the number of customers in each country".
  • The GROUP BY statement is often used with aggregate functions (COUNT, MAX, MIN, SUM, AVG) to group the result-set by one or more columns.

Syntax:

SELECT column_name(s)

FROM table_name

WHERE condition

GROUP BY column_name(s)

Example:

SELECT COMPANY, COUNT(*)  

FROM PRODUCT_MAST   

GROUP BY COMPANY 

Therefore all attributes used in the GROUP BY clause must appear in the SELECT clause 

HAVING clause:

  • HAVING clause is used to specify a search condition for a group or an aggregate.
  • Having is used in a GROUP BY clause.
  • If you are not using GROUP BY clause then you can use HAVING function like a WHERE clause.

Syntax:

SELECT column1, column2   

FROM table_name  

WHERE conditions   

GROUP BY column1, column2   

HAVING conditions  

ORDER BY column1, column2;  

 

Example:

SELECT COMPANY, COUNT(*)  

FROM PRODUCT_MAST   

GROUP BY COMPANY  

HAVING COUNT(*)>2; 

Therefore an SQL query can contain a HAVING clause only if it has a GROUP BY clause.

Confusion Points

The answer is as per standard SQL

26

The recurrence relation capturing the optimal execution time of the Towers of Hanoi problem with ṅ discs is

  1. ((a))

    T(n) = 2T(n − 2) + 2

  2. ((b))

    T(n) = 2T(n − 1) + n

  3. ((c))

    T(n) = 2T(n/2) + 1

  4. ((d))

    T(n) = 2T(n − 1) + 1

Show Answer
Answer: ((d))

T(n) = 2T(n − 1) + 1

The correct answer is option 4

Concept

Rule Of Towers of Hanoi problem:

Tower of Hanoi is a mathematical puzzle where we have three poles and n disks. The main goal in the puzzle is to move the entire stack to another pol, obeying the following simple rules: 

  1. Only one disk can be moved at a time.
  2. Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack i.e. a disk can only be moved if it is the uppermost disk on a stack.
  3. No disk may be placed on top of a smaller disk.

Solution Of Towers of Hanoi problem:

Begin with n disks on pole one

  1. We can transfer top n-1 disks from pole1 to pole3 using T(n-1) moves
  2. We keep the largest disk fixed during these moves
  3. Then, we use one move to transfer the largest disk to the second pole.
  4. We can transfer top n-1 disks on pol3 to pol2 using T(n-1) additional moves, placing them on top of the largest disk, which always stays on the bottom of pol2

Moreover, it is easy to say that the puzzle can not be solved using fewer steps. This shows that

The recurrence relation capturing the optimal execution time of the Towers of Hanoi problem with ṅ discs is

T(n) = 2T(n − 1) + 1

Example:

Follow the above algorithm to solve the problem of the Tower of Hanoi

here we have three-pole and also have three disks

 

27

Let G be a simple undirected planar graph on 10 vertices with 15 edges. If G is a connected graph, then the number of bounded faces in any embedding of G on the plane is equal to

  1. ((a))

    3

  2. ((b))

    4

  3. ((c))

    5

  4. ((d))

    6

Show Answer
Answer: ((d))

6

The correct answer is "option 4".

CONCEPT:

A planar graph is a graph that can be drawn on the plane in such a way that its edges must intersect only at their endpoints.

In a planar graph, the graph is drawn in such a way that no edges must cross each other.

The graph whose edges overlap or cross each other is known as a Non-planar graph.

A graph to be planar must satisfy the following Euler’s formula:

v - e + f = 2

where

v is the number of vertices

e is the number of edges

f is the number of faces 

CALCULATION

v = 10, e = 15

According to Euler’s formula:

v - e + f = 2 

10 – 15 + f = 2

f = 2 – 10 + 15

f = 7

Out of 7, there will be always one unbounded face.

So, the number of faces is 6.

Hence, the correct answer is "option 4".

28

Let W(n) and A(n) denote respectively, the worst case and average case running time of an algorithm executed on an input of size n. Which of the following is ALWAYS TRUE?

  1. ((a))

    A(n) = Ω (W(n))

  2. ((b))

    A(n) = Θ (W(n))

  3. ((c))

    A(n) = O (W(n))

  4. ((d))

    A(n) = o (W(n))

Show Answer
Answer: ((c))

A(n) = O (W(n))

The correct answer is "option 3".

CONCEPT:

There are three types of complexities:

  1. Worst case: It is the maximum running time taken by any algorithm. 
  2. Average case: It is the average running time taken by any algorithm. 
  3. Best case: It is the minimum running time taken by any algorithm. 

EXPLANATION:

The average case time can be equal to or lesser than the worst case.

So, A(n) would be the upper bound case by W(n).

Also, it will not be a strict upper bound as it can be the same as an average case like Merge sort.

Therefore,

A(n) = O(W(n))

Hence the correct answer is "option 3".

29

The amount of ROM needed to implement a 4 bit multiplier is

  1. ((a))

    64 bits

  2. ((b))

    128 bits

  3. ((c))

    1 Kbits

  4. ((d))

    2 Kbits

Show Answer
Answer: ((d))

2 Kbits

The correct answer is option 4

Explanation:

A ROM cannot be written and implement with the 4-bit multiplier, so we must store all possible combinations of 2× 24 inputs and their corresponding output bits giving a total of 24 × 24 × 8 bits, that is 2 Kbits.

So, the amount of ROM needed to implement a 4-bit multiplier is 2 Kbits.

Let's take an example of two 4 bit number multiplication

Let A=;a3a2a1a0{\rm{A}} = {\rm{;}}{{\rm{a}}_3}{{\rm{a}}_2}{{\rm{a}}_1}{{\rm{a}}_0}

B=b3b2b1b0{\rm{B}} = {{\rm{b}}_3}{{\rm{b}}_2}{{\rm{b}}_1}{{\rm{b}}_0}

Then

Additional Information

Multiplication of two n bit number will result in data = (2n) bits

Multiplication of two n bit number needs 2n address lines

Size of ROM = 22n × 2n bits

n = 4

Size of ROM = 22×4 × 2(4) bits

Size of ROM = 211 bits

Size of ROM = 2Kbits

  

G → Giga, M → mega, K → kilo

1 G = 230

1 M = 220

1 K = 210

30

Register renaming is done in pipelined processors:

  1. ((a))

    As an alternative to register allocation at compile time

  2. ((b))

    For efficient access to function parameters and local variables

  3. ((c))

    To eliminate certain kind of hazards

  4. ((d))

    As part of address translations

Show Answer
Answer: ((c))

To eliminate certain kind of hazards

  • Register renaming technique is used to eliminate false data dependencies arising from the reuse of registers by successive instructions that do not have any real data dependencies between them.
  • The elimination of these false data dependencies reveals more instruction-level parallelism in an instruction stream, which can be exploited by various and complementary techniques such as superscalar and out-of-order execution for better performance.
  • Register renaming is done in pipelined processors to eliminate WAR/WAW hazards.

Important Points:

WAR → write after read

WAW → write after write

31

Consider a random variable X that takes values +1 and −1 with probability 0.5 each. The values of the cumulative distribution function F(x) at x = −1 and +1 are

  1. ((a))

    0 and 0.5

  2. ((b))

    0 and 1

  3. ((c))

    0.5 and 1

  4. ((d))

    0.25 and 0.75

Show Answer
Answer: ((c))

0.5 and 1

The correct answer is option 3

Concept:

Cumulative Distribution Function

If f(x) is the probability density function and F(X) is the cumulative distribution function then the relation between both of them is:

F(X) = P[X ≤ x] = \(\mathop \smallint \nolimits_{ - \infty }^x f\left( x \right)dx\) = sum of all values less than equal to x.

Explanation:

Given that P(-1) =0.5 and P(1) =0.5. So, at all other points, p must be zero as the sum of all probabilities must be 1.

F(X) is the cumulative distribution function and let P is the probability and given X is random variable, So

F(X) = P[X ≤ x]

F(-1)=P(X <= -1)

        = P(x = -1)

        =0.5

and F(1)=P(X <= 1)

              =P(x = -1) + P(x = 1)

              =0.5 + 0.5

             =1

So, the correct answer is option 3

32

Which of the following Application layer protocols is used to support electronic mail?

  1. ((a))

    SMTP

  2. ((b))

    IP

  3. ((c))

    TCP

  4. ((d))

    UDP

Show Answer
Answer: ((a))

SMTP

SMTP

  • Simple Mail Transfer Protocol (SMTP) is the standard protocol for sending emails across the Internet. Therefore, SMTP transfers messages from the sender’s mail servers to the recipient’s mail server.

Additional Information

TCP:

TCP is the transfer layer protocol. Electronic mail function is supported by the transfer layer protocol TCP. TCP is a connection-oriented and reliable transport protocol. Therefore, SMTP transfer messages from the sender’s mail servers to the recipient’s mail servers using TCP

UDP:

  • UDP is an unreliable connectionless-transport layer Protocol used for its simplicity and efficiency in applications where error can be provided by the application layer
  • UDP provided process-to-process communication
33

In the IPv4 addressing format, the number of networks allowed under Class C addresses is

  1. ((a))

    220

  2. ((b))

    224

  3. ((c))

    214

  4. ((d))

    221

Show Answer
Answer: ((d))

221

IPv4 address: 32 bits

IP address = Network ID + Host ID

Network ID + Host ID =32

PREFIX is the part of the Network ID

ClassPREFIX (bits reserved from 1st byte)Network ID (bits)Range of 1st byteNo. of IP address consumedNumber of networksIP address per networkHost per networkPercentage of IPV4 address consumed​
Class A080 -12723127224224 – 250%
Class B1016128-191230214216216 – 225%
Class C11024192 -2232292212828 – 212.5%
Class D1110-224- 239228MULTICAST ADDRESS6.25%
Class E1111-239-255228RESERVED FOR FUTURE6.25%
34

Which of the following problems are decidable?

  1. Does a given program ever produce an output?

  2. If L is a context-free language, then, is L̅  also context-free?

  3. If L is a regular language, then, is L̅  also regular?

  4. If L is a recursive language, then, is L̅  also recursive?

  1. ((a))

    1, 2, 3, 4

  2. ((b))

    1, 2

  3. ((c))

    2, 3, 4

  4. ((d))

    3, 4

Show Answer
Answer: ((d))

3, 4

The correct answer is option 4

CONCEPT:

Decidable language: A language is decidable if there exists a Turing machine which halts or accepts it.

EXPLANATION:

1: Undecidable

There is no TM to determine whether a given program will produce an output.

2: Undecidable

Context-free languages are not closed under complementation.

3: Decidable

Regular languages are closed under complementation.

4: Decidable

Recursive languages are closed under complementation.

So option 4 is correct

35

Given the language L = {ab, aa, baa}, which of the following strings are in L * ?

  1. abaabaaabaa

2) aaaabaaaa

  1. baaaaabaaaab

  2. baaaaabaa

  1. ((a))

    1, 2 and 3

  2. ((b))

    2, 3 and 4

  3. ((c))

    1, 2 and 4

  4. ((d))

    1, 3 and 4

Show Answer
Answer: ((c))

1, 2 and 4

The correct answer is option 3.

Key Points

Option 1: abaabaaabaa

               The combination of {ab,aa, baa} forms abaabaaabaa. And this is correct combination.

               "ab aa baa ab aa"

Option 2: aaaabaaaa

               The combination of {ab,baa} forms aaaabaaaa. And this is correct combination.

               “aa aa baa aa”

Option 3: baaaaabaaaab

                This is not a correct combination of {ab,aa,baa}. Ending with 'b' can not get from given strings.

               "baa aa ab aa aab"

Option 4: baaaaabaa

               The combination of {ab,aa, baa} forms baaaaabaa. And this is the correct combination.

               "baa aa ab aa"

Hence the correct answer is 1, 2 and 4.

36

Which of the following graphs is isomorphic to

  1. ((a))

  2. ((b))

  3. ((c))

  4. ((d))

Show Answer
Answer: ((b))

The correct answer is "option 2".

EXPLANATION:

The original graph is:

Option 1: Not an Isomorphic

The original graph doesn’t contain 3 cycle sub-graph but this graph contains.

So this is not an isomorphic graph.

Option 2: An Isomorphic

This graph contains a 5 cycle graph as in the original graph and the max degree of this graph is 4.

 So, this is an isomorphic graph.

Option 3: Not an Isomorphic

The original graph doesn’t contain a node having degree 3 but this graph contains.

So this is not an isomorphic graph.

Option 4: Not an Isomorphic

The original graph doesn’t contain 4 cycle sub-graph but this graph contains.

So this is not an isomorphic graph.

37

Consider the following transactions with data items P and Q initialized to zero:

T1 :read (P);

read (Q);

if P = 0 then Q := Q + 1 ;

write (Q).

T2 : read (Q);

read (P);

if Q = 0 then P := P + 1 ;

write (P).

Any non-serial interleaving of T1 and T2 for concurrent execution leads to

  1. ((a))

    a serializable schedule

  2. ((b))

    a schedule that is not conflict serializable

  3. ((c))

    a conflict serializable schedule

  4. ((d))

    a schedule for which a precedence graph cannot be drawn

Show Answer
Answer: ((b))

a schedule that is not conflict serializable

The correct answer is option 2.

Key Points

P and Q are initialized to Zero, write operation on P and Q will be executed.

Consider any non-serial schedule like R1(P), R2(Q), R1(Q), R2(P), W1(Q), W2(P). R1(P) conflicts with W2(P) Hence T1 must be before T2. R2(Q) conflicts with W1(Q) Hence T2 must be before T1. There is no serial schedule that satisfies both of them hence it does not conflict with serializable.

Hence the correct answer is a schedule that is not conflict serializable.

38

The bisection method is applied to compute a zero of the function f(x) = x4 – x3 – x2 – 4 in the interval [1, 9]. The method converges to a solution after _______ iterations.

  1. ((a))

    1

  2. ((b))

    3

  3. ((c))

    5

  4. ((d))

    7

Show Answer
Answer: ((b))

3

Concept:

Bisection method:

Used to find the root for a function. Root of a function f(x) = a such that f(a)= 0

Property: if a function f(x) is continuous on the interval [a…b] and sign of f(a) ≠  sign of f(b). There is a value c belongs to [a…b] such that f(c) = 0, means c is a root in between [a….b]

Note:

Bisection method cut the interval into 2 halves and check which half contains a root of the equation.

  1. Suppose interval [a…b] .

  2. Cut interval in the middle to find m : m=a+b2m =\frac{{a+b}}{{2}}

  3. sign of f(m) not matches with f(a) proceed the search in the new interval.

Calculation:

The bisection method is applied to a given problem with [1, 9]

After 1 iteration

x1=1;+;92=5{x_1} = \frac{{1; + ;9}}{2} = 5

Now since f(x1) > 0, x2 replaces x1

Now, x0 = 1 and x1 = 5

And after 2nd iteration 

x2=1;+;52=3{x_2} = \frac{{1; + ;5}}{2} = 3

Now since f(x1) f(x2) > 0, x2 replaces x1 and x0 = 1 and x1 = 3 and after 3rd iteration

x2=1;+;32=2{x_2} = \frac{{1; + ;3}}{2} = 2

Now, f(x2) = f(2) = 24 – 23 – 22 – 4 = 0

So the method converges exactly to the root in 3 iterations.

39

Let G be a weighted graph with edge weights greater than one and G' be the graph constructed by squaring the weights of edges in G. Let T and T' be the minimum spanning trees of G and G', respectively, with total weights t and t'. Which of the following statements is TRUE?

  1. ((a))

    T' = T with total weight t' = t2

  2. ((b))

    T' = T with total weight t' < t 2

  3. ((c))

    T' ≠ T but total weight t' = t2

  4. ((d))

    None of the above

Show Answer
Answer: ((d))

None of the above

The correct answer is “option 4”.

CONCEPT:

A spanning tree of graph G is a subset of G which has all vertices covered with the minimum possible number of edges.

Some properties of spanning tree are:

  1. Spanning tree doesn’t contain any cycle.
  2. Spanning tree cannot be disconnected.

Every connected and undirected graph G has at least one spanning tree.

EXPLANATION:

Consider graph G with edge weights > 1,

Consider graph G’ with squared edge weights of graph G,

The minimum spanning tree (T) of graph G is:

Minimum Spanning Tree (T’) of graph G’ is:

So, T is not equal to T'and t' < t2.

Hence, the correct answer is "option 4".

40

What is the minimal form of the Karnaugh map shown below?

Assume that X denotes a don’t care term

  1. ((a))

    b̅ d̅ 

  2. ((b))

    b̅ d̅ + b̅ c̅ 

  3. ((c))

    b̅ d̅ + a b̅ c̅ d

  4. ((d))

    b̅ d̅ + b̅ c̅ + c̅ d̅ 

Show Answer
Answer: ((b))

b̅ d̅ + b̅ c̅ 

The correct answer is “option 2”.

CONCEPT:

Karnaugh Map is used to simplify Boolean algebra expressions.

It is a graphical technique of simplifying Boolean expressions.

It is also known as K-map.

K-map contains two types of methods:

  1. SOP (Sum Of Product): This produces logical expressions that contain OR of multiple AND terms.

Example: b̅.d̅ + d̅.c̅ 

  1. POS (Product Of Sum): This produces logical expressions that contain AND of multiple OR terms.

Example: (b̅ + d̅)(d̅ + c̅)

EXPLANATION:

The first quad will form from the K-map:

(ab – 00, 10, cd – 00,10)

Value is: b̅.d̅ 

The second quad will form from the K-map:

(ab – 00, 10, cd – 00,01)

Value is c̅.b̅

So, the minimal form of the given K-map is b̅.d̅ + c̅.b̅**.**

Hence, the correct answer is "option 2".

41

Consider the 3 processes, P1, P2 and P3 shown in the table.

ProcessArrival timeTime unit Required
P105
P217
P334

 

The completion order of the 3 processes under the policies FCFS and RR2 (round robin scheduling with CPU quantum of 2 time units) are

  1. ((a))

    FCFS: P1, P2, P3 RR2: P1, P2, P3

  2. ((b))

    FCFS: P1, P3, P2 RR2: P1, P3, P2

  3. ((c))

    FCFS: P1, P2, P3    RR2: P3, P1, P2

  4. ((d))

    FCFS: P1, P3, P2 RR2: P1, P2, P3

Show Answer
Answer: ((b))

FCFS: P1, P3, P2 RR2: P1, P3, P2

Correct Explanation for FCFS and RR2 Scheduling

🔹 Given:

ProcessArrival TimeBurst Time
P105
P217
P334

🔸 FCFS (First Come First Serve)

  • P1 arrives at time 0 → executed first → finishes at time 5
  • P2 arrives at time 1 → executed next → finishes at time 5 + 7 = 12
  • P3 arrives at time 3 → executed last → finishes at time 12 + 4 = 16

✅ FCFS Completion Order: P1, P2, P3

🔸 RR2 (Round Robin with Time Quantum = 2)

  • Time 0–2: P1 executes → remaining = 3
  • Time 2–4: P2 executes → remaining = 5
  • Time 4–6: P3 executes → remaining = 2
  • Time 6–8: P1 executes → remaining = 1
  • Time 8–10: P2 executes → remaining = 3
  • Time 10–12: P3 executes → completes ✅
  • Time 12–13: P1 executes → completes ✅
  • Time 13–15: P2 executes → remaining = 1
  • Time 15–16: P2 executes → completes ✅

✅ RR2 Completion Order: P3, P1, P2

📌 Summary

Scheduling PolicyCompletion Order
FCFSP1, P2, P3
RR2P3, P1, P2

✔️ Final Answer: FCFS: P1, P2, P3    RR2: P3, P1, P2

42

Fetch_And_Add(X, i) is an atomic Read-Modify-Write instruction that reads the value of memory location X, increments it by the value i, and returns the old value of X. It is used in the pseudocode shown below to implement a busy-wait lock. L is an unsigned integer shared variable initialized to 0. The value of 0 corresponds to lock being available, while any non-zero value corresponds to the lock being not available.

AcquireLock(L){

        while (Fetch_And_Add(L,1))

                  L = 1;

}

ReleaseLock(L){

        L = 0;

}

This implementation

  1. ((a))

    fails as L can overflow

  2. ((b))

    fails as L can take on a non-zero value when the lock is actually available

  3. ((c))

    works correctly but may starve some processes

  4. ((d))

    works correctly without starvation

Show Answer
Answer: ((b))

fails as L can take on a non-zero value when the lock is actually available

The correct answer is option 2

CONCEPT:

M=Fetch_And_Add(X, I) //return previous value of i

if X=10 and i=2

then X=X+2 =10+2 =12

M=2 // because return previous value of i is 2

EXPLANATION:

AcquireLock(L){

  1. while (Fetch_And_Add(L,1)) //if Fetch_And_Add(L,1) return 0 then go to CS otherwise going into loop 2.   L = 1;

}

ReleaseLock(L){

3.        L = 0;

}

Option 1: TRUE

P1P2P3P4P5--------Pn
L=0 L=1 CSL=1 L=2L=2 L=3L=3 L=4L=3 L=5……..L=n L=n+1
<br>

Let's take 4-bit register

if n=15

1111 +   1 10000  //overflow

Here overflow occurs and L becomes zero so it fails

Option 2: TRUE

1,2,3 shows the execution of line number

when P0 execute line number 3 then L=0 and lock is available but P1 fall into an infinite loop

So, fails as L can take on a non-zero value when the lock is actually available

Confusion Points

Option 1 is also the correct answer and the given answer is as per the official answer key, that is, option 2

43

Suppose a fair six-sided die is rolled once. If the value on the die is 1, 2, or 3, the die is rolled a second time. What is the probability that the sum total of values that turn up is at least 6?

  1. ((a))

    10/21

  2. ((b))

    5/12

  3. ((c))

    2/3

  4. ((d))

    1/6

Show Answer
Answer: ((b))

5/12

The correct answer is "option 2".

EXPLANATION:

Value on the die for the first time:

{1, 2, 3}                                  

Value on the die for the second time:

{1, 2, 3, 4, 5, 6}

Therefore, values are:

First value =1(1,1)(1,2)(1,3)(1,4)(1,5)(1,6)
Sum234567
First value =2(2,1)(2,2)(2,3)(2,4)(2,5)(2,6)
Sum345678
First value =3(3,1)(3,2)(3,3)(3,4)(3,5)(3,6)
Sum456789

 

Sample space = 36

The sum must be at least 6 so,

Values of dice are: (1,5), (1,6), (2,4), (2,5), (2,6), (3,3), (3,4), (3,5), (3,6)

So, 9/36 is the probability of getting 6 when both dices are thrown.

If the value of dice comes to 6 in the first dice then there is no need to roll it again.

Prob. of getting 6 is: 1/6

Total probability = 1/6 + 9/36

                               = 5/12

Hence, the correct answer is “option 2”.

44

An Internet Service Provider (ISP) has the following chunk of CIDR-based IP addresses available with it: 245.248.128.0/20. The ISP wants to give half of this chunk of addresses to Organization A, and a quarter to Organization B, while retaining the remaining with itself. Which of the following is a valid allocation of addresses to A and B?

  1. ((a))

    245.248.136.0/21 and 245.248.128.0/22

  2. ((b))

    245.248.128.0/21 and 245.248.128.0/22

  3. ((c))

    245.248.132.0/22 and 245.248.132.0/21

  4. ((d))

    245.248.136.0/24 and 245.248.132.0/21

Show Answer
Answer: ((a))

245.248.136.0/21 and 245.248.128.0/22

The correct answer is Option 1.

Key Points

 

Since Half of 4096 post addresses must be given organization A, we can set the 12th bit to 1, include that bit into the network path of organization A. So the valid allocation of address to A is 245.248.136.0/21.

The 12th bit is set to 0, but we need only half of the 2048 address, 13th bit can be set to be 0 addresses to B is 245.248.128.0/22.

Hence the correct answer is 245.248.136.0/21 and 245.248.128.0/22.

45

Suppose a circular queue of capacity (n −1) elements is implemented with an array of n elements. Assume that the insertion and deletion operations are carried out using REAR and FRONT as array index variables, respectively. Initially, REAR = FRONT = 0. The conditions to detect queue full and queue empty are

  1. ((a))

    full: (REAR+1) mod n == FRONT empty: REAR == FRONT

  2. ((b))

    full: (REAR+1) mod n == FRONT empty: (FRONT+1) mod n == REAR

  3. ((c))

    full: REAR == FRONT empty: (REAR+1) mod n == FRONT

  4. ((d))

    full: (FRONT+1) mod n == REAR empty: REAR == FRONT

Show Answer
Answer: ((a))

full: (REAR+1) mod n == FRONT empty: REAR == FRONT

The correct answer is "option 1".

CONCEPT:

A circular queue is a queue whose last position is connected back to the first position.

ENQUEUE – It is the operation to insert elements into the queue.

DEQUEUE – It is the operation to delete elements from the queue.

After inserting an element in the last position, the next element again gets inserted into the first position.

EXPLANATION:

Given, Rear = Front = 0

Here, the Rear is used to insert elements & the front is used to delete elements.

To check full condition in queue:

(Rear + 1) % n == Front

Example: Consider queue is full that means Rear = 6, front = 0, n = 7

(6+1) % 7 = 7 % 7 = 0

To check empty condition in queue:

Rear == Front

Example: Consider queue is empty that means Rear = 0, front = 0, n = 7

Rear = Front = 0

Hence, the correct answer is “option 1”.

46

Consider the program given below, in a block-structured pseudo-language with lexical scoping and nesting of procedures permitted.

Program main;

     Var ...

Procedure A1;

     Var ...

     Call A2;

End A1

Procedure A2;

      Var ...

      Procedure A21;

      Var ...

      Call A1;

      End A21

      Call A21;

      End A2

     Call A1;

End main.

Consider the calling chain: Main →  A1 → A2 → A21 → A1

The correct set of activation records along with their access links is given by

  1. ((a))

  2. ((b))

  3. ((c))

  4. ((d))

Show Answer
Answer: ((d))

The correct answer is “option 4”.

The access link is a pointer to the activation record.

A direct implementation of the normal static scope rule for a nested function is obtained by adding a pointer called access link to each activation record.

Consider any procedure P, if P is nested immediately within procedure Q in any code, then access link in any activation of P points to the most recent activation of Q.

EXPLANATION:

Main →  A1 → A2 → A21 → A1

Activation records are created at procedure exit time.

Since A1 & A2 are defined under Main ().

A1 & A2 access links are pointed to the main function.

A21 is defined under A2, so its access link will point to A2.

Hence, the correct answer is “option 4”.

47

How many onto (or surjective) functions are there from an n-element (n ≥ 2) set to a 2-element set?

  1. ((a))

    2n

  2. ((b))

    2n - 1

  3. ((c))

    2n - 2

  4. ((d))

    2(2n - 2)

Show Answer
Answer: ((c))

2n - 2

The correct answer is “option 3”.

CONCEPT:

An Onto function is such a function that for every element in the codomain, there exists an element in the domain that maps to it.

A function f from A to B is known as Onto function if**:**

For all 'b' in B, there is an 'a' in A such that f(a) = b.

In other words, all elements of B are used.                   

The onto function is:

The non-onto function is:

Here, value 3 is not used.

CALCULATION:

Consider number of elements in m & n respectively.

Number of onto functions possible is:

nm – nC1(n-1)m + nC2(n-2)m +……

Here, m = n, n= 2

= 2n – 2C1(2-1)n + 2C2(2-2)n

= 2n – 2×1 + 0

= 2n – 2 

Hence, the correct answer is “option 3”.

48

Let G be a complete undirected graph on 6 vertices. If vertices of G are labeled, then the number of distinct cycles of length 4 in G is equal to

  1. ((a))

    15

  2. ((b))

    30

  3. ((c))

    45

  4. ((d))

    360

Show Answer
Answer: ((c))

45

The correct answer is “option 3”.

CONCEPT:

A graph that contains an edge between every pair of vertices is known as a complete graph.

A complete graph with 6 vertices is:

EXPLANATION:

To get a cycle to length 4, edges of length 4 can be selected to form a cycle.

To get the cycle of length 4, select any 4 vertices.

The number of selection of 4 vertices out of 6 vertices is: 6C4 i.e. 15

Example:

Consider 4 vertices {a, b, c, d}, total cycles using 4 vertices are:

a-b-c-d, a-b-d-c, a-c-b-d, a-c-d-b, a-d-b-c, a-d-c-b

Therefore, number of cycle using n vertices is (n-1)!

But number of distinct cycles of length 4 with vertices (a,b,c,d) is 3.

{Since abcd and adcb are same, in different directions}

So, the total number of distinct cycles of length 4 is:

= 15 × 3

= 45

Hence, the correct answer is "option 3".

49

A list of n strings, each of length n, is sorted into lexicographic order using merge - sort algorithm. The worst case running time of this computation is:

  1. ((a))

    O(n log n)

  2. ((b))

    O(n2 log n)

  3. ((c))

    O(n2 + log n)

  4. ((d))

    O(n3)

Show Answer
Answer: ((b))

O(n2 log n)

The correct answer is "option 2".

CONCEPT:

The Recurrence relation for the number of comparisons needed to sort an array of n integers is:

T(n) = 2T(n/2) + n

= O(nlog2n)

EXPLANATION:

Consider n strings of length n in place of each integer, since each integer takes O(1) time to sort then,

Complexity to sort one string of size n - O(n)

Complexity to sort n strings of size n - O(n * nlog2n) = O(n2log2n)

Hence, worst case running time is O(n2log2n).

50

Consider the directed graph shown in the figure below. There are multiple shortest paths between vertices S and T. Which one will be reported by Dijkstra’s shortest path algorithm? Assume that, in any iteration, the shortest path to a vertex v is updated only when a strictly shorter path to v is discovered.

  1. ((a))

    SDT

  2. ((b))

    SBDT

  3. ((c))

    SACDT

  4. ((d))

    SACET

Show Answer
Answer: ((d))

SACET

The correct answer is “option 4”.

CONCEPT:

Dijkstra’s algorithm is an algorithm used for finding the shortest paths between nodes or vertices in a graph.

 This algorithm is basically used to find the shortest path from a starting node to a target node in a weighted graph.

This algorithm creates a tree of the shortest path from a vertex to other nodes in the graph.

This algorithm assigns initial distance values & will try to improve step by step.

Dijkstra’s algorithm works as follows**:**

  1. It initializes distances according to the algorithm.
  2. Pick a node and calculate the distance to adjacent nodes.
  3. Pick the next node with the smallest distance & repeat distance calculations.
  4. Find the result of the shortest-path tree.

CALCULATION:

SACEGDBFT
S0
SB0473SELECT B
SBA0473SELECT A
SBAC04573SELECT C
SBACE045673SELECT E
SBACED045687310SELECT D
SBACEDT04568731210SELECT T

The shortest-path tree is:

Hence, the shortest path from S to T is S → AC → ET.

51

A file system with 300 GByte disk uses a file descriptor with 8 direct block addresses, 1 indirect block address and 1 doubly indirect block address. The size of each disk block is 128 Bytes and the size of each disk block address is 8 Bytes. The maximum possible file size in this file system is

  1. ((a))

    3 KBytes

  2. ((b))

    35 KBytes

  3. ((c))

    280 KBytes

  4. ((d))

    dependent on the size of the disk

Show Answer
Answer: ((b))

35 KBytes

The correct answer is option 2

DATA:

In the index node of a Unix- style file system,

Direct Block pointer = 8

Single Indirect Block pointer = 1

Double Indirect Block pointer = 1

Disk block address = disk block entries size = 8 B

Disk Block size = 128 B

CALCULATION:

Number of entries in a block = disk;block;sizedisk;block;address;size=128;B8;B\frac{disk; block; size}{disk; block; address; size} = \frac{128; B}{8;B}  = 24

File size = (8 direct + 1 singel indirect + 1 double indirect) × Block size

File size = (8 × 1 + 1 × 24 + 1 × 24 × 24 ) × 128 B

File size = (210 B + 211 B + 215 B )

File size = (1 + 2 + 32)KB

The maximum size of file is 35 KB or 35 KBytes

52

Consider the virtual page reference string

1, 2, 3, 2, 4, 1, 3, 2, 4, 1

on a demand paged virtual memory system running on a computer system that has main memory size of 3 page frames which are initially empty. Let LRU, FIFO and OPTIMAL denote the number of page faults under the corresponding page replacement policy. Then

  1. ((a))

    OPTIMAL < LRU < FIFO

  2. ((b))

    OPTIMAL < FIFO < LRU

  3. ((c))

    OPTIMAL = LRU

  4. ((d))

    OPTIMAL = FIFO

Show Answer
Answer: ((b))

OPTIMAL < FIFO < LRU

The correct answer is Option 2.

Concept:

First In First Out (FIFO):

In this algorithm, the operating system keeps track of all pages in the memory in a queue. The oldest page is in the front of the queue. When a page needs to be replaced page in the front of the queue is selected for removal.

Optimal Page replacement:

In this algorithm, pages are replaced which would not be used for the longest duration of time in the future.

Least Recently Used :

In this algorithm, the page will be replaced which is least recently used.

Solution: 

First In First Out (FIFO):

The given virtual page reference string is 1, 2, 3, 2, 4, 1, 3, 2, 4, 1 and the main memory size is 3-page frames.

1111444444
222211111
33333222
FFFHFFHFHH

Total number of page faults= 6

Optimal Page replacement:

1111111111
222444444
33333222
FFFHFHHFHH

Total number of page faults= 5

Least Recently Used :

1111444222
222223331
33311144
FFFHFFFFFF

Total number of page faults= 9

The number of page faults with OPTIMAL, FIFO, LRU (5,6,9) is OPTIMAL < FIFO < LRU.

53

Suppose R1(A, B) and R2(C, D) are two relation schemas. Let r1 and r2 be the corresponding relation instances. B is a foreign key that refers to C in R2. If data in r1 and r2 satisfy referential integrity constraints, which of the following is ALWAYS TRUE?

  1. ((a))

    ΠB(r1) - ΠC(r2) = Φ

  2. ((b))

    ΠC(r2) - ΠB(r1) = Φ

  3. ((c))

    ΠB(r1) = ΠC(r2)

  4. ((d))

    ΠB(r1) - ΠC(r2) ≠ Φ

Show Answer
Answer: ((a))

ΠB(r1) - ΠC(r2) = Φ

The correct answer is option 1

Concept:

Referential integrity constraints

  • In a relational database, a referential integrity constraint is specified between two tables with the help of a foreign key.
  • In the Referential integrity constraints, if a foreign key in Table 1 refers to the Primary Key of Table 2, then every value of the Foreign Key in Table 1 must be null or be available in Table 2.

B is a foreign key of R1 that refers to C(primary key) in R2, B must be null or to be available in R2

r2(C) is a superset of r1(B)

So {subset - Superset} =Φ

So the correct answer is ΠB(r1) - ΠC(r2) = Φ

Additional Information

functional dependency: Dependency of attributes in relations

Foreign key

  • A foreign key means that values in one table must also appear in another table. T
  • he referenced table is called the parent table while the table with the foreign key is called the child table.
  • The foreign key in the child table will generally reference a primary key in the parent table.

Primary key

  • A primary key is a specific choice of a minimal set of attributes (columns) that uniquely specify a tuple (row) in a relation (table). Primary key cannot accept null values and there can be only one primary key constraint for one table.
54

Consider a source computer (S) transmitting a file of size 106 bits to a destination computer (D) over a network of two routers (R1 and R2) and three links (L1, L2, and L3). L1 connects S to R1; L2 connects R1 to R2; and L3 connects R2 to D. Let each link be of length 100 km. Assume signals travel over each link at a speed of 108 meters per second. Assume that the link bandwidth on each link is 1Mbps. Let the file be broken down into 1000 packets each of size 1000 bits. Find the total sum of transmission and propagation delays in transmitting the file from S to D?

  1. ((a))

    1005 ms

  2. ((b))

    1010 ms

  3. ((c))

    3000 ms

  4. ((d))

    3003 ms

Show Answer
Answer: ((a))

1005 ms

The correct answer is option 1

Data:

Number of packets = n =1000

Size of each Packet = L = 1000 bits

The link bandwidth on each link is = BW = 1Mbps =106 bits/s

Each link be of length = d= 100 km

Signals travel over each link at a speed = v= 108m/s

Transmission delay = T

Propagation delay = P

Formula:

T=LBWT = \frac{L}{{BW}}

P=dvP = \frac{d}{v}

Calculation:

Propagation delay for the first packet to transmit S to R1

P=100×103108=1×103;s=1;msP = \frac{{100×10^3}}{{ {{10}^8}}} = {1\times10^{ - 3}};s = 1;ms

So, the propagation delay for the first packet to transmit S to D

P =1 × 3=3ms

Transmission delay for the first packet to transmit S to R1

T=10001×106=1×103;s=1;ms;T = \frac{{1000}}{{{{1\times10}^6}}} = 1 × {10^{ - 3}};s = 1;ms;

So, the transmission delay for the first packet to transmit S to D

T=1 × 3=3ms

So, total time is taken to transmit the first packet from S to D =P +T=6ms

Using pipelining, the remaining packet follows the first packet

then remaining every packet take 1ms to transmit from S to D

So, the total time is taken to transmit all 1000 packets from S to D is

⇒ time for the first packet + time for the remaining 999 packets

⇒ 6ms + 999ms

⇒ 1005ms

So, the total time is taken to transmit all 1000 packets from S to D is 1005ms.

55

Consider an instance of TCP’s Additive Increase Multiplicative Decrease (AIMD) algorithm where the window size at the start of the slow start phase is 2 MSS and the threshold at the start of the first transmission is 8 MSS. Assume that a timeout occurs during the fifth transmission. Find the congestion window size at the end of the tenth transmission. 

  1. ((a))

    8 MSS

  2. ((b))

    14 MSS

  3. ((c))

    7 MSS

  4. ((d))

    12 MSS

Show Answer
Answer: ((c))

7 MSS

The correct answer is option 3

EXPLANATION:

Initial window size or window size for first transmission: cwnd = 2 MSS

For 2nd transmission → cwnd = 22 = 4 MSS

For 3rd transmission → cwnd = 23 = 8 MSS

When threshold is reached then additive increase

For 4th transmission → cwnd = 8 + 1 = 9 MSS

For 5th transmission → cwnd = 9+ 1 = 10 MSS(fails)

Now window size reduced to 10/2 =5 MSS

For 6th transmission → cwnd = 1 MSS

For 7rd transmission → cwnd = 21 = 2 MSS

For 8th transmission → cwnd = 22 = 4 MSS

Thersoled reached now additive increase

For 9th transmission → cwnd = 4 + 1 = 5 MSS

For 10th transmission → cwnd = 5 + 1 =6 MSS

So, at the end of 10th successful transmission 

The congestion window size will be  6 + 1 = 7 MSS

56

Consider the set of strings on {0,1} in which, every substring of 3 symbols has at most two zeros. For example, 001110 and 011001 are in the language, but 100010 is not. All strings of length less than 3 are also in the language. A partially completed DFA that accepts this language is shown below.

The missing arcs in the DFA are

  1. ((a))
    00011011Q
    0010
    011
    100
    110
  2. ((b))
    00011011Q
    0001
    011
    100
    110
  3. ((c))
    00011011Q
    0010
    011
    100
    110
  4. ((d))
    00011011Q
    0010
    011
    100
    110
Show Answer
Answer: ((d))
00011011Q
0010
011
100
110

The correct answer is option 4.

Key Points

 L={All the strings of 0's and 1's where every substring of 3 symbols has at most 2 zero's }

Case 1: If we go with option 1.

If we take the substring 0000, it has a substring 000 containing more than 2 zero's so it is an invalid string but it is accepted by DFA. Hence this option is not possible.

Case 2: If we go with option 2.

W=000 is a string and has a substring 000 having more than 2 zeros. Not in a language but it is accepted. So option 2 is not possible.

Case 3: If we go with option 3.

W=001000 has a substring 000 having more than 2 zeros and accepted but it is not in the given language.

Case 4: If we go with option4.

This machine accepts all the strings that were every substring of 3 symbols has at most 2 zeros.

So the correct answer is option 4.

57

The height of a tree is defined as the number of edges on the longest path in the tree. The function shown in the pseudocode below is invoked as height(root) to compute the height of a binary tree rooted at the tree pointer root.

int height (treeptr n)

{ if (n == NULL) return -1;

  if (n →  left == NULL)

       if (n →  right == NULL) return 0;

       else return ; B1\boxed{B1};     // Box 1

else { h1 = height (n →  left);

         if (n → right == NULL) return (1+h1);

         else { h2 = height (n → right);

         return ; B2\boxed{B2}   // Box 2

                       }

           }

}

The appropriate expressions for the two boxes B1 and B2 are

  1. ((a))

    B1: (1+height(n → right))

    B2: (1+max(h1, h2))

  2. ((b))

    B1: (height(n → right))

    B2: (1+max(h1,h2))

  3. ((c))

    B1: height(n → right)

    B2: max(h1, h2)

  4. ((d))

    B1: (1+ height(n → right))

    B2: max(h1, h2)

Show Answer
Answer: ((a))

B1: (1+height(n → right))

B2: (1+max(h1, h2))

The correct answer is option 1

EXPLANATION:

The box B1 gets executed when left subtree of n is NULL and right subtree is not NULL. So, height of n will be height of right subtree plus one.

The box B2 gets executed when both left and right subtrees of n are not NULL. So, height of n will be max of heights of left and right subtrees of n plus 1.

So, the correct answer is 

B1: (1+height(n → right))

B2: (1+max(h1, h2))

EXAMPLE:

Find the height of this tree using option 1 in the program

int height (treeptr n)

{ if (n == NULL) return -1;

  if (n →  left == NULL)

       if (n →  right == NULL) return 0;

       else return (1+height(n → right)) ;     // Box 1

else { h1 = height (n →  left);

         if (n → right == NULL) return (1+h1);

         else { h2 = height (n → right);

         return (1+max(h1, h2)) ; // Box 2

                       }

           }

}

So, the height of the above tree is 3

Consider the following C code segment.

int a, b, c = 0;

void prtFun(void);

main( )

{ static int a = 1; / Line 1 /

prtFun( );

a += 1;

prtFun( );

printf(“ \n %d %d ”, a, b);

}

void prtFun(void)

{ static int a = 2; / Line 2 /

int b = 1;

a += ++b;

printf(“ \n %d %d ”, a, b);

}

58

What output will be generated by the given code segment?

  1. ((a))

    3     1

    4     1

    4     2

  2. ((b))

    4      2

    6     1

    6     1

  3. ((c))

    4     2

    6     2

    2     0

  4. ((d))

    3     1

    5     2

    5     2

Show Answer
Answer: ((c))

4     2

6     2

2     0

The correct answer is option 3.

Key Points

 If the variables are static then, it is persisting previous state value from the destruction of various function calls. The variable 'a' in prtFun() is static, i.e its lifetime is global and hence retains its value always, meaning history sensitive.

Hence the correct answer is 4     2,  6     2,  2     0.

59

What output will be generated by the given code segment if:

Line 1 is replaced by auto int a = 1;

Line 2 is replaced by register int a = 2;

  1. ((a))

    3     1

    4     1

    4     2

  2. ((b))

    4     2

    6     1

    6     1

  3. ((c))

    4     2

    6     2

    2     0

  4. ((d))

    4     2

    4     2

    2     0

Show Answer
Answer: ((d))

4     2

4     2

2     0

The correct answer is option 4.

Key Points

If the variable is auto, these variables will be reinitialized in every function calls. Now the variables are all auto storage classes. Their lifetime is local.

Hence correct answer is  4     2, 4     2, 2     0.

Consider the following relations A, B and C:

A
IdNameAge
12Arun60
15Shreya24
99Rohit11

 

B
IdNameAge
15Shreya24
25Hari40
98Rohit20
99Rohit11

 

C
IdPhoneArea
10220002
99210001
60

How many tuples does the result of the following relational algebra expression contain? Assume that the schema of A∪B is the same as that of A.

(A∪B) ⋈ A.Id > 40 ∨ C.Id < 15 C

  1. ((a))

    7

  2. ((b))

    4

  3. ((c))

    5

  4. ((d))

    9

Show Answer
Answer: ((a))

7

The correct answer is option 1.

Key Points

 Apply first cross-product then apply filter. Cross product yields 10 rows, then you play filter A.ID>40 or C.ID<15 produces 7 rows.

AUB= A.Id

12,15,25,98,99

|x| is cross product followed selection and projection.

A.Id     B.Id  X gives(cross product)10rowsCondition
A.IdB.IdA.Id>40 V C.ID<15
5 rows  2 rows the result contains 7 rows1210True
1299False
1510True
1599False
2510True
2599False
9810True
9899True
9910True
9999True

Hence the correct answer is 7.

61

How many tuples does the result of the following SQL query contain?

SELECT A.Id

FROM A

WHERE A.Age > ALL (SELECT B.Age

                                       FROM B WHERE B.Name = ‘Arun’)

  1. ((a))

    4

  2. ((b))

    3

  3. ((c))

    0

  4. ((d))

    1

Show Answer
Answer: ((b))

3

The correct answer is option 2.

Key Points

The ALL keyword specifies that the search condition is TRUE if the comparison is TRUE for every value that the subquery returns. If the subquery returns no value, the condition is TRUE.

There is no Name='Arun' in the B table. So it returns no value then the condition become is TRUE for every row. So Finally it prints the ID of the A table.

Id
12
15
99

Hence the correct answer is 3.

For the grammar below, a partial LL(1) parsing table is also presented along with the grammar. Entries that need to be filled are indicated as E1, E2, and E3. ε is the empty string, $ indicates end of input, and, | separates alternate right hand sides of productions. 

S → a A b B | b A a B | ε 

A → S

B → S

ab$
SE1E2S → ε
AA → SA → SError
BB → SB → SE3
62

The FIRST and FOLLOW sets for the non-terminals A and B are

  1. ((a))

    FIRST(A) = {a, b, ε} = FIRST(B)

    FOLLOW(A) = {a, b}

    FOLLOW(B) = {a, b, $}

  2. ((b))

    FIRST(A) = {a, b, $}

    FIRST(B) = {a, b, ε}

    FOLLOW(A) = {a, b}

    FOLLOW(B) = {$}

  3. ((c))

    FIRST(A) = {a, b, ε} = FIRST(B)

    FOLLOW(A) = {a, b}

    FOLLOW(B) = Φ

  4. ((d))

    FIRST(A) = {a, b} = FIRST(B)

    FOLLOW(A) = {a, b}

    FOLLOW(B) = {a, b}

Show Answer
Answer: ((a))

FIRST(A) = {a, b, ε} = FIRST(B)

FOLLOW(A) = {a, b}

FOLLOW(B) = {a, b, $}

The correct answer is option 1

EXPLANATION:

FIRST(A) = FIRST(s) ={a, b, ε}

FIRST(B) = FIRST(s) ={a, b, ε}

So,FIRST(A) = {a, b, ε} = FIRST(B)

FOLLOW(A) = {First of { bB}, FIRST of {aB}}

FOLLOW(A) = {a, b}

FOLLOW(B) = FOLLOW(S) ={FOLLOW(A), $}

FOLLOW(B) = FOLLOW(S) ={FOLLOW(A), $} ={a, b,$}

Now, the answer is

FIRST(A) = {a, b, ε} = FIRST(B)

FOLLOW(A) = {a, b}

FOLLOW(B) = {a, b, $}

63

The appropriate entries for E1, E2, and E3 are

  1. ((a))

    E1: S → aAbB, A → S

    E2: S → bAaB, B → S

    E3: B → S

  2. ((b))

    E1: S → aAbB, S → ε

    E2: S → bAaB, S → ε

    E3: S → ε

  3. ((c))

    E1: S → aAbB, S → ε

    E2: S → bAaB, S → ε 

    E3: B → S

  4. ((d))

    E1: A → S, S → ε

    E2: B → S, S → ε

    E3: B → S

Show Answer
Answer: ((c))

E1: S → aAbB, S → ε

E2: S → bAaB, S → ε 

E3: B → S

The correct answer is option 3

EXPLANATION:

FIRST and FOLLOW:

FIRSTFOLLOW
S{a, b, ϵ }{a,b, $ }
A{a,b, ϵ }{b,a}
B{a,b,ϵ }{a,b,$}

 

Parsing Table:

ab$
SS→ aAbB S→ ϵS → bAaB S→ ϵS→ ϵ
AA → SA → SError
BB → SB → SB→S

 

Hence the answer is

E1: S → aAbB, S → ε

E2: S → bAaB, S → ε

E3: B → S

A computer has a 256 KByte, 4-way set associative, write back data cache with block size of 32 Bytes. The processor sends 32 bit addresses to the cache controller. Each cache tag directory entry contains, in addition to address tag, 2 valid bits, 1 modified bit and 1 replacement bit.

64

The number of bits in the tag field of an address is

  1. ((a))

    11

  2. ((b))

    14

  3. ((c))

    16

  4. ((d))

    27

Show Answer
Answer: ((c))

16

The correct answer is option 3

Data:

Physical address (PA) = 232 bytes

Block size = 32 B = 25 B

Number of bits for block size = 5

cache size =256 KByte = 218 B

set associative = 4 -way 

Calculation:

number of bits = ⌈log2 n⌉ 

Number of blocks = cache;sizeblock;size\frac{cache;size}{block; size} =218B25B=213{2^{18} B\over 2^5B}=2^{13}

Number of sets in cache = number;of;blocksset;associativity=21322=211{\frac{number; of; blocks}{set; associativity}} = {2^{13}\over 2^2}=2^{11}

Number of bits in set =11

PA = tag + set + offset

32 = tag + 11+ 5

∴ tag = 16 bits

So, the number of bits in the tag field of an address is 16 bits

65

The size of the cache tag directory is

  1. ((a))

    160 Kbits

  2. ((b))

    136 Kbits

  3. ((c))

    40 Kbits

  4. ((d))

    32 Kbits

Show Answer
Answer: ((a))

160 Kbits

The correct answer is option 1

Data:

Physical address space = 232 bytes

Block size = 32 B = 25 B

Number of bits for block size = 5

cache size =256 KByte = 218 B

set associative = 4 -way 

Calculation:

number of bits = ⌈log2 n⌉ 

Number of blocks = cache;sizeblock;size\frac{cache;size}{block; size} =218B25B=213{2^{18} B\over 2^5B}=2^{13}

Number of sets in cache = number;of;blocksset;associativity=21322=211{\frac{number; of; blocks}{set; associativity}} = {2^{13}\over 2^2}=2^{11}

Number of bits in set =11

Virtual address = tag + set + Byte offset (in bits)

32 = tag + 11+ 5

∴ tag = 16 bits

16 bit address 2 valid bits, 1 modified bit and 1 replacement bit

So, total bits =20

So, Each cache tag directory entry contains = 20 × Number of blocks = 20 × 213 bits

∴ 213 = 8 K bits

So, Each cache tag directory entry contains = 20 × 8 K bits=160 Kbits

So, the size of the cache tag directory is 160 Kbits

Attempt this paper under real exam conditions

Timed interface, section switching, instant scoring, and question-by-question analytics — free.

Start Timed Attempt