You are on page 1of 38

GATE PREVIOUS YEAR QUESTIONS INDEX

2000
2004 (50 QUESTIONS)
2020 SET1 (30 QUESTIONS)
Gate 2000

1.1 The minimum number of cards to be dealt from an arbitrarily shuffled deck of 52
cards to guarantee that three cards are from some same suit is
(a) 3 (b) 8 (c) 9 (d) 12
Solution:
Use Pigeon Hole Principle:
N=(R-1)k+1 R=3;k=4 (52 cards 4 different shades)
= 2*4+1=9
We know that there are 4 suits. Let, Heart= H Spade= S Diamond= D
Club= C
So the possible withdrawal sequence  (alternating/worst case)
 HSDCHSDCHSDCHSDC__ (this 9th card will make 3 cards of same suit.)
Therefore option C

1.2 An n  n array v is defined as follows:


 i, j   i  j for all i, j, i  i  n,1 j  nThe sum of the elements of the array v is
(a) 0 (b) n -1 (c)n2  3n  2 2 n  12
(d) n

1.3 The determinant of the matrix


2
0 0 0

8 1 7 2
  is:
2 0 2 0
 
9 0 6 1
(a) 4 (b) 0 (c) 15 (d) 20

1.4 Let S and T be language over ={a,b} represented by the regular expressions
(a+b*)* and (a+b)*, respectively. Which of the following is true?
(a) S  T (b) T  S (c) S = T (d) S T = 

1.5 Let L denotes the language generated by the grammar S 🡪 0S0/00.


Which of the following is true?
(a) L = 0+ (b) L is regular but not 0+
(c) L is context free but not regular (d) L is not context free

1.6 The number 43 in 2’s complement representation is


(a) 01010101 (b) 11010101 (c) 00101011 (d) 10101011

1.7 To put the 8085 microprocessor in the wait state


(a) lower the HOLD input (b) lower the READY input
(c) raise the HOLD input (d) raise the READY input

1.8 Comparing the time T1 taken for a single instruction on a pipelined CPU with time
T2 taken on a non-pipelined but identical CPU, we can say that
(a) T1  T2 (b) T1  T2 (c) T1 < T2
(d) T1 is T2 plus the time taken for one instruction fetch cycle
Pipelined CPU has greater throughput than non-pipelined

1.9 The 8085 microprocessor responds to the present of an interrupt


(a) as soon as the TRAP pin becomes ‘high’
(b) by checking the TRAP pin for ‘high’ status at the end of each instruction each
(c) by checking the TRAP pin for ‘high’ status at the end of the execution of each
instruction.
(d) by checking the TRAP pin for ‘high’ status at regular intervals.

1.10 The most appropriate matching for the following pairs

X: Indirect addressing 1: Loops Y:


Immediate addressing 2: Pointers
Z: Auto decrement addressing 3. Constants
is
(a) X – 3 Y – 2 Z - 1 (b) X – 1 Y – 3 Z - 2
(c) X – 2 Y – 3 Z - 1 (d) X – 3 Y – 1 Z - 2

1.11 The following C declarations


struct node{
int i:
float j;
};
struct node *s[10];
define s to be
(a) An array, each element of which is a pointer to a structure of type node
(b) A structure of 2 fields, each field being a pointer to an array of 10 elements
(c) A structure of 3 fields: an integer, a float, and an array of 10 elements
(d) An array, each element of which is a structure of type node

1.12 The most appropriate matching for the following pairs

X: m=malloc(5); m= NULL; 1: using dangling pointers


Y: free(n); n->value=5; 2: using uninitialized pointers
Z: char *p; *p=’a’; 3. lost memory
is:
(a) X – 1 Y – 3 Z - 2 (b) X – 2 Y – 1 Z - 3
(c) X – 3 Y – 2 Z - 1 (d) X – 3 Y – 1 Z – 2
Sol: C Dynamic memory allocation:
X -> A pointer is assigned to NULL without freeing memory so a clear example of
memory leak
Y -> Trying to retrieve value after freeing it so dangling pointer.
Z -> Using uninitialized pointers

1.13 The most appropriate matching for the following pairs


X: depth first search 1: heap
Y: breadth-first search 2: queue
Z: sorting 3: stack
is:
(a) X – 1 Y – 2 Z - 3 (b) X – 3 Y – 1 Z - 2
(c) X – 3 Y – 2 Z - 1 (d) X – 2 Y – 3 Z - 1
Solution:
X - 3 DFS uses stack implicitly
Y - 2 BFS uses queue explicitly in Algo
Z - 1 Heap-Heapsort

1.14 Consider the following nested representation of binary trees: (X Y Z) indicates Y


and Z are the left and right sub stress, respectively, of node X. Note that Y and Z
may be NULL, or further nested. Which of the following represents a valid binary
tree?
(a) (1 2 (4 5 6 7)) (b) (1 (2 3 4) 5 6) 7)
(c) (1 (2 3 4)(5 6 7)) (d) (1 (2 3 NULL) (4 5))

1.15 Let s be a sorted array of n integers. Let t(n) denote the time taken for the most
efficient algorithm to determined if there are two elements with sum less than
1000 in s. which of the following statements is true?
(a) t (n) is 0(1) (b) n  t(n)  n log2 n
(c) n log2 n  t(n) <
Solution:
Array is sorted. The sum of first 2 elements either will be less than 1000 or will be more than 1000.
and if first 2 elements(which are smallest one) have sum more than 1000, then no other sum will be
less than 1000
1.16 Aliasing in the context of programming languages refers to
(a) multiple variables having the same memory location
(b) multiple variables having the same value
(c) multiple variables having the same identifier
(d) multiple uses of the same variable
Solution:
In computer programming, aliasing refers to the situation where the same memory location can
be accessed using different names. For instance, if a function takes two pointers A and B which have
the same value, then the name A aliases the name B.

1.17 Consider the following C declaration


struct {
short s [5]
union {
float y;
long z;
} u;
}t;
Assume that objects of the type short, float and long occupy 2 bytes, 4
bytes and 8 bytes, respectively. The memory requirement for variable t,
ignoring alignment considerations, is
(a) 22 bytes (b) 14 bytes (c) 18
bytes (d) 10 bytes

Here, structure creates the memory for 'array and unionarray and union', but union only creates the
memory for only 'long z' which is the largest size data type inside it.
Hence,
short×[5]=5∗2=10short×[5]=5∗2=10 bytes  [ shorts take 22 bytes]
long z=8long z=8 bytes
So, (10+8)=1810+8)=18 bytes

1.18 The number of tokens in the following C


statement printf(“i=%d, &i=%x”,i,&i);
is
(a) 3 (b) 26 (c) 10 (d) 21

1.19. Which of the following derivations does a top-down


parser use while parsing an input string? The input is assumed to be scanned in
left to right order.
(a) Leftmost derivation
(b) Leftmost derivation traced out in reverse
(c) Rightmost derivation
(d) Rightmost derivation traced out in reverse
Solution:
Top-down parser - Leftmost derivation
Bottom-Up parser - Reverse of rightmost derivation
A top-down parser is called LL parser because it parses the input from Left to right, and
constructs a Leftmost derivation of the sentence

1.20. Which of the following need not necessarily be saved on a context switch
between processes?
(a) General purpose registers (b) Translation look-aside buffer
(c) Program counter (d) All of the above
We don't need to save TLB or cache to ensure correct program resumption. They are just bonus for
ensuring better performance. But PC, stack and registers must be saved as otherwise program
cannot resume.
TLS buffer need not be saved as it will flush out the contents of the switched process and
will have the new process contents.

1.21. Let m[0]…m[4] be mutexes (binary semaphores)


and P[0] …. P[4] be processes. Suppose each
process P[i] executes the following:
wait (m[i];wait (m[(i+1) mode 4]);
………
release (m[i]); release (m[(i+1)mod 4]);
This could cause
(a) Thrashing
(b) Deadlock
(c) Starvation, but not deadlock
(d) None of the above

1.22. B+ -trees are preferred to binary trees in databases because


(a) Disk capacities are greater than memory capacities
(b) Disk access is much slower than memory access
(c) Disk data transfer rates are much less than memory data transfer rates
(d) Disks are more reliable than memory
Data in B+ Tree is stored in a way to make optimum use of locality of reference. And We know that
Disk access time (ms) is much higher than memory Access time (ns), So, it takes more time to
access a page from Disk, so We want to retrieve as much as data in one go. So, we use B+ Tree
instead of BST.

1.23. Given the relations


employee (name, salary, deptno), and department
(deptno, deptname, address)
Which of the following queries cannot be expressed using the basic relational algebra
operations (,,, ,,,)?

(a) Department address of every employee


(b) Employees whose name is the same as their department name
(c) The sum of all employees’ salaries
(d) All employees of a given department
Solution: The six basic operators of relational algebra are the selection(σ ), the projection(π), the
Cartesian product (x) (also called the cross product or cross join), the set union (U), the set
difference (-), and the rename (p). These six operators are fundamental in the sense that none of
them can be omitted without losing expressive power. Many other operators have been defined in
terms of these six. Among the most important are set intersection, division, and the natural join,
but aggregation is not possible with these basic relational algebra operations. So, we cannot run
sum of all employees’ salaries with the six operations.

2.1 X, Y and Z are closed intervals of unit length on the real line. The overlap of X and Y is half a
unit. The overlap of Y and Z is also half a unit. Let the overlap of X and Z be k units. Which of the
following is true?
(a) k must be 1 (b) k must be 0
(c) k can take any value between 0 and 1 (d) None of the above

2.2. A polynomial p(x) satisfies the following:


p(1) = p(3) = p(5) = 1
p(2) = p(4) = -1
The minimum degree of such a polynomial is
(a) 1 (b) 2 (c) 3 (d) 4

2.3. A relation R is defined on the set of integers as


x Ry iff (x+y) is even. Which of the following
statements is true?
(a) R is not an equivalence relation
(b) R is an equivalence relation having 1 equivalence class
(c) R is an equivalence relation having 2 equivalence classes
(d) R is an equivalence relation having 3 equivalence classes

2.4. Let P(S) denotes the powerset of set S. Which of the following is always true? (a)
P(P(S))=P(S) (b) P(S) P(P(S)) = {}
(c) P(S) S = P(S) (d) S P(S)
2.5. Let a, b, c, d be propositions. Assume that the equivalence a
 (b V-b) and b 
c hold. Then the truth-value of the formula a  b  a  c   d
is always
(a) True (b) False
(c) Same as the truth-value of b (d) Same as
the truth-value of d

2.6. What can be said about a regular language L over {a} whose
minimal finite state automation has two states?
(a) L must be {an|n is odd} (b) L must
be {an|n is even}
(c) L must be {an|0}
(d) Either L must be {an|n is odd}, or L must be {an| n is even}

2.7. Consider the following decision problems:


(P1) Does a given finite state machine accept a given string
(P2) Does a given context free grammar generate an infinite number of stings
Which of the following statements is true?
(a) Both (P1) and (P2) are decidable
(b) Neither (P1) nor (P2) are decidable
(c) Only (P1) is decidable (d) Only (P2) is decidable
Solution:
 P1; membership problem of DFA is decidable.
 p2: finiteness problem of CFG is also decidable

2.8. The simultaneous equations on the Boolean variables x, y, z and w,


x y  z 1
xy  0
xz  w  1
xy  z w=0
have the following solution for x, y, z and w, respectively:
(a) 0 1 0 0 (b) 1 1 0 1 (c) 1 0 1 1 (d) 1 0 0 0

2.9. Which functions does NOT implement the Karnaugh map


given below?

2.10. P Q 1 T
he following arrangement of master-slave flip flops
JK D
1
Clock
has the initial state of P, Q as 0, 1 (respectively). After the clock cycles the output
state P, Q is (respectively),
(a) 1, 0 (b) 1, 1 (c) 0, 0 (d) 0, 1

2.11. A graphics card has on board memory of 1 MB. Which of the following modes can the card
not support?
(a) 1600  400 resolution with 256 colours on a 17 inch monitor
(b) 1600  400 resolution with 16 million colours on a 14 inch monitor
(c) 800  400 resolution with 16 million colours on a 17 inch monitor
(d) 800  800 resolution with 256 colours on a 14 inch monitor
A. 256 colors means 8 bits for color representation meaning 1 byte. So, 1600 * 400 resolution
requires 640 kB. We have 1 MB, so fine.

B. 16 million colors require 24 bits or 3 bytes. So, 1600 * 400 resolution requires 640 k * 3 = 1920
kB which is over our on board memory. So, not possible.

C. Again 3 bytes for a color. 800 * 400 resolution requires 320 k * 3 = 960 kB which is fine as we
have 1 MB on board.

D. 256 colors require 1 byte. 800 * 800 resolution requires 640 k * 1 = 640 kB which is again fine.
So, answer is B.

2.12. Consider the values of A = 2.0  1030, B = -2.0  1030, C = 1.0, and the sequence
X: = A + B Y:= A + c
X: = X + C Y:= Y + B
Executed on a computer where floating point numbers are represented with 32 bits. The
values for X and Y will be
(a) X = 1.0, Y = 1.0 (b) X = 1.0, Y = 0.0
(c) X = 0.0, Y = 1.0 (d) X = 0.0, Y = 0.0

2.13. Suppose you are given an array s[1…n] and a procedure reverse (s,i,j) which reverses the
order of elements in a between positions i and j (both inclusive). What does the following
sequence do, where 1  k n:
reverse (s, 1, k);
reverse (s, k + 1, n);
reverse (s, 1, n);
(a) Rotates s left by k positions (b) Leaves s unchanged
(c) Reverses all elements of s (d) None of the above

2.14. Let LASTPOST, LASTIN and LASTPRE denote the last vertex visited in a postorder, inorder
and preorder traversal. Respectively, of a complete binary tree. Which of the following is
always tree?
(a) LASTIN = LASTPOST (b) LASTIN = LASTPRE
(c) LASTPRE = LASTPOST (d) None of the above

2.15. Consider the following functions


f n  3n n
n log2 n
g n  2
h n  n!
Which of the following is true?
(a) h(n) is O (f(n)) (b) h(n) is O (g(n))
(c) g(n) is not O (f(n)) (d) f(n) is O(g(n))
(a) No minimum spanning tree contains emax
(b) G has a unique minimum spanning tree

2.16. Lt G be an undirected graph. Consider a depth-first traversal of G, and let T be the


resulting depth-first search tree. Let u be a vertex in G and let  be the first new
(unvisited) vertex visited after visiting u in the traversal. Which of the following
statements is always true?
(a) {u,v} must be an edge in G, and u is a descendant of v in T
(b) {u,v} must be an edge in G, and v is a descendant of u in T
(c) If {u,v} is not an edge in G then u is a leaf in T
(d) If {u,v} is not an edge in G then u and v must have the same parent in T

2.17. The value of j at the end of the execution of the following C program
int incr (int i)
{
static int count = 0;
count = count + i;
return (count);
}
main () {
int i,j;
for (i = 0; i <=4; i++) j
= incr(i);
}
is
(a) 10 (b) 4 (c) 6 (d) 7

2.18. Given the following expression grammar: E 🡪


E*F|F+E|F
F 🡪 F - | id
Which of the following is true?
(a) * has higher precedence than + (b) - has higher precedence than *
(c) + and – have same precedence (d) + has higher precedence than *

2.19. Suppose the time to service a page fault is on the average 10 milliseconds, while a
memory access takes 1 microsecond. Then a 99.99% hit ratio results in average memory
access time of
(a) 1.9999 milliseconds (b) 1 millisecond
(c) 9.999 microseconds (d) 1.9999 microseconds

2.20. Which of the following is NOT a valid deadlock prevention scheme?


(a) Release all resources before requesting a new resource
(b) Number the resources uniquely and never request a lower numbered resource than
the last one requested.
(c) Never request a resource after releasing any resource
(d) Request and all required resources be allocated before execution.

2.21. Given the following relation instance


X Y Z
1 4 2
1 5 3
1 6 3
3 2 2
Which of the following functional dependencies are satisfied by the instance?
(a) XY 🡪 Z and Z 🡪 Y (b) YZ 🡪 X and Y 🡪 Z
(c) YZ 🡪 X and X 🡪 Z (d) XZ 🡪 Y and Y 🡪 X

2.22. Given relations r(w,x) and s(y,z), the result of


select distinct w,x from r, s
is guaranteed to be same as r, provided
(a) r has no duplicates and s is non-empty
(b) r and s have no duplicates
(c) s has no duplicates and r is non-empty
(d) r and s have the same number of tuples

2.26 In SQL, relations can contain null values, and comparisons with null values are treated as
unknown. Suppose all comparisons with a null value are treated as false. Which of the
following pairs is not equivalent?
(a) x = 5 not (not (x = 5)
(b) x = 5 x > 4 and x < 6, where x is an integer
(c) x  5 not (x = 5)
(d) None of the above

Gate 2004
1. The goal of structured programming is to:
A. have well indented programs
B. be able to infer the flow of control from the compiled code
C. be able to infer the flow of control from the program text
D. avoid the use of GOTO statements

It means user can execute the code according to his requirement. CC and Pascal are good example of
structured programming. In structured programming control passes one instruction to another
instruction in sequential manner.
Avoiding the use of GOTO statements is not the goal of structured programming, it (avoiding the use
of GOTO) is one of the requirements for a program to be structured.

2. Consider the following function


void swap(int a, int b)
{
int temp;
temp = a;
a = b;
b = temp;
}
In order to exchange the values of two variables xx and yy.
A. call swap(x,y)swap(x,y)
B. call swap(&x,&y)swap(&x,&y)
C. swap(x,y)swap(x,y) cannot be used as it does not return any value
D. swap(x,y)swap(x,y) cannot be used as the parameters are passed by value

Option A will not exchange the values of xx and yy because parameters are passed by value in C. i.e.,
the code is exchanging x′x′ and y′y′ which are having the values of xx and yy respectively. 
Option B will not swap the value
void swap(int a, int b)
Here, it is wrong to pass in address (int*) as the parameters are of int type, even sizeof int and int*
varies depending on the compiler. Now, even if ignoring this error, the given code would not
exchange the values of xx and yy as it is merely exchanging p′1p1′ and p′2p2′ where p′1p1′ and p
′2p2′ are containing the copies of the addresses of xx and yy respectively. (Even addresses are
passed by value in C language).
Option C is false, return value is not required for exchanging the variables.
Option D is correct. We cannot use swap(x,y)swap(x,y) because parameters are passed by value.
Only way now to exchange the variables are by passing their addresses and then modifying the
contents using the de-referencing operator (∗).
Therefore to exchange the values of x and y, we cannot use pass by value( given code is for pass by
value). So option D is correct

3. A single array A[1..MAXSIZE]A[1..MAXSIZE] is used to implement two stacks. The two


stacks grow from opposite ends of the array. Variables top1top1 and top2top2 (top<top2)
(top<top2) point to the location of the topmost element in each of the stacks. If the space is to be
used efficiently, the condition for “stack full” is
A. (top1=MAXSIZE/2)(top1=MAXSIZE/2) and (top2=MAXSIZE/2+1)(top2=MAXSIZE/2+1)
B. top1+top2=MAXSIZEtop1+top2=MAXSIZE
C. (top1=MAXSIZE/2)(top1=MAXSIZE/2) or (top2=MAXSIZE)(top2=MAXSIZE)
D. top1=top2−1

4. The following numbers are inserted into an empty binary


search tree in the given
order: 10,1,3,5,15,12,1610,1,3,5,15,12,16. What is the height
of the binary search tree (the height is the maximum distance
of a leaf node from the root)?
A. 2
B. 3
C. 4
D. 6
5. The best data structure to check whether an arithmetic expression has balanced
parentheses is a
A. queue
B. stack
C. tree
D. list
STACK scan the expression from left to right whenever a left paranthesis is encountered just PUSH it
into stack and whenever a right paranthesis is encountered just POP it from stack. If at the end of
expression we are left with an empty stack then it is a correctly parenthesized expression.

6. Level order traversal of a rooted tree can be done by starting from the root and
performing
A. preorder traversal
B. in-order traversal
C. depth first search
D. breadth first search
Solution:
 Preorder traversal: Root, then L, then R
 Inorder traversal: L, then Root, then R
 Postorder traversal: L, then R, then Root
 Levelorder traversal: Start from the root and call BFS.
Level order traversal of the tree resembles the Breadth-first search of the graph and also level order
traversal uses the queued data structure.

7.Given the following input (4322,1334,1471,9679,1989,6171,6173,4199) and the hash


function xx mod 1010, which of the following statements are true?
I. 9679,1989,41999679,1989,4199 hash to the same value
II. 1471,61711471,6171 hash to the same value
III. All elements hash to the same value
IV. Each element hashes to a different value
A. I only
B. II only
C. I and II only
D. III or IV
8. Which of the following grammar rules violate the requirements of an
operator grammar? P, Q, R are nonterminals, and r, s, t are terminals.
I. P → Q R
II. P → Q s R
III. P →ε
IV. P → Q t R r
A. (I) only
B. (I) and (III) only
C. (II) and (III) only
D. (III) and (IV) only

Operator grammar  cannot contain  


1. Nullable variable  
2. Two adjacent non-terminal on RHSRHS of production

9. Consider a program P that consists of two source modules M1 and M2 contained in two


different files. If M1 contains a reference to a function defined in M2 the reference will be
resolved at 
A. Edit time
B. Compile time
C. Link time
D. Load time
Each module is compiled separately and then linked together to make the executable. Linker are the
one responsible for resolving external references. so it is link time.

11. Consider the following statements with respect to user-level threads and kernel-
supported threads
I. context switch is faster with kernel-supported threads
II. for user-level threads, a system call can block the entire process
III. Kernel supported threads can be scheduled independently
IV. User level threads are transparent to the kernel
Which of the above statements are true?
A. (II), (III) and (IV) only
B. (II) and (III) only
C. (I) and (III) only
D. (I) and (II) only
Solution:
I. User level thread switching is faster than kernel level switching. So, (I) is false.
II. is true.
III. is true.
IV. User level threads are transparent to the kernel
In case of Computing transparent means functioning without being aware. In our case user
level threads are functioning without kernel
being aware about them. So (IV) is actually
correct. 
"The kernel knows nothing about user-level threads
and manages them as if they were single-threaded
processes"

10. Consider the grammar rule E→E1–E2 for


arithmetic expressions. The code generated is
targeted to a CPU having a single user register.
The subtraction operation requires the first operand to be in the register. If E1 and E2 do
not have any common sub expression, in order to get the shortest possible code
A. E1 should be evaluated first
B. E2 should be evaluated first
C. Evaluation of E1 and E2 should necessarily be interleaved
D. Order of evaluation of E1 and E2 is of no consequence.

12. Consider an operating system capable of loading and executing a single sequential user
process at a time. The disk head scheduling algorithm used is First Come First Served
(FCFS). If FCFS is replaced by Shortest Seek Time First (SSTF), claimed by the vendor to
give 50%50% better benchmark results, what is the expected improvement in the I/O
performance of user programs?
A. 50%
B. 40%
C. 25%
D. 0%
Question says "single sequential user process". So, all the requests to disk scheduler will be in
sequence and each one will be blocking the execution and hence there is no use of any disk
scheduling algorithm. Any disk scheduling algorithm gives the same input sequence and hence the
improvement will be 0%0% for SSTF over FCFS.

13. Let R1(A−−,B,C)R1(A_,B,C) and R2(D−−,E)R2(D_,E) be two


relation schema, where the primary keys are shown underlined, and let C be
a foreign key in R1R1 referring to R2R2. Suppose there is no violation of the
above referential integrity constraint in the corresponding relation
instances r1r1 and r2r2. Which of the following relational algebra expressions
would necessarily produce an empty relation?

Answer is (B).
C in R1 is a foreign key referring to the primary key D in R2. So, every
element of C must come from some D element.

14. Consider the following relation schema pertaining to a students database:


 Students (rollno, name, address)
 Enroll (rollno, courseno, coursename)
where the primary keys are shown underlined. The number of tuples in the student and Enroll tables
are 120 and 8 respectively. What are the maximum and minimum number of tuples that can be
present in (Student * Enroll), where ‘*’ denotes natural join?
A. 8,8
B. 120,8
C. 960,8
D. 960,120
In natural join it'll return the records where the rollno value of enroll matches with the rollno of
students so, in both conditions min and max records will be resulted (8,8).

15. Choose the best matching


between Group 1 and Group 2
A. P-1, Q-4, R-3
B. P-2, Q-4, R-1
C. P-2, Q-3, R-1
D. P-1, Q-3, R-2

16. Which of the following is NOT true with


respect to a transparent bridge and a
router?
A. Both bridge and router selectively forward data packets
B. A bridge uses IP addresses while a router uses MAC addresses
C. A bridge builds up its routing table by inspecting incoming packets
D. A router can connect between a LAN and a WAN
A. Both bridge and router selectively forward data packets ⇒ True.
Bridge can drop packets not meant for other side, so can router.
B. A bridge uses IP addresses while a router uses MAC addresses ⇒ False .
A bridge operate at layer 2 (data link layer) so it uses MAC address,
while router at layer 3 (network layer) so it using IP addresses
C. A bridge builds up its routing table by inspecting incoming packets ⇒⇒ True.
Self Learning Bridges
D. A router can connect between a LAN and a WAN⇒ True.
Router connecting home LANLAN To internet !
Correct Answer: B
The main difference between router and bridge is router will do connection between two WAN
packets, where as bridge do connection between 2 LAN packets.

17. A Boolean function x′y′+xy+x′y is equivalent to


a. x′+y′
b. x+y
c. x+y′
d. x′+y
One simple way of doing such type of questions is :
step1 - Draw the k-map for the given inputs
step2 - group the minterms and the resultant is your answer.

18. In an SR latch made by cross-coupling two NAND gates, if both S and R inputs are set
to 0, then it will result in
a. Q=0,Q′=1
b. Q=1,Q′=0
c. Q=1,Q′=1
d. Indeterminate states

19. If 73x (in base-x number system) is equal to 54y (in base-y number system), the
possible values of x and y are
(A) 8, 16
(B) 10, 12
(C) 9, 13
(D) 8, 11
Solution:
abx= cdy => b+a*x=d+c*y
We can solve it by converting both to decimals.
3 + 7*8 = 4 + 11*5

20. Which of the following addressing modes are suitable for program relocation at run
time?
I. Absolute addressing
II. Based addressing
III. Relative addressing
IV. Indirect addressing
A. I and IV
B. I and II
C. II and III
D. I, II and IV
21. The minimum number of page frames that must be allocated to a running process in a
virtual memory environment is determined by
A. the instruction set architecture
B. page size
C. number of processes in memory
D. physical memory size
Its instruction set architecture .if you have no indirect addressing then you need at least two pages in
physical memory. One for instruction (code part) and another for if the data references memory. if
there is one level of indirection then you will need at least three pages one for the instruction(code)
and another two for the indirect addressing. If there three indirection then minimum 44 frames are
allocated.
Pages in virtual address space (which is what all code running under a virtual memory OS deals with)
are called simply pages, or virtual pages. 
Pages in physical memory (RAM) are called physical memory, or physical pages, or... "page frames

The maximum  number of frames that a process can have in the physical memory depends on
Options B, C and D.
Page size and physical memory size determine the total number of frames. And the number of
processes in the physical memory also play a role

22. How many 8−bit characters can be transmitted per second over a 9600 baud serial
communication link using asynchronous mode of transmission with one start bit, eight data bits, two
stop bits and one parity bit?
a. 600 b. 800 c. 876 d. 1200

23. Identify the correct translation into logical notation of the following assertion.
Some boys in the class are taller than all the girls
Note: taller(x,y) is true if x is taller than y.
a. (∃x)(boy(x)→(∀y)(girl(y)∧taller(x,y)))
b. (∃x)(boy(x)∧(∀y)(girl(y)∧taller(x,y)))
c. (∃x)(boy(x)→(∀y)(girl(y)→taller(x,y)))
d. (∃x)(boy(x)∧(∀y)(girl(y)→taller(x,y)))

24. Consider the binary relation:


S={(x,y)∣y=x+1 and x,y∈{0,1,2}}S={(x,y)∣y=x+1 and x,y∈{0,1,2}}
The reflexive transitive closure is SS is
A. {(x,y)∣y>x and x,y∈{0,1,2}}{(x,y)∣y>x and x,y∈{0,1,2}} 
B. {(x,y)∣y≥x and x,y∈{0,1,2}}{(x,y)∣y≥x and x,y∈{0,1,2}} 
C. {(x,y)∣y<x and x,y∈{0,1,2}}{(x,y)∣y<x and x,y∈{0,1,2}} 
D. {(x,y)∣y≤x and x,y∈{0,1,2}}
25. If a fair coin is tossed four times. What is the probability that two heads and two tails
will result?
a. 3/8
b. 1/2
c. 5/8
d. 3/4

Binomial distribution:-
P(H) = 1/2
P(T) = 1/2
4
C2(1/2)2(1/2)2 = 6/16 = 3/8.

27. Let A,B,C,D be n×n matrices, each with non-zero determinant. If ABCD=I, then B −1 is
a. D−1C−1A−1
b. CDA
c. ADC
d. Does not necessarily exist

29. The tightest lower bound on the number of comparisons, in the worst case, for
comparison-based sorting is of the order of
a. n b. n2 c. nlogn d. nlog2n

30. The problem 3-SAT and 2-SAT are


a. both in P
b. both NP complete
c. NP-complete and in P respectively
d. undecidable and NP complete respectively
31. Consider the following C function:
int f(int n)
{
static int i = 1;
if(n >= 5) return n;
n = n+i;
i++;
return f(n);
}
The value returned by f(1)is:
A. 5 B. 6 C.7 D.8
33. Consider the following C program segment:
char p[20]; int i;
char* s = "string";
int length = strlen(s);
for(i = 0; i < length; i++)
p[i] = s[length-i];
printf("%s", p);
The output of the program is:
A. gnirts
B. string
C. gnirt
D. no output is printed
Solution: In for loop, i starts from 0 and not 1 so s[6-0]=6 and at 6th index we have ‘\0’.
SO, NOTHING IS PRINTED.

34. It is desired to design an object-oriented employee record system for a company. Each employee
has a name, unique id, and salary. Employees belong to different categories and their salary is
determined by their category. The functions get name, getId and compute salary are required. Given the
class hierarchy below, possible locations for these functions are:
I. getId is implemented in the superclass
II. getId is implemented in the subclass
III. getName is an abstract function in the superclass
IV. getName is implemented in superclass
V. getName is implemented in subclass
VI. getSalary is an abstract function in the superclass
VII. getSalary is implemented in the superclass
VIII. getSalary is implemented in the subclass

Choose the best design


A. I, IV, VI, VIII
B. I, IV, VII
C. I, III, V, VI, VIII
D. II, V, VIII
Solution: Name and id are a property of every employee and independent of their category. So,
these should be implemented in superclass. Every employee has a salary but this is determined by
their category. So, getSalary must be a abstract function in superclass and implemented in subclass.

35. Consider the label sequences obtained by the following pairs of traversals on a labeled
binary tree. Which of these pairs identify a tree uniquely?
I. preorder and postorder
II. inorder and postorder
III. preorder and inorder
IV. level order and postorder
A. I only
B. II, III
C. III only
D. IV only

36. A circularly linked list is used to represent a Queue. A single variable pp is used to access the
Queue. To which node should pp point such that both the
operations enQueueenQueue and deQueuedeQueue can be performed in constant time?

A. rear node
B. front node
C. not possible with a single pointer
D. node next to front
38. Assume that the operators +,−,×are left associative and ^ is right associative. The order of
precedence (from highest to lowest) is ^,×,+,−. The postfix expression corresponding to the infix
expression a+b×c−d^e^f is
A. abc×+def^^−
B. abc×+de^f^−
C. ab+c×d−e^f^
D. −+a×bc^^def
Solution:
Use Bracket according to precedance 
^  - Precedance from Right to Left and others left to right
((a + (b * c )) - (d ^ (e ^ f))) then solve it 

39. Two matrices M1 and M2 are to be stored in arrays A and B respectively. Each array can


be stored either in row-major or column-major order in contiguous memory locations. The
time complexity of an algorithm to compute M1×M2 will be
A. best if A is in row-major, and B is in column-major order
B. best if both are in row-major order
C. best if both are in column-major order
D. independent of the storage scheme
Running time of an algorithm is always independent of the storage scheme. While computing the
running time of an algorithm we assume that to access any element time taken is same. So Answer
is D.

But if the question asked best time complexity in which of the following implementation (not
algorithm) then Option a is correct.

40. Suppose each set is represented as a linked list with elements in arbitrary order. Which
of the operations among union, intersection, membership, cardinality will be the slowest?
A. union only
B. intersection, membership
C. membership, cardinality
D. union, intersection
Membership is linear search - O(n1+n2) (traverse all nodes of L1 and L2 and look for a match)
Cardinality is linear - O(n1+n2) (simple count all the nodes)
For union we need to ensure no duplicate elements should be present - O(n1×n2) for each element
we need to check if that element exists in other set
For intersection also for every element in set1 we need to scan set2 - O(n1×n2)

41. Consider the following C program


main()
{
int x, y, m, n;
scanf("%d %d", &x, &y);
/* Assume x>0 and y>0*/
m = x; n = y;
while(m != n)
{
if (m > n)
m = m-n;
else
n = n-m;
}
printf("%d", n);
}
The program computes
A. x+y using repeated subtraction
B. x mod y using repeated subtraction
C. the greatest common divisor of x and y
D. the least common multiple of x and y
Solution:
Given code is same as Euclid's Algorithm for finding Greatest Common Divisor(GCD).
Here, while loop executes until m=n.
We can test by taking any two numbers as m,n.
fibonacci pair, which is the worst case input for the EGCD.

42. What does the following algorithm approximate? (Assume m>1,ϵ>0).


x = m; y = 1;
While (x-y > ϵ)
{
x = (x+y)/2;
y = m/x;
}
print(x);
A. logm
B. m2
C. m1/2
D. m1/3

43. Consider the following C program segment


struct CellNode{
struct CellNode *leftChild
int element;
struct CellNode *rightChild;
};

int Dosomething (struct CellNode *ptr)


{
int value = 0;
if(ptr != NULL)
{
if (ptr -> leftChild != NULL)
value = 1 + DoSomething (ptr -> leftChild);
if (ptr -> rightChild != NULL)
value = max(value, 1 + Dosomething (ptr -> rightChild));
}
return(value);
}
The value returned by the function DoSomething when a pointer to the root of a non-empty tree is
passed as argument is
A. The number of leaf nodes in the tree
B. The number of nodes in the tree
C. The number of internal nodes in the tree
D. The height of the tree
It calculates Height of tree.
Result for all options will be as follows:
A- 4
B-7
C-3
D-2
Running given code we get 2 as answer. So option D is right

44. Suppose we run Dijkstra’s single source shortest path algorithm on the following edge-
weighted directed graph with vertex P as the source.

In what order do the nodes get included into the set of vertices for which the shortest path distances
are finalized?
A. P,Q,R,S,T,U
B. P,Q,R,U,S,T
C. P,Q,R,U,T,S
D. P,Q,T,R,U,S

45. Consider the grammar with the following translation rules and E as the start symbol

Compute E.value for the root of the parse tree for the expression: 2 # 3 & 5 # 6 & 4
a. 200 b. 180 c.160 d.40

Here # is multiplication and & is addition by semantics rules given in the question.
By observation of productions,
1. here &(+) is higher precedence than #(*), because & is far from starting symbol
2. both &,# are left associative
So, we can solve the expression as ((2∗(3+5))∗(6+4))=160
 "Operator which is at lower level in the grammar is termed to have higher precedence."
 if there is left recursion then operator will be left associative .. or if right recursion then
operator will be right associate ..
eg : E---> E+T(here E derive E+T so it is left recursive

      E---->T+E (here E derive T+E so it is right recursive

46. Consider the following set of processes, with the arrival times and the CPU-burst times
gives in milliseconds.
What is the average turnaround time for these processes with the
preemptive shortest remaining processing time first (SRPT)
algorithm?
A. 5.50
B. 5.75
C. 6.00
D. 6.25
47. Consider a system with a two-level paging scheme in which a regular memory access
takes 150nanoseconds, and servicing a page fault takes 8 millisecond. An average
instruction takes 100nanoseconds of CPU time, and two memory accesses. The TLB hit
ratio is 90%, and the page fault rate is one in every 10,000 instructions. What is the
effective average instruction execution time?
A. 645 nanoseconds
B. 1050 nanoseconds
C. 1215 nanoseconds
D. 1230 nanoseconds

48. Consider two processes P1 and P2 accessing the


shared variables X and Y protected by two binary
semaphores SX and SY respectively, both initialized to
1. P and V denote the usual semaphore operators,
where P decrements the semaphore value,
and V increments the semaphore value. The pseudo-code
of P1 and P2 is as follows:

Ans: D

49. A unix-style I-nodes has 10 direct pointers and one


single, one double and one triple indirect pointers. Disk block
size is 1Kbyte, disk block address is 32 bits, and 48-bit
integers are used. What is the maximum possible file size?
A. 224 bytes
B. 232 bytes
C. 234 bytes
D. 248 bytes

50. The relation scheme Student Performance (name, courseNo, rollNo, grade) has the
following functional dependencies:
 name, courseNo, → grade
 rollNo, courseNo → grade
 name → rollNo
 rollNo → name
The highest normal form of this relation scheme is
A. 2NF
B. 3NF
C. BCNF
D. 4NF

1 st 2 FD's satisfy BCNF ... other 2 is in 3 NF but not in BCNF


So the highest normal form of the schema is 3 NF
Gate 2021 Set 1
1. Suppose that L1 is a regular language and L2 is a context-free language. Which one of
the following languages is NOT necessarily context-free?
A. L1∩L2
B. L1⋅L2
C. L1−L2
D. L1∪L2
Explanation:
 A) CFL intersection with Regular language is CFL 
 B) All Regular languages are CFL, CFLs are closed under concatenation
 D) CFLs are closed under union
 C) CFLs are not closed under set difference
Same as above question: Gate 1996
If L1 and L2 are context free languages and R a regular set, one of the languages below is not
necessarily a context free language. Which one?
A. L1.L2
B. L1∩L2
C. L1∩R
D. L1∪L2
Same as above question: Gate 1999
If L1 is a context free language and L2 as a regular language, which of the following is/are False?
a. L1-L2 is not context free
b. L1 ∩ L2 is context free
c. ~L1 is context free
d. ~L2 is regular
(A) Only b
(B) Only c
(C) Both a and c
(D) Both b and c
Explanation: Given L1 is a context free language and L2 as a regular language then L1-L2 is context
free language and ~L1(complement of context free) is not context free because context free is not
closed under complement.
Complement of regular language i.e. ~L2 is also regular ( so d is correct ) since statements a and c
are false. Option (C) is correct.

2. Let P be an array containing n integers. Let t be the lowest upper bound on the number
of comparisons of the array elements, required to find the minimum and maximum values
in an arbitrary array of n elements. Which one of the following choices is correct?
A. t>2n−2
B. t>3⌈n2⌉ and t≤2n−2
C. t>n and t≤3⌈n/2⌉
D. t>⌈log2(n)⌉ and t≤n

3. Consider the three functions


f1=10n f2=nlogn f3=n√n
Which one of the following options arranges the functions in the increasing order as asymptotic
growth rate?
(A) f3, f2, f1
(B) f2, f1, f3
(C) f1, f2, f3
(D) f2, f3, f1

4. Consider the following statements.


 S1: The sequence of procedure calls corresponds to a preorder traversal of the activation
tree.
 S2: The sequence of procedure returns corresponds to a postorder traversal of the activation
tree.
Which one of the following options is correct?
A. S1 is true and S2 is false
B. S1 is false and S2 is true
C. S1 is true and S2 is true
D. S1 is false and S2 is false

5. Consider the following statements.


 S1: Every SLR(1) grammar is unambiguous but there are certain unambiguous grammars
that are not SLR(1).
 S2: For any context-free grammar, there is a parser that takes at most O(n3) time to parse a
string of length n.
Which one of the following options is correct?
A. S1 is true and S2 is false
B. S1 is false and S2 is true
C. S1 is true and S2 is true
D. S1 is false and S2 is false
Statement 2 Statement 1

6. Let the representation of a number in base 3 be 210. What is the hexadecimal


representation of the number?
A. 15
B. 21
C. D2
D. 528

7. Let p and q be two propositions. Consider the following two formulae in propositional


logic.
S1:(¬p∧(p∨q))→qS1:(¬p∧(p∨q))→q
S2:q→(¬p∧(p∨q))S2:q→(¬p∧(p∨q))
Which one of the following choices is correct?
A. Both S1 and S2 are tautologies.
B. S1 is a tautology but S2 is not a tautology
C. S1 is not a tautology but S2 is a tautology
D. Niether S1 nor S2 is a tautology
8. Consider the following two statements.
 S1: Destination MAC address of an ARP reply is a broadcast address.
 S2: Destination MAC address of an ARP request is a broadcast address.
Which one of the following choices is correct?
(A) Both S1 and S2 are true
(B) S1 is true and S2 is false
(C) S1 is false and S2 is true
(D) Both S1 and S2 are false
Explanation:
S1: ARP reply is a unicast message, as only one node will have that MAC address and it responds for
the request.
S2: ARP request is a Broadcasting message, as it has to search for the given MAC address from all
the nodes.

9. Consider the following array.

Which algorithm out of the following options uses the least number of comparisons (among the array
elements) to sort the above array in ascending order?
(A) Selection sort
(B) Mergesort
(C) Insertion sort
(D) Quicksort using the last element as pivot
Explanation:
No algorithm can beat insertion sort, if array is already sorted

10. A binary search tree T contains n distinct


elements. What is the time complexity of picking an
element in T that is smaller than the maximum
element in T?
(A) Θ(nlogn)
(B) Θ(n)
(C) Θ(logn)
(D) Θ(1)

For a BST, the maximum element is rightmost leaf node.


Any element less than maximum can be found
by comparing any two numbers i.e. one companies = O(1)

11. In the context of operating systems, which of the


following statements is/are correct with respect to paging?
(A) Paging helps solve the issue of external
fragmentation
(B) Page size has no impact on internal fragmentation
(C) Paging incurs memory overheads
(D) Multi-level paging is necessary to support pages of different sizes

 Paging is the technique of non contiguous allocation of physical memory which solves
external fragmentation. True
 Paging may cause internal fragmentation depends on the page size and process size in last
page, if page size is larger and process size is smaller. False
 Implementation of Paging requires management of Page tables which resides in pages and
hence consume additional memory. True
 Multilevel paging is required when size of page table exceeds the size of page. Since page
table reside in page, it is further divided to pages of same size. False

12. Let ⟨M⟩ denote an encoding of an


automaton M. Suppose that Σ= {0, 1}. Which of
the following languages is/are NOT recursive?
(A) L = {⟨M⟩ ∣ M is a DFA such that L(M)=∅}
(B) L = {⟨M⟩ ∣ M is a DFA such that L(M)=Σ*}
(C) L = {⟨M⟩ ∣ M is a PDA such that L(M)=∅}
(D) L = {⟨M⟩ ∣ M is a PDA such that L(M)=Σ*}
Explanation:
L = {<M> M is d DFA such that L(M) = } is
decidable hence recursive
L = {<M> M is a PDA such that L(M) = } is
also decidable
L = {<M> M is a DFA such that L(M) = Σ∗} is
also decidable
L = {<M> M is a PDA such that L(M) = Σ∗} is
undecidable and hence non-recursive.
From the given options, L = {⟨M⟩ ∣ M is a PDA such
that L(M)=Σ*} is completeness problem of CFL,
which is undecidable. Hence not recursive.

13. Suppose a database system crashes again while recovering from a previous crash.
Assume checkpointing is not done by the database either during the transactions or during
recovery. Which of the following statements is/are correct?
(A) The same undo and redo list will be used while recovering again
(B) The system cannot recover any further
(C) All the transactions that are already undone and redone will not be recovered again
(D) The database will become inconsistent

14. Which of the following standard C library functions will always invoke a system call
when executed from a single-threaded process in a UNIX/Linux operating system?
(A) exit
(B) malloc
(C) sleep
(D) strlen
Answer: (A) (C)
The exit and sleep call in Linux is also a system call.
malloc is a library call and not always a system call. This is a function defined in standard C library
and it does not always invoke the system call. When a process is created, certain amount of heap
memory is already allocated to it, when required to expand or shrink that memory, it internally uses
sbrk/brk system call on Unix/Linux.

15. Consider a linear list based directory implementation in a file system. Each directory is
a list of nodes, where each node contains the file name along with the file metadata, such
as the list of pointers to the data blocks. Consider a given directory foo. Which of the
following operations will necessarily require a full scan of foo for successful completion?
(A) Creation of a new file in foo
(B) Deletion of an existing file from foo
(C) Renaming of an existing file in foo
(D) Opening of an existing file in foo
Explanation:
The key here’s it is asking for successful completion.
Let’s take option one by one
A. Creation of new file    → while creating new file we have to check whether same name file
exist or not , so we always need full scan for this
B. Deletion of an existing file → for deleting file , file can be present at any node (best case if
present as first node, worst if present at last). So we don’t always need to full scan list.
C. Renaming of file → same reason can be given as option A.
D. Opening of existing file → same reason as option B.
So correct options are A , C

16. In an undirected connected planar graph G, there are eight vertices and five faces. The
number of edges in G is _________.
(A) 10
(B) 11
(C) 12
(D) 6
Given: For a planner graph G 
 Number of vertices(V)= 8
 Number of region/faces(R/f)=5
 Number of edges (E)=?
For any planner graph V+F=E+2
⟹8+5=E+2
⟹E=13−2=11
∴ Number of edges in given graph G is 11.
Similar Question: UGC NET june 2012
1. Two graphs A and B are shown below: Which one of the following statements is true?

A. Both A and B are planar


B. Neither A nor B is planar
C. A is planar and B is not
D. B is planar and A is not
Constructing planar version of given graph is quite time consuming. We can solve such questions
quickly using the relation :
If E is the number of edges and V is the number of vertices, and  E<= 3(V-2),  graph is  planar,
otherwise it is Not Planar.
1. A) V=4; E=6; 3*(V-2)=3(4-2)=6=E  //Planar
2. B) V=8; E=12 3*(V-2)=3(8-2)=18               E=12<18   //Planar
Answer: Both A and B are planar
UGC NET dec 2012
2. G1 and G2 are two graphs as shown:
A. Both G1 and G2 are planar graphs
B. Both G1 and G2 are not planar graphs
C. G1 is planar and G2 is not planar
D. G1 is not planar and G2 is planar
Gate 2015 set1
3. Let G be a connected planar graph with 10 vertices. If the number of edges on each face is three,
then the number of edges in G is_______24________.
Can we use the formula :
e <= 3n-6 for connected planar graph
for n=10 
e <= 30-6= 24

17. Consider the following undirected graph with edge


weights as shown: The number of minimum-weight
spanning trees of the graph is ___________.
(A) 3
(B) 4
(C) 5
(D) 2

18. The lifetime of a component of a certain type is a random


variable whose probability density function is exponentially
distributed with parameter 2. For a randomly picked
component of this type, the probability that its lifetime
exceeds the expected lifetime (rounded to 2 decimal places)
is ___0.35 to 0.39_.

19. There are 6 jobs with distinct difficulty levels, and


3 computers with distinct processing speeds. Each job
is assigned to a computer such that:
 The fastest computer gets the toughest job and the slowest computer gets the easiest job.
 Every computer gets at least one job.
The number of ways in which this can be done is ____65_______.
Explanation: As the toughest job is assigned to the fastest computer and the easiest job is assigned
to the slowest computer, we need to assign the remaining 4 jobs to the 3 computers such that every
computer was assigned at least one job.
∴ The required number of ways of arranging the remaining 4 jobs=(Total number of ways of
assigning the 4 jobs to the 3 computers) – (Number of ways of assigning the 4 jobs to the fastest and
the slowest computers only)=34 – 24=81 – 16=65

21. Consider the following sequence of operations on an empty stack.


Push(54);push(52);pop();push(55);push(62);s=pop();
Consider the following sequence of operations on an empty queue.
enqueue(21);enqueue(24);dequeue();enqueue(28);enqueue(32);q=dequeue();
The value of s+q is ____86_______.
22. Consider a computer system with a byte-addressable primary
memory of size 232 bytes. Assume the computer system has a
direct-mapped cache of size 32 KB (1 KB = 210 bytes), and each
cache block is of size 64 bytes.
The size of the tag field is ____17______ bits

23. A relation r(A,B) in a relational database has 1200 tuples.


The attribute A has integer values ranging from 6 to 20, and the
attribute B has integer values ranging from 1 to 20. Assume that
the attributes A and B are independently distributed.
The estimated number of tuples in the output of σ (A>10)∨(B=18)(r) is
____________.

Explanation: Probability of first condition satisfies, P(A) = 10/15


Probability of second condition satisfies, P(B) = 1/20
Probability of both condition satisfy, P(A∩B) = 10/15*1/20
Because of independent.
So, either first or second condition satisfy P(A∪B)
= P(A) + P(B) – P(A∩B)
= 10/15 + 1/20 – 10/15*1/20
= 0.6833
Therefore, estimated number of tuples in the output,
= 1200*0.6833
= 820
24. Consider the following representation of a number in IEEE 754 single-precision floating
point format with a bias of 127.
S: 1 E: 10000001 F: 11110000000000000000000
Here, S, E and F denote the sign, exponent, and fraction components of the floating point
representation.
The decimal value corresponding to the above representation (rounded to 2 decimal places) is
____________.
Explanation: Given
Sign bit = 1 → Number is negative.
Biased Exponent bits = 10000001 = 129 → E = 129-127 = 2
Mantissa bits = 11110000000000000000000

Number = – 1.111100…00 * 22 → -111.11


Hence, Number = -7.75 in decimal.

25. Three processes arrive at time zero with CPUCPU bursts


of 16,2016,20 and 1010 milliseconds. If the scheduler has prior knowledge about the
length of the CPUCPU bursts, the minimum achievable average waiting time for these three
processes in a non-preemptive scheduler (rounded to nearest integer) is ______12______
milliseconds.
Explanation:
 SJF gives minimum average waiting time over other non-premitive CPU scheduling
algorithms.
 in the SJF technique select the process which has minimum burst time 
order them according to burst time C<A<B
27. The following relation records the age of 500500 employees of a company,
where empNo (indicating the employee number) is the key:
empAge(empNo−−−−−−,age)
Consider the following relational algebra expression:
ΠempNo(empAge⋈(age>age1)ρempNo1,age1(empAge))
What does the above expression generate?
A. Employee numbers of only those employees whose age is the maximum
B. Employee numbers of only those employees whose age is more than the age of exactly one
other employee
C. Employee numbers of all employees whose age is not the minimum
D. Employee numbers of all employees whose age is the minimum

28. Consider a 3-bit counter, designed using T flip-flops, as shown below:

 Assuming the initial state of the counter given by PQRPQR as 000000, what are the next three
states?
A. 011,101,000
B. 001,010,111
C. 011,101,111
D. 001,010,000

30. Consider the following recurrence relation.


T(n)={T(n/2)+T(2n/5)+7n if n>0
1 if n=0
Which one of the following options is correct?
A. T(n)=Θ(n5/2)
B. T(n)=Θ(nlogn)
C. T(n)=Θ(n)
D. T(n)=Θ((logn)5/2)

32. Let ri(z) and wi(z) denote read and write operations respectively on a data item z by a


transaction Ti. Consider the following two schedules.
 S1:r1(x)r1(y)r2(x)r2(y)w2(y)w1(x)
 S2:r1(x)r2(x)r2(y)w2(y)r1(y)w1(x)
Which one of the following options is correct?
A. S1 is conflict serializable, and S2 is not conflict serializable
B. S1 is not conflict serializable, and S2 is conflict serializable
C. Both S1 and S2 are conflict serializable
D. Niether S1 nor S2 is conflict serializable

A schedule S is CSS if their precedence graph is acyclic. A precedence


graph can have cycle iff:
 either read-write conflict
 either write-read conflict
 Either write-write conflict.
Precedence graph of schedule S1: following conflicts resent in schedule S1
1. r1(y)→w2(y)
2. r2(x)→w1(x)
Precedence graph of schedule S2:
Following conflicts present in schedule S2
1. r2(x)→w1(x)
2. w2(y)→r1(y)
It is clearly visible that S1 having a cycle so it’s not CSS whereas S2 is acyclic graph, it’s
CSS.
Option B is correct.

33. Consider the relation R(P,Q,S,T,X,Y,Z,W)with the following functional dependencies.


PQ→X; P→YX; Q→Y; Y→ZW
Consider the decomposition of the relation RR into the constituent relations according to
the following two decomposition schemes.
 D1:R=[(P,QS,T);(P,T,X);(Q,Y);(Y,Z,W)]
 D2:R=[(P,Q,S);(T,X);(Q,Y);(Y,Z,W)]
Which one of the following options is correct?
A. D1 is a lossless decomposition, but D2 is a lossy decomposition
B. D1 is a lossy decomposition, but D2 is a lossless decomposition
C. Both D1 and D2 are lossless decompositions
D. Both D1 and D2 are lossy decompositions

34. Let G be a group of order 6, and H be a subgroup of G such that 1<|H|<6. Which one of
the following options is correct?
A. Both G and H are always cyclic
B. G may not be cyclic, but H is always cyclic
C. G is always cyclic, but H may not be cyclic
D. Both G and H may not be cyclic

Given G is a group of order 6.


Lagrange's Theorem: The order of every subgroup of G divides the order of G
So, Subgroup (H) of G can be the order of 1,2,3,6 but 6 is not possible as we need a proper sub-
group as mentioned in the question.
Now, any Group of prime order is cyclic. If the order is not-prime both cyclic and acyclic groups are
possible.
Order of G=6– Not a prime number so G may or may not be cyclic.
Order of H={1,2,3}–2 and 3 are prime numbers and Group with 1 element is cyclic. So, 
H is always cyclic.
Ans : (B) G may not be cyclic, but H is always cyclic

35. Consider the two statements.


 S1: There exist random variables XX and YY such that (E[(X−E(X))(Y−E(Y))])2>Var[X]Var[Y]
 S2: For all random variables X and Y, Cov[X,Y]=E[|X−E[X]||Y−E[Y]|]Y,
Which one of the following choices is correct?
A. Both S1 and S2 are true
B. S1 is true, but S2 is false
C. S1 is false, but S2 is true
D. Both S1 and S2 are false
37. Consider the following ANSI C ANSI C program.
1. #include <stdio.h>
2. int main()
3. {
4. int i, j, count;
5. count=0;
6. i=0;
7. for (j=-3; j<=3; j++)
8. {
9. if (( j >= 0) && (i++))
10. count = count + j;
11. }
12. count = count +i;
13. printf("%d", count);
14. return 0;
15. }
Which one of the following options is correct?
A. The program will not compile successfully
B. The program will compile successfully and output 10 when executed
C. The program will compile successfully and output 8 when executed
D. The program will compile successfully and output 13 when executed

1. for (j=-3; j<=3; j++)


2. {
3. if (( j >= 0) && (i++))
4. count = count + j;
5. }

From the above loop code we can see that the loop iterates 7 times for j∈{−3,−2,−1,0,1,2,3}.

Now, we have an “if” condition and inside it we have a logical AND operator (&&). In C language we
have the following short-circuit rule for binary logical operators
1. The second operand of logical OR operator || is ignored if the first operand is non zero.
2. The second operand of logical AND operator (&&) is ignored if the first operand is 0.
So, for j∈{−3,−2,−1} the first operand of || operator (j >= 0) will be 0, and hence the second
operand (i++) will be ignored. 
For j∈{0,1,2,3} the first operand of || operator (j >= 0) will be 1,and hence the second
operand (i++) will get evaluated 4 times and final value of i=4.

Initial value of i=0. 

The post increment operator i++, returns the original value of ii and then increments i. So, when the first
time i++ happens, the second operator of logical AND operator is 0 and hence the “if” condition fails.

So, count = count +j happens only for j∈{1,2,3} and we get count=0+1+2+3=6.

After the loop, we have count = count + i, which makes count=6+4=10.


So, correct option: B.

38. Consider the following language:


L={w∈{0,1}∗∣w ends with the substring 011}
Which one of the following deterministic finite automata accepts L?

The correct automata for LL must accept every binary string ending with “011” and not accept any
other binary string.
A. False it accepts binary strings ending with 111
B. False it accepts binary strings ending with 0,00,00,100,001,111 etc.
C. False it accepts binary string ending with 1111
D. True it accepts all strings that end with 011 and no other strings.
Correct Ans: D

39. Same question in gate 2016


For a Turing machine M, ⟨M⟩ denotes an encoding of M. Consider the following two languages.
L1={⟨M⟩∣M takes more than 2021 steps on all inputs}
L2={⟨M⟩∣M takes more than 2021 steps on some input}
Which one of the following options is correct?
A. Both L1 and L2 are decidable
B. L1 is decidable  and L2 is undecidable
C. L1 is undecidable  and L2 is decidable
D. Both L1 and L2 are undecidable

You might also like