GATE CS 2008
Question 2 
Q^{c} U R^{c}  
P U Q^{c} U R^{c}  
P^{c} U Q^{c} U R^{c}  
U 
Discuss it
Question 3 
0  
either 0 or 1  
one of 0, 1 or 1  
any real number  
any real number other than 5 
Discuss it
Question 3 Explanation:
The choice E was not there in GATE paper. We have added it as the given 4 choices don't seem correct.
Augment the given matrix as 1 1 2  1 1 2 3  2 1 4 a  4 Apply R2 < R2  R1 and R3 < R3  R1 1 1 2  1 0 1 1  1 0 3 a2  3 Apply R3 < R3  3R2 1 1 2  1 0 1 1  1 0 0 a5  0 So for the system of equations to have a unique solution, a  5 != 0 or a != 5 or a = R  {5}Thanks to Anubhav Gupta for providing above explanation. Readers can refer below MIT video lecture for linear algebra. https://www.youtube.com/watch?v=QVKj3LADCnA&index=2&list=PLE7DDD91010BC51F8
Question 4 
In the IEEE floating point representation, the hexadecimal value 0 × 00000000 corresponds to
the normalized value 2^{127}  
the normalized value 2^{126}  
the normalized value +0  
the special value +0 
Discuss it
Question 5 
In the Karnaugh map shown below, X denotes a don't care term. What is the minimal form of the function represented by the Karnaugh map?
A) B) C) D)
A  
B  
C  
D 
Discuss it
Question 6 
decimal 10  
decimal 11  
decimal 10 and 11  
any value > 2 
Discuss it
Question 6 Explanation:
As we can see 121 contains digit ‘2’ which can’t be represented directly in base ‘2’ (as digits should be less than base) so number system must have “r>2”.
Ans (D) part.
Question 7 
Given f_{1}, f_{3} and f in canonical sum of products form (in decimal) for the circuit
A) m(4, 6) B) m(4, 8) C) m(6, 8) D) m(4, 6, 8)
A  
B  
C  
D 
Discuss it
Question 7 Explanation:
From logic diagram we have f=f1.f2+f3
f=m(4,5,6,7,8).f2+m(1,6,15)(1)
from eq(1) we need to find such f2 so that we can get f=m(1,6,8,15)
eq(1) says we can get m(1,6,15) from f3 ,so only 8 left
now from option (a,b,d) we get (4,6), (4,8) ,(4,6,8) respectively for m(4,5,6,7,8)f2 which is not required as m4 is undesired.
But option (D) m(4,5,6,7,8)(6,8)+(1,6,15)
 m(6,8)+m(1,6,15)
 m(1,6,8,15)an
Question 8 
It is not accepted by a Turing Machine  
It is regular but not contextfree  
It is contextfree but not regular  
It is neither regular nor contextfree, but accepted by a Turing machine 
Discuss it
Question 8 Explanation:
Turing machine can be designed for a^{p} using the concept of ‘Sieve of Eratosthenes’.
Suppose we are given an integer ‘n’ and we want to find out all the prime numbers less than or equal to ‘n’. We repeat the following steps : We find the smallest number in the list, declare it prime and eliminate all the multiples of that number from the list. We keep doing this until each element has been declared prime or eliminated from the list.
Now, if p = 0 or p = 1, we reject the input. Else, we replace the first and the last ‘a’ with symbol $.
In the above steps, what we do is we find the first nonblack symbol from the left. Let this symbol occur at position ‘x’. Suppose ‘x’ is a prime number. If this nonblank symbol is $, input string will be accepted. But, if the symbol is ‘a’, we mark it as a* and replace all the multiples of ‘x’ with the symbol ‘blank’. If at the end, symbol $ is replaced with 'blank’, we reject the input string (because p will be multiple of some ‘x’ in that case). Else, we go back and repeat the steps.
Thus, the input is neither regular nor contextfree, but is accepted by a Turing machine.
Please comment below if you find anything wrong in the above post.
Suppose we are given an integer ‘n’ and we want to find out all the prime numbers less than or equal to ‘n’. We repeat the following steps : We find the smallest number in the list, declare it prime and eliminate all the multiples of that number from the list. We keep doing this until each element has been declared prime or eliminated from the list.
Now, if p = 0 or p = 1, we reject the input. Else, we replace the first and the last ‘a’ with symbol $.
In the above steps, what we do is we find the first nonblack symbol from the left. Let this symbol occur at position ‘x’. Suppose ‘x’ is a prime number. If this nonblank symbol is $, input string will be accepted. But, if the symbol is ‘a’, we mark it as a* and replace all the multiples of ‘x’ with the symbol ‘blank’. If at the end, symbol $ is replaced with 'blank’, we reject the input string (because p will be multiple of some ‘x’ in that case). Else, we go back and repeat the steps.
Thus, the input is neither regular nor contextfree, but is accepted by a Turing machine.
Please comment below if you find anything wrong in the above post.
Question 9 
Which of the following are decidable?
I. Whether the intersection of two regular languages is infinite II. Whether a given contextfree language is regular III. Whether two pushdown automata accept the same language IV. Whether a given grammar is contextfree
I and II  
I and IV  
II and III  
II and IV 
Discuss it
Question 9 Explanation:
(A) Intersection of two regular languages is regular and checking if a regular language is infinite is decidable.
(B) Deciding regularity of a context free language is undecidable.
We check if L(CFG) contains any string with length between n and 2n−1 , where n is the pumping lemma constant. If so, L(CFG) is infinite otherwise it is finite.
(C) Equality problem is undecidable for all languages except in case of finite automata i.e. for regular languages.
(D) We have to check if the grammar obeys the rules of CFG. If, it obeys such rules then it is decidable.
Thus, option (B) is correct.
Please comment below if you find anything wrong in the above post.
Question 10 
Which of the following describes a handle (as applicable to LRparsing) appropriately?
It is the position in a sentential form where the next shift or reduce operation will occur
 
It is nonterminal whose production will be used for reduction in the next step  
It is a production that may be used for reduction in a future step along with a position in the sentential form where the next shift or reduce operation will occur  
It is the production p that will be used for reduction in the next step along with a position in the sentential form where the right hand side of the production may be found 
Discuss it
Question 10 Explanation:
Let's first understand the terminology used here.
LR Parsing  Here 'L' stands for Left to Right screening of input string, and 'R' stands for Right Most Derivation in Reverse ( because it is about bottomup parsing).
Sentential Form  Suppose For a given Context Free Grammar G, we have a start symbol S, then to define Language generated by Grammar G, i.e. L(G), we start the derivation starting from S using the production rules of the grammar. After one complete derivation we get a string w which consists of only terminal symbols, i.e. w belongs to L(G). Then we can say that w is a sentence of the Grammar G. Now, while the derivation process, if it gets some form q, where q may contain some Nonterminal then we say that q is a sentential form of the Grammar G. Even the start symbol S is also the sentential form of the Grammar G ( because it also contains Nonterminal S).
For Ex : Grammar is : S> aAcBe A>Abb B>d Input string : abbcde Derivation : ( TopDown, Right Most Derivation) S>aAcBe >aAcde >aAbcde >abbcdeHere { abbcde } is the sentence of the Grammar( because it contains only terminal symbols), and { S, aAcBe, aAcde, aAbcde } are the sentential forms of the G ( because these forms contain nonterminals during the derivation process ) Now, let's look at the question. The question is related to LR parsing which is a bottomup parsing. Let's take the same grammar above, as it is a bottom up parsing we need to start from the string "abbcde" and try to get S using production rules.
: abbcde >aAbcde ( using A> b ) >aAcde ( using A> Ab ) >aAcBe ( using B > d ) >S ( using S> aAcBe )The above process is called reduction. The RHS of the Production which is being replaced by their LHS is called Handle, So , { b, Ab, d, aAcBe} are handles, and replacing it with its LHS is called HandlePruning. Hence option D suits best.
Question 11 
Some code optimizations are carried out on the intermediate code because
they enhance the portability of the compiler to other target processors  
program analysis is more accurate on intermediate code than on machine code  
the information from dataflow analysis cannot otherwise be used for optimization  
the information from the front end cannot otherwise be used for optimization 
Discuss it
Question 11 Explanation:
Option (B) is also true. But the main purpose of doing some codeoptimization on intermediate code generation is to enhance the portability of the compiler to target processors. So Option A) is more suitable here.
Intermediate code is machine/architecture independent code. So a compiler can optimize it without worrying about the architecture on which the code is going to execute (it may be the same or the other ). So that kind of compiler can be used by multiple different architectures.
In contrast to that, suppose code optimization is done on target code, which is machine/architecture dependent, then the compiler has be specific about the optimizations on that kind of code. In this case the compiler can't be used by multiple different architectures, because the target code produced on different architectures would be different. Hence portability reduces here.
Question 12 
If L and L' are recursively enumerable, then L is
regular  
contextfree
 
contextsensitive  
recursive 
Discuss it
Question 12 Explanation:
If L is recursively enumerable, then L' is recursively enumerable if and only if L is also recursive.
Question 13 
What is the maximum size of data that the application layer can pass on to the TCP layer below?
Any size  
2^{16} bytes  size of TCP header
 
2^{16} bytes  
1500 bytes 
Discuss it
Question 13 Explanation:
The default TCP Maximum Segment Size is 536. Where a host wishes to set the maximum segment size to a value other than the default, the maximum segment size is specified as a TCP option, initially in the TCP SYN packet during the TCP handshake. Because the maximum segment size parameter is controlled by a TCP option, a host can change the value in any later segment.
Source: http://en.wikipedia.org/wiki/Maximum_segment_size
Question 15 
A clustering index is defined on the fields which are of type
nonkey and ordering  
nonkey and nonordering  
key and ordering  
key and nonordering 
Discuss it
Question 15 Explanation:
A clustering index as the name suggests is created when the data can be grouped in the form of clusters.
For example: A small database file storing roll no and subjects enrolled for a particular student. Here data can be grouped on the basis of Roll No.s.
Hence to create such kind of index files, fields could be nonkey attributes and which are in ordered form so as to form clusters easily.
Hence option (A) – non key and ordering.
Additional points for Clustered Indexing:
1. The number of entries in the index file are the unique values of the attribute on which indexing is done.
2. The pointer in the index file will give the base address of the block in which the value appear for the first time.
http://quiz.geeksforgeeks.org/indexingindatabasesset1/
This solution is contributed by Yashika Arora.
Question 16 
Which of the following system calls results in the sending of SYN packets?
socket  
bind  
listen  
connect 
Discuss it
Question 16 Explanation:
socket() creates a new socket of a certain socket type, identified by an integer number, and allocates system resources to it.
bind() is typically used on the server side, and associates a socket with a socket address structure, i.e. a specified local port number and IP address.
listen() is used on the server side, and causes a bound TCP socket to enter listening state.
connect() is used on the client side, and assigns a free local port number to a socket. In case of a TCP socket, it causes an attempt to establish a new TCP connection.
When connect() is called by client, following three way handshake happens to establish the connection in TCP.
1) The client requests a connection by sending a SYN (synchronize) message to the server.
2) The server acknowledges this request by sending SYNACK back to the client.
3) The client responds with an ACK, and the connection is established.
Sources: Berkeley sockets, TCP Connection Establishment and Termination
Question 17 
The Breadth First Search algorithm has been implemented using the queue data structure. One possible order of visiting the nodes of the following graph is
MNOPQR  
NQMPOR  
QMNPRO  
QMNPOR 
Discuss it
Question 17 Explanation:
The Breadth First Search visits the "breadth" first, i.e. if it is visiting a node then after visiting that node, it will visit the neighbor nodes (children) first before moving on to the next level neighbors.
Let's see how.
Initially : If BFS starts at node Q, it first visits Q and puts Q in the Queue.
So, Queue contains : Q.
And, Visiting Order yet is : Q.
Now it dequeues Q, and explores its neighbors, which are {M,N,P}. It checks for those neighbors of Q which are not visited yet, then it visits them, and puts them in Queue (so that later their neighbors can be visited).
Now, these neighbors can be visited and put them in Queue in any order (depends on the implementation).
Suppose it visits and put them in the Queue in the order ( M N P ) with M being at the FRONT and P at the REAR.
So, Visiting Order : QMNP.
Now, it looks for the next entry in Queue. As Queue follows FIFO principle, M gets dequeued.
Queue contains : ( N P )
It explores M, finds its neighbors { N, Q, R }, but before visiting them it checks whether these have been visited earlier, it will only visit and put those nodes in the Queue which are not visited yet. As N and Q have been visited earlier, it will only visit R and enqueue it.
Visiting Order : QMNPR.
Queue contains : ( N P R ).
Now, N gets dequeued.
Queue contains : ( P R ).
It explores N, finds its neighbors { M, O, Q }. As M and Q have been visited earlier, it will only visit and enqueue O.
Visiting Order : QMNPRO.
Queue contains : ( P R O ).
Now, P gets dequeued.
Queue contains : (R O).
It explores P, finds its neighbors { O, Q }. As O and Q have been visited earlier, it will NOT enqueue .
Now, R gets dequeued.
Queue contains : (O).
It explores R, finds its neighbor { M }. As M has been visited earlier, it will NOT enqueue.
Now, O gets dequeued.
Queue contains : ( ) .
It explores O, finds its neighbors { N, P }. As both have been visited earlier, it will NOT enqueue.
Now Queue is empty, hence BFS stops here.
And the visiting order has been : QMNPRO.
The Pseudocode for the above explanation can be found at https://en.wikipedia.org/wiki/Breadthfirst_search
Question 18 
Which combination of the integer variables x, y and z makes the variable a get the value 4 in the following expression?
a = ( x > y ) ? (( x > z ) ? x : z) : (( y > z ) ? y : z )
x = 3, y = 4, z = 2  
x = 6, y = 5, z = 3  
x = 6, y = 3, z = 5  
x = 5, y = 4, z = 5 
Discuss it
Question 18 Explanation:
The given expression assigns maximum among three elements (x, y and z) to a.
Question 19 
The most efficient algorithm for finding the number of connected components in an undirected graph on n vertices and m edges has time complexity
&thetha;(n)  
&thetha;(m)  
&thetha;(m + n)  
&thetha;(mn) 
Discuss it
Question 20 
The data blocks of a very large file in the Unix file system are allocated using
contiguous allocation  
linked allocation  
indexed allocation  
an extension of indexed allocation 
Discuss it
Question 20 Explanation:
The Unix file system uses an extension of indexed allocation. It uses direct blocks, single indirect blocks, double indirect blocks and triple indirect blocks. Following diagram shows implementation of Unix file system. The diagram is taken from Operating System Concept book.
Question 21 
The minimum number of equal length subintervals needed to approximate to an accuracy of at least using the trapezoidal rule is
1000 l  
1000  
100 l  
100 
Discuss it
Question 21 Explanation:
Trapezoidal rule error :
Maximum error = 1/3 * 10^{6} (given)
Therefore, E_{n} < 1/3 * 10^{6}
a = 1 and b = 2 (given)
Therefore,
f''(x) = xe^{x} + 2e^{x}
f''(x) is maximum at x = 2.
Therefore, f''(x) = 4e^{2}
Thus, option (A) is correct.
Reference: http://www.cse.iitd.ac.in/~mittal/gate/gate_math_2008.html
Please comment below if you find anything wrong in the above post.
Question 22 
square of R  
reciprocal of R  
square root of R  
logarithm of R 
Discuss it
Question 22 Explanation:
According to NewtonRaphson method,
x_{n+1} = x_{n} − f(x_{n}) / f′(x_{n})So we try to bring given equation in above form. Given equation is :
x_{n+1} = x_{n}/2 + R/(2x_{n}) = x_{n} − x_{n}/2 + R/(2x_{n}) = x_{n} − (x_{n}^{2} − RSo clearly f(x) = x^{2} − R, so root of f(x) means x^{2} − R = 0 i.e. we are trying to find square root of R. So option (C) is correct. Source: http://www.cse.iitd.ac.in/~mittal/gate/gate_math_2008.html2)/(2x_{n})
Question 23 
Which of the following statements is true for every planar graph on n vertices?
The graph is connected  
The graph is Eulerian  
The graph has a vertexcover of size at most 3n/4  
The graph has an independent set of size at least n/3 
Discuss it
Question 23 Explanation:
A planar graph is a graph which can drawn on a plan without any pair of edges crossing each other.
A) FALSE: A disconnected graph can be planar as it can be drawn on a plane without crossing edges.
B) FALSE: An Eulerian Graph may or may not be planar. An undirected graph is eulerian if all vertices have even degree.
For example, the following graph is Eulerian, but not planar
C) TRUE:
D) FALSE:
Question 24 
P = Q  k  
P = Q + k  
P = Q  
P = Q +2 k 
Discuss it
Question 24 Explanation:
P is sum of odd integers from 1 to 2k Q is sum of even integers from 1 to 2k Let k = 5 P is sum of odd integers from 1 to 10 P = 1 + 3 + 5 + 7 + 9 Q is sum of even integers from 1 to 10 Q = 2 + 4 + 6 + 8 + 10 In general, Q can be written as Q = (1 + 3 + 5 + 9..... ) + (1 + 1 + .....) = P + k
Question 25 
A point on a curve is said to be an extremum if it is a local minimum or a local maximum. The number of distinct extrema for the curve 3x^{4}  16x^{3} + 24x^{2} + 37
0  
1  
2  
3 
Discuss it
Question 26 
If P, Q, R are Boolean variables, then (P + Q')(PQ' + PR)(P'R' + Q') simplifies
PQ'  
PR'  
PQ' + R  
PR'' + Q 
Discuss it
Question 27 
Aishwarya studies either computer science or mathematics everyday. If she studies computer science on a day, then the probability that she studies mathematics the next day is 0.6. If she studies mathematics on a day, then the probability that she studies computer science the next day is 0.4. Given that Aishwarya studies computer science on Monday, what is the probability that she studies computer science on Wednesday?
0.24  
0.36  
0.4  
0.6 
Discuss it
Question 29 
Let X be a random variable following normal distribution with mean +1 and variance 4. Let Y be another normal variable with mean 1 and variance unknown If P(X <=1) = P(Y >2). the standard deviation of Y is
3  
2  
sqrt(2)  
1 
Discuss it
Question 30 
Let fsa and pda be two predicates such that fsa(x) means x is a finite state automaton, and pda(y) means that y is a pushdown automaton. Let equivalent be another predicate such that equivalent (a, b) means a and b are equivalent. Which of the following first order logic statements represents the following:
Each finite state automaton has an equivalent pushdown automaton.
A  
B  
C  
D 
Discuss it
Question 30 Explanation:
Considering each option :
(A) If everything is a FSA, then there exists an equivalent PDA for everything.
(B) It is not the case that for all y if there exist a FSA then it has an equivalent PDA.
(C) Everything is a FSA and has an equivalent PDA.
(D) Everything is a PDA and has exist an equivalent FSA.
Thus, option (A) is correct.
Please comment below if you find anything wrong in the above post.
(A) If everything is a FSA, then there exists an equivalent PDA for everything.
(B) It is not the case that for all y if there exist a FSA then it has an equivalent PDA.
(C) Everything is a FSA and has an equivalent PDA.
(D) Everything is a PDA and has exist an equivalent FSA.
Thus, option (A) is correct.
Please comment below if you find anything wrong in the above post.
Question 31 
For a magnetic disk with concentric circular tracks, the seek latency is not linearly proportional to the seek distance due to
nonuniform distribution of requests  
arm starting and stopping inertia  
higher capacity of tracks on the periphery of the platter  
use of unfair arm scheduling policies 
Discuss it
Question 31 Explanation:
Whenever head moves from one track to other then its speed and direction changes, which is noting but change in motion or the case of inertia. So answer B
This explanation has been contributed by Abhishek Kumar.
See Disk drive performance characteristics_Seek_time
Question 32 
Which of the following is/are true of the autoincrement addressing mode?
I. It is useful in creating selfrelocating code. II. If it is included in an Instruction Set Architecture, then an additional ALU is required for effective address calculation. III.The amount of increment depends on the size of the data item accessed.
I only  
II only  
III Only  
II and III only 
Discuss it
Question 32 Explanation:
In autoincrement addressing mode the address where next data block to be stored is generated automatically depending upon the size of single data item required to store.
Self relocating code takes always some address in memory and statement says that this mode is used for self relocating code so option 1 is incorrect and no additional ALU is required So option (C) is correct option.
Question 33 
Only I and II  
Only I, II and III  
Only I, II and IV  
All of I, II, III and IV 
Discuss it
Question 33 Explanation:
I and II are same by Demorgan's law
The IIIrd can be simplified to I.
Question 34 
Which of the following must be true for the RFE (Return from Exception) instruction on a general purpose processor?
I. It must be a trap instruction II. It must be a privileged instruction III. An exception cannot be allowed to occur during execution of an RFE instruction
I only  
II only  
I and II only  
I, II and III only 
Discuss it
Question 34 Explanation:
RFE (Return From Exception) is a privileged trap instruction that is executed when exception occurs, so an exception is not allowed to execute.
In computer architecture for a general purpose processor, an exception can be defined as an abrupt transfer of control to the operating system. Exceptions are broadly classified into 3 main categories:
a. Interrupt: it is mainly caused due to I/O device.
b. Trap: It is caused by the program making a syscall.
c. Fault: It is accidentally caused by the program that is under execution such as( a divide by zero, or null pointer exception etc).
The processor’s fetch instruction unit makes a poll for the interrupts. If it finds something unusual happening in the machine operation it inserts an interrupt pseudo instruction in the pipeline in place of the normal instruction. Then going through the pipeline it starts handling the interrupts. The operating system explicitly makes a transition from kernel mode to user mode, generally at the end of an interrupt handle pr kernel call by using a privileged instruction RFE( Return From Exception) instruction.
This solution is contributed by Namita Singh
Question 35 
For inclusion to hold between two cache levels L1 and L2 in a multilevel cache hierarchy, which of the following are necessary?
I. L1 must be a writethrough cache II. L2 must be a writethrough cache III. The associativity of L2 must be greater than that of L1 IV. The L2 cache must be at least as large as the L1 cache
IV only  
I and IV only  
I, III and IV only  
I, II, III and IV 
Discuss it
Question 35 Explanation:
Answer is (B), i.e., (i) and (iv) are true.
Because inclusion says the L2 cache should be Superset of L1 cache. If "Write Through update" is not used (and "Write Back update" is used ) at L1 cache, then the modified data in L1 cache will not be present in L2 cache for some time unless the block in L1 cache is replaced by some other block. Hence "Write Through Update " should be used.
Associativity doesn't matter.
L2 cache must be at least as large as L1 cache, since all the words in L1 are also is L2.
Question 36 
Which of the following are NOT true in a pipelined processor?
I. Bypassing can handle all RAW hazards. II. Register renaming can eliminate all register carried WAR hazards. III. Control hazard penalties can be eliminated by dynamic branch prediction.
I and II only  
I and III only  
II and III only  
I, II and III 
Discuss it
Question 36 Explanation:
i) In a Pipelined processor bypassing can’t handle all the raw hazards. A read after write (RAW) data hazard refers to a situation where an instruction refers to a result that has not yet been calculated or retrieved. This can occur because even though an instruction is executed after a previous instruction, the previous instruction has not been completely processed through the pipeline.Consider when any instruction depends on the result of LOAD instruction, now LOAD updates register value at Memory Access Stage (MA), so data will not be available directly on Execute stage.
ii) WAR(Write After Read ) A write after read (WAR) data hazard represents a problem with concurrent execution. Register carried WAR does not have register renaming as proper solution because If programs refrained from reusing registers immediately, there would be no need for register renaming. There are limitations to this approach:
 It is very difficult for the compiler to avoid reusing registers without large code size increases.
 Large numbers of registers require more bits for specifying a register as an operand in an instruction, resulting in increased code size.
 Many instruction sets historically specified smaller numbers of registers and cannot be changed now.
 Control hazard penalties are handled by delayed branching not by dynamic branch prediction.
Question 37 
The use of multiple register windows with overlap causes a reduction in the number of memory accesses for
I. Function locals and parameters II. Register saves and restores III. Instruction fetches
I only  
II only  
III only  
I, II and III 
Discuss it
Question 37 Explanation:
I is true as by using multiple register windows, we eliminate the need to access the variable values again and again from the memory. Rather, we store them in the registers.
II is false as register saves and restores would still be required for each and every variable.
III is also false as instruction fetch is not affected by memory access using multiple register windows.
So, only I is true. Hence, A is the correct option.
Please comment below if you find anything wrong in the above post.
II is false as register saves and restores would still be required for each and every variable.
III is also false as instruction fetch is not affected by memory access using multiple register windows.
So, only I is true. Hence, A is the correct option.
Please comment below if you find anything wrong in the above post.
Question 38 
In an instruction execution pipeline, the earliest that the data TLB (Translation Lookaside Buffer) can be accessed is
before effective address calculation has started  
during effective address calculation  
after effective address calculation has completed  
after data cache lookup has completed 
Discuss it
Question 38 Explanation:
When we calculate effective address, first of all we access TLB to access the Frame number.
Logical address generated by CPU breaks in two parts : page number and page offset, for faster accessing of data we place some page table entries in a small hardware TLB whose access time is same as cache memory. So initially when page no. is mapped to find the corresponding frame no., first it is look up in TLB and then in pagetable (in case if TLB miss).
During effective address calculation TLB is accessed.
So (B) is correct option.
Question 39 
Consider the following functions:
f(n) = 2^{n} g(n) = n! h(n) = n^{logn}Which of the following statements about the asymptotic behaviour of f(n), g(n), and h(n) is true?
(A) f(n) = O(g(n)); g(n) = O(h(n)) (B) f(n) = (g(n)); g(n) = O(h(n)) (C) g(n) = O(f(n)); h(n) = O(f(n)) (D) h(n) = O(f(n)); g(n) = (f(n))
A  
B  
C  
D 
Discuss it
Question 39 Explanation:
According to order of growth: h(n) < f(n) < g(n) (g(n) is asymptotically greater than f(n) and f(n) is asymptotically greater than h(n) )
We can easily see above order by taking logs of the given 3 functions
lognlogn < n < log(n!) (logs of the given f(n), g(n) and h(n)).Note that log(n!) = [Tex]\theta[/Tex](nlogn)
Question 40 
The minimum number of comparisons required to determine if an integer appears more than n/2 times in a sorted array of n integers is
(A) (n) (B) (logn) (C) (log*n) (D) (n)
A  
B  
C  
D 
Discuss it
Question 40 Explanation:
The Best way to find out whether an integer appears more than n/2 times in a sorted array(Ascending Order) of n integers, would be binary search approach.
1. The First occurence of an element can be found out in O(log(n)) time using divide and conquer technique,lets say it is i.
2. The Last occurrence of an element can be found out in O(log(n)) time using divide and conquer technique,lets say it is j.
3. Now number of occuerence of that element(count) is (ji+1). Overall time complexity = log n +log n +1 = O(logn)
See Check for Majority Element in a sorted array
This solution is contributed by Nirmal Bharadwaj
Question 41 
A Btree of order 4 is built from scratch by 10 successive insertions. What is the maximum number of node splitting operations that may take place?
3  
4  
5  
6 
Discuss it
Question 41 Explanation:
Insertion of 3 keys 10 20 30 Insertion of 4th key (1st split) 30 / \ 10*20 40 Insertion of 5th key no split To maximize splits, let us insert a value in a node that has key in access. Let us insert 5 30 / \ 5*10*20 40 Insertion of 6th key (2nd Split) To maximize splits, let us insert a value in a node that has key in access. Let us insert 6 8*30 /  \ 5 10*20 40 Insertion of 7th key To maximize splits, let us insert a value in a node that has key in access. Let us insert 15 8*30 /  \ 5 10*15*20 40 Insertion of 8th key (3rd Split) To maximize splits, let us insert a value in a node that has key in access. Let us insert 12 8*12*30 / / \ \ 5 10 15*20 40 Insertion of 9th key To maximize splits, let us insert a value in a node that has key in access. Let us insert 17 8*12*30 / / \ \ 5 10 15*17*20 40 Insertion of 10th key (4th and 5th Splits) To maximize splits, let us insert a value in a node that has key in access. Let us insert 13 12 / \ 8 15*30 / \ /  \ 5 10 13 17*20 40
Question 42 
G is a graph on n vertices and 2n  2 edges. The edges of G can be partitioned into two edgedisjoint spanning trees. Which of the following is NOT true for G?
For every subset of k vertices, the induced subgraph has at most 2k2 edges  
The minimum cut in G has at least two edges  
There are two edgedisjoint paths between every pair to vertices  
There are two vertexdisjoint paths between every pair of vertices 
Discuss it
Question 42 Explanation:
Counter for option D is as follows. Take two copies of K4(complete graph on 4 vertices), G1 and G2. Let V(G1)={1,2,3,4} and V(G2)={5,6,7,8}. Construct a new graph G3 by using these two graphs G1 and G2 by merging at a vertex, say merge (4,5). The resultant graph is two edge connected, and of minimum degree 2 but there exist a cut vertex, the merged vertex.
Thanks to Renjith P for providing above explanation.
Question 43 
Consider the Quicksort algorithm. Suppose there is a procedure for finding a pivot element which splits the list into two sublists each of which contains at least onefifth of the elements. Let T(n) be the number of comparisons required to sort n elements. Then
T(n) <= 2T(n/5) + n  
T(n) <= T(n/5) + T(4n/5) + n  
T(n) <= 2T(4n/5) + n  
T(n) <= 2T(n/2) + n 
Discuss it
Question 43 Explanation:
For the case where n/5 elements are in one subset, T(n/5) comparisons are needed for the first subset with n/5 elements, T(4n/5) is for the rest 4n/5 elements, and n is for finding the pivot.
If there are more than n/5 elements in one set then other set will have less than 4n/5 elements and time complexity will be less than T(n/5) + T(4n/5) + n because recursion tree will be more balanced.
Question 44 
The subsetsum problem is defined as follows. Given a set of n positive integers, S = {a1 ,a2 ,a3 ,...,an} and positive integer W, is there a subset of S whose elements sum to W? A dynamic program for solving this problem uses a 2dimensional Boolean array X, with n rows and W+1 columns. X[i, j], 1 <= i <= n, 0 <= j <= W, is TRUE if and only if there is a subset of {a1 ,a2 ,...,ai} whose elements sum to j. Which of the following is valid for 2 <= i <= n and ai <= j <= W?
X[i, j] = X[i  1, j] V X[i, j ai]  
X[i, j] = X[i  1, j] V X[i  1, j  ai]  
X[i, j] = X[i  1, j] V X[i, j  ai]  
X[i, j] = X[i  1, j] V X[i 1, j  ai] 
Discuss it
Question 44 Explanation:
X[I, j] (2 <= i <= n and ai <= j <= W), is true if any of the following is true
1) Sum of weights excluding ai is equal to j, i.e., if X[i1, j] is true.
2) Sum of weights including ai is equal to j, i.e., if X[i1, jai] is true so that we get (j – ai) + ai as j.
Question 45 
Dijkstra’s single source shortest path algorithm when run from vertex a in the below graph, computes the correct shortest path distance to
only vertex a  
only vertices a, e, f, g, h  
only vertices a, b, c, d  
all the vertices 
Discuss it
Question 45 Explanation:
Dijkstra’s single source shortest path is not guaranteed to work for graphs with negative weight edges, but it works for the given graph.
Let us see...
Let us run the 1st pass b 1 b is minimum, so shortest distance to b is 1. After 1st pass, distances are c 3, e 2. e is minimum, so shortest distance to e is 2 After 2nd pass, distances are c 3, f 0. f is minimum, so shortest distance to f is 0 After 3rd pass, distances are c 3, g 3. Both are same, let us take g. so shortest distance to g is 3. After 4th pass, distances are c 3, h 5 c is minimum, so shortest distance to c is 3 After 5th pass, distances are h 2 h is minimum, so shortest distance to h is 2
Question 46 
You are given the postorder traversal, P, of a binary search tree on the n elements 1, 2, ..., n. You have to determine the unique binary search tree that has P as its postorder traversal. What is the time complexity of the most efficient algorithm for doing this?
O(Logn)  
O(n)  
O(nLogn)  
none of the above, as the tree cannot be uniquely determined. 
Discuss it
Question 46 Explanation:
One important thing to note is, it is Binary Search Tree, not Binary Tree. In BST, inorder traversal can always be obtained by sorting all keys.
See method 2 of http://www.geeksforgeeks.org/constructbstfromgivenpreordertraversa/ for details.
Same technique can be used for postorder traversal.
Question 47 
We have a binary heap on n elements and wish to insert n more elements (not necessarily one after another) into this heap. The total time required for this is
(A) (logn) (B) (n) (C) (nlogn) (D) (n^2)
A  
B  
C  
D 
Discuss it
Question 47 Explanation:
See http://www.geeksforgeeks.org/datastructuresandalgorithmsset14/ for explanation
Question 48 
Which of the following statements is false?
Every NFA can be converted to an equivalent DFA  
Every nondeterministic Turing machine can be converted to an equivalent deterministic Turing machine  
Every regular language is also a contextfree language  
Every subset of a recursively enumerable set is recursive 
Discuss it
Question 48 Explanation:
A language is recursively enumerable if there exists a Turing machine that accepts every string of the language, and does not accept strings that are not in the language. Strings that are not in the language may be rejected or may cause the Turing machine to go into an infinite loop.
A recursive language can't go into an infinite loop, it has to clearly reject the string, but a recursively enumerable language can go into an infinite loop.
So, every recursive language is also recursively enumerable. Thus, the statement ‘Every subset of a recursively enumerable set is recursive’ is false.
Thus, option (D) is the answer.
Please comment below if you find anything wrong in the above post.
Question 49 
Given below are two finite state automata (→ indicates the start state and F indicates a final state)Which of the following represents the product automaton Z×Y?
A  
B  
C  
D 
Discuss it
Question 50 
Which of the following statements are true?
I. Every leftrecursive grammar can be converted to a rightrecursive grammar and viceversa II. All productions can be removed from any contextfree grammar by suitable transformations III. The language generated by a contextfree grammar all of whose productions are of the form X > w or X > wY (where, w is a string of terminals and Y is a nonterminal), is always regular IV. The derivation trees of strings generated by a contextfree grammar in Chomsky Normal Form are always binary trees
I, II, III and IV  
II, III and IV only  
I, III and IV only  
I, II and IV only 
Discuss it
Question 50 Explanation:
I is true as we can always remove left recursion from any given grammar.
(For better understanding, see this.)
II is false as we can remove all epsilon productions only if grammar doesn't contain epsilon in the language.
III is true as it is the definition of regular grammar.
(For better understanding, see type3 languages in this article.)
IV is true because in chomsky normal form, all the productions are of type X > YZ or X > t, where X, Y, Z are variables and 't' is terminal string. When we draw the derivation tree for every node there are at most 2 children. That's why Derivation trees of grammars in chomsky normal form are Binary trees.
(For better understanding, see this.)
Thus, C is the correct choice.
Question 51 
E  P, F  R, G  Q, H  S  
E  R, F  P, G  S, H  Q  
E  R, F  P, G  Q, H  S  
E  P, F  R, G  S, H  Q 
Discuss it
Question 51 Explanation:
H  S because it is the only option that gives even length palindrome.
So, B and D are incorrect.
Now, we are left with A and C.
Both have G  Q. So, G has to be paired with Q.
Now, we are left with E and F that are to be paired with P and R.
Consider E  R.
R says that either w will be null, that is, it will give only 'c' or it will give 'wcw', where w is any string of a's and b's.
So, if w is used, i.e., it is not null, then it will surely be declared before use and if it is not used, i.e., it is null, then also it satisfies E.
So, E  R is the correct match and thus, C is the correct choice.
Question 52 
Match the following NFAs with the regular expressions they correspond to
1. ϵ + 0(01*1 + 00) * 01* 2. ϵ + 0(10 *1 + 00) * 0 3. ϵ + 0(10 *1 + 10) *1 4. ϵ + 0(10 *1 + 10) *10 *
P  2, Q  1, R  3, S  4  
P  1, Q  3, R  2, S  4  
P  1, Q  2, R  3, S  4  
P  3, Q  2, R  1, S  4 
Discuss it
Question 52 Explanation:
Trick: Here we see in all the given figures then second state has a loop over the input alphabets. In such cases we should resolve the loop at that state and transform the NFA into a simpler one to get a regular expression for the NFA.
For resolving the loop, first reach the state where loop is to be resolved then draw all loops over that state and all possible movements to move to the final state.
Figure P: (when loop resolved at middle state)Loop at middle state is either by a 00 or a 01*1. Hence the regular expression: € + 0(00 +01*1)* 01*
Figure Q: (when loop resolved at middle state)Loop at middle state is either by a 00 or a 10*1. Hence the regular expression: € + 0(00 +10*1)* 0.
Figure R: (when loop resolved at middle state)Loop at middle state is either by a 10 or a 10*1. Hence the regular expression: € + 0(10 +10*1)* 1.
Figure S: (when loop resolved at middle state)Loop at middle state is either by a 10 or a 10*1. Hence the regular expression: € + 0(10 +10*1)* 10*. The regular expressions matching with the above gives suitable matching as P1, Q2, R3, S4 This explanation has been contributed by Yashika Arora.
Question 53 
I and IV only  
I and III only  
I only  
IV only 
Discuss it
Question 53 Explanation:
1.L = {a n b 2m m, n ≥ 0} is a regular language of the form a ∗ (bb) ∗ .
2. L = {a n b m n = 2m} is not a regular language. This is a similar language as of {a n b n } which is known to be not a regular language.
3. L = {a n b m n notEqualTo m} is not regular because there is no way to for finite automaton to remember n, number of as.
4. L = {xcyx, y ∈ {a, b} ∗ } is a regular language which is concatenation of {xx ∈ a, b ∗ } on itself with a alphabet c in between. Note: Regular languages are closed under concatenation.
Hence, correct answer would be (A) I and IV only.
This solution is contributed by vineet purswani.
Question 54 
Which of the following are true?
I. A programming language which does not permit global variables of any kind and has no nesting of procedures/functions, but permits recursion can be implemented with static storage allocation II. Multilevel access link (or display) arrangement is needed to arrange activation records only if the programming language being implemented has nesting of procedures/functions III. Recursion in programming languages cannot be implemented with dynamic storage allocation IV. Nesting of procedures/functions and recursion require a dynamic heap allocation scheme and cannot be implemented with a stackbased allocation scheme for activation records V. Programming languages which permit a function to return a function as its result cannot be implemented with a stackbased storage allocation scheme for activation records
II and V only  
I, III and IV only  
I, II and V only  
II, III and V only 
Discuss it
Question 54 Explanation:
I. Recursion cannot be implemented with Static Storage Allocation. Static allocation means, compiler has to decide size for function calls. In case of recursion, it is not possible for compiler to decide as depth of recursion depends on recursion parameter which may be an input from user also.
II. Is CORRECT. Programming languages that support nested subroutines also have a field in the call frame that points to the stack frame of the latest activation of the procedure that most closely encapsulates the callee, i.e. the immediate scope of the callee. This is called an access link or static link (as it keeps track of static nesting during dynamic and recursive calls) and provides the routine (as well as any other routines it may invoke) access to the local data of its encapsulating routines at every nesting level. Some architectures, compilers, or optimization cases store one link for each enclosing level (not just the immediately enclosing), so that deeply nested routines that access shallow data do not have to traverse several links; this strategy is often called a "display" [Source: https://en.wikipedia.org/wiki/Call_stack ]
III. Recursion CAN be implemented with any kind of Dynamic Storage Allocation scheme.
IV. Nesting features are always implemented in a language using STACK and NOT Heap. (See above point II for details)
V. Is CORRECT. In stack based allocation scheme, once a function has returned, it is removed from function call stack. Therefore returning a function from a function doesn't look possible.
Question 55 
An LALR(1) parser for a grammar G can have shiftreduce (SR) conflicts if and only if
the SLR(1) parser for G has SR conflicts  
the LR(1) parser for G has SR conflicts  
the LR(0) parser for G has SR conflicts  
the LALR(1) parser for G has reducereduce conflicts 
Discuss it
Question 55 Explanation:
Both LALR(1) and LR(1) parser uses LR(1) set of items to form their parsing tables. And LALR(1) states can be find by merging LR(1) states of LR(1) parser that have the same set of first components of their items.
i.e. if LR(1) parser has 2 states I and J with items A>a.bP,x and A>a.bP,y respectively, where x and y are look ahead symbols, then as these items are same with respect to their first component, they can be merged together and form one single state, let's say K. Here we have to take union of look ahead symbols. After merging, State K will have one single item as A>a.bP,x,y . This way LALR(1) states are formed ( i.e. after merging the states of LR(1) ).
Now, SR conflict in LR(1) items can be there whenever a state has items of the form :
A> a.bB , p C> d. , b i.e. it is getting both shift and reduce at symbol b, hence a conflict.Now, as LALR(1) have items similar to LR(1) in terms of their first component, shiftreduce form will only take place if it is already there in LR(1) states. If there is no SR conflict in LR(1) state it will never be reflected in the LALR(1) state obtained by combining LR(1) states. Note: But this process of merging may introduce RR conflict, and then the Grammar won't be LALR(1).
Question 56 
In the slow start phase of the TCP congestion control algorithm, the size of the congestion window
does not increase  
increases linearly  
increases quadratically  
increases exponentially 
Discuss it
Question 56 Explanation:
See Question 2 of http://www.geeksforgeeks.org/computernetworksset7/
Question 57 
If a class B network on the Internet has a subnet mask of 255.255.248.0, what is the maximum number of hosts per subnet?
1022  
1023  
2046  
2047 
Discuss it
Question 57 Explanation:
See Question 3 of http://www.geeksforgeeks.org/computernetworksset7/
Question 58 
A computer on a 10Mbps network is regulated by a token bucket. The token bucket is filled at a rate of 2Mbps. It is initially filled to capacity with 16Megabits. What is the maximum duration for which the computer can transmit at the full 10Mbps?
1.6 seconds  
2 seconds  
5 seconds  
8 seconds 
Discuss it
Question 58 Explanation:
See Question 3 of http://www.geeksforgeeks.org/computernetworksset8/
Question 59 
A client process P needs to make a TCP connection to a server process S. Consider the following situation: the server process S executes a socket(), a bind() and a listen() system call in that order, following which it is preempted. Subsequently, the client process P executes a socket() system call followed by connect() system call to connect to the server process S. The server process has not executed any accept() system call. Which one of the following events could take place?
connect () system call returns successfully  
connect () system call blocks  
connect () system call returns an error  
connect () system call results in a core dump 
Discuss it
Question 59 Explanation:
See Question 2 of http://www.geeksforgeeks.org/computernetworksset8/
Question 60 
What is printed by the following C program?
$include <stdio.h> int f(int x, int *py, int **ppz) { int y, z; **ppz += 1; z = **ppz; *py += 2; y = *py; x += 3; return x + y + z; } void main() { int c, *b, **a; c = 4; b = &c; a = &b; printf( "%d", f(c,b,a)); getchar(); }
18  
19  
21  
22 
Discuss it
Question 60 Explanation:
See Question 1 of http://www.geeksforgeeks.org/clanguageset5/
Question 61 
Choose the correct option to fill ?1 and ?2 so that the program below prints an input string in reverse order. Assume that the input string is terminated by a newline character.
void reverse(void) { int c; if (?1) reverse(); ?2 } int main() { printf ("Enter Text ") ; printf ("\n") ; reverse(); printf ("\n") ; }
?1 is (getchar() != ’\n’) ?2 is getchar(c);  
?1 is (c = getchar() ) != ’\n’) ?2 is getchar(c);  
?1 is (c != ’\n’) ?2 is putchar(c);  
?1 is ((c = getchar()) != ’\n’) ?2 is putchar(c); 
Discuss it
Question 61 Explanation:
See Question 2 of http://www.geeksforgeeks.org/clanguageset5/
Question 62 
The following C function takes a singlelinked list of integers as a parameter and rearranges the elements of the list. The function is called with the list containing the integers 1, 2, 3, 4, 5, 6, 7 in the given order. What will be the contents of the list after the function completes execution?
struct node { int value; struct node *next; }; void rearrange(struct node *list) { struct node *p, * q; int temp; if ((!list)  !list>next) return; p = list; q = list>next; while(q) { temp = p>value; p>value = q>value; q>value = temp; p = q>next; q = p?p>next:0; } }
1,2,3,4,5,6,7  
2,1,4,3,6,5,7  
1,3,2,5,4,7,6  
2,3,4,5,6,7,1

Discuss it
Question 62 Explanation:
Given linked list is 1>2>3>4>5>6>7
If you carefully observe the given function,
It just swaps the adjacent values for every pair till it reaches the end.
The modified linked list is 2>1>4>3>6>5>7
See Question 4 of http://www.geeksforgeeks.org/datastructuresandalgorithmsset15/
This solution is contributed by Anil Saikrishna Devarasetty
Question 63 
The P and V operations on counting semaphores, where s is a counting semaphore, are defined as follows:
P(s) : s = s  1; if (s < 0) then wait; V(s) : s = s + 1; if (s <= 0) then wakeup a process waiting on s;Assume that Pb and Vb the wait and signal operations on binary semaphores are provided. Two binary semaphores Xb and Yb are used to implement the semaphore operations P(s) and V(s) as follows:
P(s) : Pb(Xb); s = s  1; if (s < 0) { Vb(Xb) ; Pb(Yb) ; } else Vb(Xb); V(s) : Pb(Xb) ; s = s + 1; if (s <= 0) Vb(Yb) ; Vb(Xb) ;The initial values of Xb and Yb are respectively
0 and 0  
0 and 1
 
1 and 0
 
1 and 1 
Discuss it
Question 63 Explanation:
Suppose Xb = 0, then because of P(s): Pb(Xb) operation, Xb will be 1 and processs will get blocked as it will enter into waiting section.
So, Xb will be one.
Suppose s=2(means 2 process are accessing shared resource), taking Xb as 1,
first P(s): Pb(Xb) operation will make Xb as zero. s will be 1 and Then Vb(Xb) operation will be executed which will increase the count of Xb as one. Then same process will be repeated making Xb as one and s as zero.
Now suppose one more process comes, then Xb will be 1 but s will be 1 which will make this process go into loop (s <0) and will result into calling Vb(Xb) and Pb(Yb) operations. Vb(Xb) will result into Xb as 2 and Pb(Yb) will result into decrementing the value of Yb.
case 1: if Yb has value as 0, it will be 1 and it will go into waiting and will be blocked.total 2 process will access shared resource (according to counting semaphore, max 3 process can access shared resource) and value of s is 1 means only 1 process will be waiting for resources and just now, one process got blocked. So it is still true.
case 2: if Yb has value as 1, it will be 0. Total 3 process will access shared resource (according to counting semaphore, max 3 process can access shared resource) and value of s is 1 means only 1 process will be waiting for resources and but there is no process waiting for resources.So it is false.
See Question 2 of http://www.geeksforgeeks.org/operatingsystemsset10/ This solution is contributed by Nitika Bansal
first P(s): Pb(Xb) operation will make Xb as zero. s will be 1 and Then Vb(Xb) operation will be executed which will increase the count of Xb as one. Then same process will be repeated making Xb as one and s as zero.
Now suppose one more process comes, then Xb will be 1 but s will be 1 which will make this process go into loop (s <0) and will result into calling Vb(Xb) and Pb(Yb) operations. Vb(Xb) will result into Xb as 2 and Pb(Yb) will result into decrementing the value of Yb.
case 1: if Yb has value as 0, it will be 1 and it will go into waiting and will be blocked.total 2 process will access shared resource (according to counting semaphore, max 3 process can access shared resource) and value of s is 1 means only 1 process will be waiting for resources and just now, one process got blocked. So it is still true.
case 2: if Yb has value as 1, it will be 0. Total 3 process will access shared resource (according to counting semaphore, max 3 process can access shared resource) and value of s is 1 means only 1 process will be waiting for resources and but there is no process waiting for resources.So it is false.
See Question 2 of http://www.geeksforgeeks.org/operatingsystemsset10/ This solution is contributed by Nitika Bansal
Question 64 
Which of the following statements about synchronous and asynchronous I/O is NOT true?
An ISR is invoked on completion of I/O in synchronous I/O but not in asynchronous I/O  
In both synchronous and asynchronous I/O, an ISR (Interrupt Service Routine) is invoked after completion of the I/O  
A process making a synchronous I/O call waits until I/O is complete, but a process making an asynchronous I/O call does not wait for completion of the I/O  
In the case of synchronous I/O, the process waiting for the completion of I/O is woken up by the ISR that is invoked after the completion of I/O 
Discuss it
Question 64 Explanation:
There are two types of input/output (I/O) synchronization: synchronous I/O and asynchronous I/O.
Asynchronous I/O is also referred to as overlapped I/O.
In synchronous file I/O, a thread starts an I/O operation and immediately enters a wait state until the I/O request has completed. An ISR will be invoked after the completion of I/O operation and it will place process from block state to ready state.
A thread performing asynchronous file I/O sends an I/O request to the kernel by calling an appropriate function. If the request is accepted by the kernel, the calling thread continues processing another job until the kernel signals to the thread that the I/O operation is complete. It then interrupts its current job and processes the data from the I/O operation as necessary.
See Question 3 of http://www.geeksforgeeks.org/operatingsystemsset10/
Reference:
https://msdn.microsoft.com/enus/library/windows/desktop/aa365683%28v=vs.85%29.aspx
This solution is contributed by Nitika Bansal
Question 65 
Which of the following is NOT true of deadlock prevention and deadlock avoidance schemes?
In deadlock prevention, the request for resources is always granted if the resulting state is safe  
In deadlock avoidance, the request for resources is always granted if the result state is safe  
Deadlock avoidance is less restrictive than deadlock prevention  
Deadlock avoidance requires knowledge of resource requirements a priori 
Discuss it
Question 65 Explanation:
Deadlock Prevention: Deadlocks can be prevented by preventing at least one of the four required
conditions:
1. Mutual Exclusion – not required for sharable resources; must hold for nonsharable resources.
2. Hold and Wait – must guarantee that whenever a process requests a resource, it does not hold any other resources. Require process to request and be allocated all its sources before it begins execution, or allow process to request resources only when the process has none. Low resource utilization; starvation possible. Restrain the ways request can be made.
3. No Preemption – If a process that is holding some resources requests another resource that cannot be immediately allocated to it, and then all resources currently being held are released. Preempted resources are added to the list of resources for which the process is waiting. Process will be restarted only when it can regain its old resources, as well as the new ones that it is requesting.
4. Circular Wait – impose a total ordering of all resource types, and require that each process requests resources in an increasing order of enumeration.
Deadlock Avoidance:
When a scheduler sees that starting a process or granting resource requests may lead to future deadlocks, then that process is just not started or the request is not granted. The deadlockavoidance algorithm dynamically examines the resourceallocation state to ensure that there can never be a circularwait condition. Resourceallocation state is defined by the number of available and allocated resources, and the maximum demands of the processes.
Choice of the question:
(A) In deadlock prevention, the request for resources is always granted if the resulting state is safe. false, Deadlock prevention scheme handles deadlock by making sure that one of the four necessary conditions don't occur. In deadlock prevention, the request for a resource may not be granted even if the resulting state is safe.
(B) In deadlock avoidance, the request for resources is always granted if the result state is safe. true, As in Deadlock avoidance, if resultant state is safe than request for resource is granted as being in a safe state, it can hold other resources now.
(C) Deadlock avoidance is less restrictive than deadlock prevention. true, As in Deadlock prevention, request for a resource may not be granted even if the resulting state is safe. but in deadlock avoidance, request for a resource is granted if the resulting state is safe.
(D) Deadlock avoidance requires knowledge of resource requirements a priori true, deadlock avoidance checks any chance of deadlock means even if the system is in safe state, it checks that after allocating requested resource, the system is not in deadlocked state. So deadlock avoidance requires knowledge of resource requirements a priori.
See Question 2 of http://www.geeksforgeeks.org/operatingsystemsset11/
This solution is contributed by Nitika Bansal
Question 66 
A process executes the following code
for (i = 0; i < n; i++) fork();The total number of child processes created is
n  
2^n  1  
2^n  
2^(n+1)  1; 
Discuss it
Question 66 Explanation:
F0 // There will be 1 child process created by first fork / \ F1 F1 // There will be 2 child processes created by second fork / \ / \ F2 F2 F2 F2 // There will be 4 child processes created by third fork / \ / \ / \ / \ ............... // and so on
If we sum all levels of above tree for i = 0 to n1, we get 2^n  1. So there will be 2^n – 1 child processes. Also see this post for more details.
Question 67 
A processor uses 36 bit physical addresses and 32 bit virtual addresses, with a page frame size of 4 Kbytes. Each page table entry is of size 4 bytes. A three level page table is used for virtual to physical address translation, where the virtual address is used as follows
• Bits 3031 are used to index into the first level page table
• Bits 2129 are used to index into the second level page table
• Bits 1220 are used to index into the third level page table, and
• Bits 011 are used as offset within the page
The number of bits required for addressing the next level page table (or page frame) in the page table entry of the first, second and third level page tables are respectively.
20, 20 and 20  
24, 24 and 24  
24, 24 and 20  
25, 25 and 24 
Discuss it
Question 67 Explanation:
Virtual address size = 32 bits
Physical address size = 36 bits
Physical memory size = 2^36 bytes
Page frame size = 4K bytes = 2^12 bytes
No. of bits for offset (or number of bits required for accessing location within a page frame) = 12.
No. of bits required to access physical memory frame = 36  12 = 24
So in third level of page table, 24 bits are required to access an entry.
9 bits of virtual address are used to access second level page table entry and size of pages in second level is 4 bytes. So size of second level page table is (2^9)*4 = 2^11 bytes. It means there are (2^36)/(2^11) possible locations to store this page table. Therefore the second page table requires 25 bits to address it.
Similarly, the third page table needs 25 bits to address it.
Question 68 
1) Let R and S be two relations with the following schema
R (P,Q,R1,R2,R3)
S (P,Q,S1,S2)
Where {P, Q} is the key for both schemas. Which of the following queries are equivalent?
Only I and II  
Only I and III  
Only I, II and III  
Only I, III and IV 
Discuss it
Question 68 Explanation:
See Question 1 of http://www.geeksforgeeks.org/databasemanagementsystemsset7/
Question 69 
Consider the following relational schemes for a library database:
Book (Title, Author, Catalog_no, Publisher, Year, Price)
Collection (Title, Author, Catalog_no)
with in the following functional dependencies:
I. Title Author > Catalog_no II. Catalog_no > Title, Author, Publisher, Year III. Publisher Title Year > PriceAssume {Author, Title} is the key for both schemes. Which of the following statements is true?
Both Book and Collection are in BCNF  
Both Book and Collection are in 3NF only  
Book is in 2NF and Collection is in 3NF  
Both Book and Collection are in 2NF only 
Discuss it
Question 69 Explanation:
Book (Title, Author, Catalog_no, Publisher, Year, Price) Collection (Title, Author, Catalog_no)with in the following functional dependencies:
I. Title, Author > Catalog_no II. Catalog_no > Title, Author, Publisher, Year III. Publisher, Title, Year > Price Assume {Author, Title} is the key for both schemes
 The table "Collection" is in BCNF as there is only one functional dependency “Title Author –> Catalog_no” and {Author, Title} is key for collection.
 Book is not in BCNF because Catalog_no is not a key and there is a functional dependency “Catalog_no –> Title Author Publisher Year”.
 Book is not in 3NF because nonprime attributes (Publisher Year) are transitively dependent on key [Title, Author].
 Book is in 2NF because every nonprime attribute of the table is either dependent on the whole of a candidate key [Title, Author], or on another non prime attribute. In table book, candidate keys are {Title, Author} and {Catalog_no}. In table Book, nonprime attributes (attributes that do not occur in any candidate key) are Publisher, Year and Prince
Question 70 
Consider a file of 16384 records. Each record is 32 bytes long and its key field is of size 6 bytes. The file is ordered on a nonkey field, and the file organization is unspanned. The file is stored in a file system with block size 1024 bytes, and the size of a block pointer is 10 bytes. If the secondary index is built on the key field of the file, and a multilevel index scheme is used to store the secondary index, the number of firstlevel and secondlevel blocks in the multilevel index are respectively.
8 and 0  
128 and 6  
256 and 4  
512 and 5 
Discuss it
Question 70 Explanation:
Indexing mechanisms are used to optimize certain accesses to data (records) managed in files. For example, the author catalog in a library is a type of index. An Index File consists of records (called index entries) of the form
  SearchKey  Pointer to Block  If even outer index is too large to fit in main memory, yet another level of index can be created, and so on. Source: http://web.cs.ucdavis.edu/~green/courses/ecs165aw11/7indexes.pdf
Number of records in file = 16384 Record size = 32 bytes Key Size = 6 bytes Block Size on file system = 1024 bytes Size of Block Pointer = 10 bytes Size of a record or index Entry = 10 + 6 = 16 Number of blocks in first level = (Number of records in file)/ (Disk Block Size) = (16384 * 16)/(1024) = 16 * 16 = 256 In second level, there will be 256 * 16 entries. Number of blocks in second level = (Number of entries) / (Block Size) = (256 * 16) / 1024 = 4
Question 71 
Consider a machine with a 2way set associative data cache of size 64 Kbytes and block size 16 bytes. The cache is managed using 32 bit virtual addresses and the page size is 4 Kbytes. A program to be run on this machine begins as follows:
double ARR[1024][1024]; int i, j; // Initialize array ARR to 0.0 for(i = 0; i < 1024; i++) for(j = 0; j < 1024; j++) ARR[i][j] = 0.0;The size of double is 8 Bytes. Array ARR is located in memory starting at the beginning of virtual page 0xFF000 and stored in row major order. The cache is initially empty and no prefetching is done. The only data memory references made by the program are those to array ARR. The total size of the tags in the cache directory is
32 Kbits  
34 Kbits  
64 Kbits  
68 Kbits 
Discuss it
Question 71 Explanation:
Virtual Address = 32 bits
Cache address is of the form: TAG  SET  BLOCK
For BLOCK of 16 bytes, we need 4 bits.
Total number of sets(each set containing 2 Blocks) = 64 KB / (2 * 16) B = 2^{11}
So, Number of SET bits = 11
Number of TAG bits = 32  (11 + 4) = 17
Thus, cache address = 17  11  4 (TAG  SET  BLOCK)
Tag memory size = Number of tag bits * Total number of blocks
= 17 * 2 * 2^{11} (Total Number of blocks = 2 * Total number of sets)
= 68 KB
Thus, D is the correct choice.
Question 72 
Consider the data given in above question. Which of the following array elements has the same cache index as ARR[0][0]?
ARR[0][4]  
ARR[4][0]  
ARR[0][5]  
ARR[5][0] 
Discuss it
Question 72 Explanation:
Total number of elements in array = 2^{10} * 2^{10} = 2^{20}
Each block in cache can contain 2 elements as double is 8 bytes and size of each block = 16 bytes.
Total number of elements that can be present in cache = Total number of blocks * 2 = 2 * 2^{11} * 2 = 2^{13}
For having same cache index the 11 set bits for the element should be same as Arr[0][0], in other words, the element should map to same address as Arr[0][0],
Mapping of the should be as follows:
Set No ............................... Block1................................ Block2 00000000000.....................Arr[0][0] Arr[0][1]..................Arr[4][0] Arr[4][1] 00000000001.....................Arr[0][2] Arr[0][3] . . . 01111111111....................Arr[2][1022] Arr[2][1023] 10000000000....................Arr[3][0] Arr[3][1] . . . 11111111111.....................Arr[3][1022] Arr[3][1023]So, index of Arr[0][0] is same as Arr[4][0]. Thus, B is the correct choice.
Question 73 
The cache hit ratio for this initialization loop is
0%  
25%  
50%  
75% 
Discuss it
Question 73 Explanation:
Explanation:
Cache hit ratio=No. of hits/total accesses
=1024/(1024+1024)
=1/2=0.5=50%
So (C) is correct option
Question 74 
Consider the following C program
int f1(int n) { if(n == 0  n == 1) return n; else return (2*f1(n1) + 3*f1(n2)); } int f2(int n) { int i; int X[N], Y[N], Z[N] ; X[0] = Y[0] = Z[0] = 0; X[1] = 1; Y[1] = 2; Z[1] = 3; for(i = 2; i <= n; i++) { X[i] = Y[i1] + Z[i2]; Y[i] = 2*X[i]; Z[i] = 3*X[i]; } return X[n] ; }The running time of f1(n) and f2(n) are (A) (n) and (n) (B) (2^n) and (n) (C) (n) and (2^n) (D) (2^n) and (2^n)
A  
B  
C  
D 
Discuss it
Question 74 Explanation:
See Question 3 of http://www.geeksforgeeks.org/clanguageset5/
Question 75 
Consider the program given in above question, f1(8) and f2(8) return the values
1661 and 1640  
59 and 59  
1640 and 1640  
1640 and 1661 
Discuss it
Question 75 Explanation:
See question 4 of http://www.geeksforgeeks.org/clanguageset5/
Question 76 
Delayed branching can help in the handling of control hazards.
For all delayed conditional branch instructions, irrespective of whether the condition evaluates to true or false,
the instruction following the conditional branch instruction in memory is executed  
the first instruction in the fall through path is executed  
the first instruction in the taken path is executed  
the branch takes longer to execute than any other instruction 
Discuss it
Question 76 Explanation:
In order to avoid the pipeline delay due to conditional branch instruction, a suitable instruction is placed below the conditional branch instruction such that the instruction will be executed irrespective of whether branch is taken or not and won't affect the program behavior.
Another explanation :
An instruction following a branch instruction in a pipeline is always executed because usually branch target address is available at the ID which in turn introduces stall in the pipeline. This stall slot is called branch delay slot. As we don't know beforehand whether the branch will take place or not, we need to fill the delay slot with an appropriate instruction, for example, an instruction having no dependency or a NOP instruction.
Question 77 
Delayed branching can help in the handling of control hazards
The following code is to run on a pipelined
processor with one branch delay slot:
I1: ADD R2←R7+R8 I2 : SUB R4← R5R6 I3 : ADD R1← R2+R3 I4 : STORE Memory [R4]←[R1] BRANCH to Label if R1== 0Which of the instructions I1, I2, I3 or I4 can legitimately occupy the delay slot without any other program modification?
I1  
I2  
I3  
I4 
Discuss it
Question 77 Explanation:
It can't be l1 or l3, because directly or indirectly they are taking part in the branching decision.
Now we can have both l2 and l4 after the branching decision statement and the order of I2 and I4 matters because in I2 we are getting the final value in register R4 and in instruction we are saving contents of R1 in memory whose address is stored in the register.
So If we made I2 to be the instruction after branch then the value in the first loop itself the value stored in memory location whose address is stored in R4 would be wrong because it actually should have been updated first by R5R6.So I4 is correct.
So (D) is correct option.
Question 78 
Let xn denote the number of binary strings of length n that contain noconsecutive 0s. Which of the following recurrences does Xn satisfy?
A  
B  
C  
D 
Discuss it
Question 78 Explanation:
For n = 1 i.e. binary strings of length 1, strings are '0', '1'.
So, X1 = 2
For n = 2 i.e. binary strings of length 2, strings are '01' , '10' , '11'. (here string '00' will be rejected because it has consecutive zeros).
So, X2 = 3
For n = 3 i.e. binary strings of length 3, strings are '010' , '011' , '101' , '110' , '111' . 0 01 (rejected) 0 10 0 11 1 01 1 10 1 11
So, X3 = 5
This shows that X3 = X2 + X1
Therefore, X(n) = X(n  1) + X(n  2)
Please comment below if you find anything wrong in the above post.
For n = 2 i.e. binary strings of length 2, strings are '01' , '10' , '11'. (here string '00' will be rejected because it has consecutive zeros).
So, X2 = 3
For n = 3 i.e. binary strings of length 3, strings are '010' , '011' , '101' , '110' , '111' . 0 01 (rejected) 0 10 0 11 1 01 1 10 1 11
So, X3 = 5
This shows that X3 = X2 + X1
Therefore, X(n) = X(n  1) + X(n  2)
Please comment below if you find anything wrong in the above post.
Question 79 
The value of X5 is
5  
7  
8  
16 
Discuss it
Question 79 Explanation:
Since, X(n) = X(n  1) + X(n  2)
X5 = X4 + X3
X4 = X3 + X2 = 5 + 3 = 8
Therefore, X5 = 8 + 5 = 13
Thus, only option (C) is close to the answer.
Please comment below if you find anything wrong in the above post.
X5 = X4 + X3
X4 = X3 + X2 = 5 + 3 = 8
Therefore, X5 = 8 + 5 = 13
Thus, only option (C) is close to the answer.
Please comment below if you find anything wrong in the above post.
Question 80 
The subsetsum problem is defined as follows. Given a set of n positive integers, S = {a1 ,a2 ,a3 ,...,an} and positive integer W, is there a subset of S whose elements sum to W? A dynamic program for solving this problem uses a 2dimensional Boolean array X, with n rows and W+1 columns. X[i, j],1 <= i <= n, 0 <= j <= W, is TRUE if and only if there is a subset of {a1 ,a2 ,...,ai} whose elements sum to j. Which of the following is valid for 2 <= i <= n and ai <= j <= W?
X[i, j] = X[i  1, j] V X[i, j ai]  
X[i, j] = X[i  1, j] V X[i  1, j  ai]  
X[i, j] = X[i  1, j] V X[i, j  ai]  
X[i, j] = X[i  1, j] V X[i 1, j  ai] 
Discuss it
Question 80 Explanation:
See Question 1 of http://www.geeksforgeeks.org/datastructuresandalgorithmsset21/
Question 81 
The subsetsum problem is defined as follows. Given a set of n positive integers, S = {a1 ,a2 ,a3 ,...,an} and positive integer W, is there a subset of S whose elements sum to W? A dynamic program for solving this problem uses a 2dimensional Boolean array X, with n rows and W+1 columns. X[i, j],1 <= i <= n, 0 <= j <= W, is TRUE if and only if there is a subset of {a1 ,a2 ,...,ai} whose elements sum to j. Which of the following is valid for 2 <= i <= n and ai <= j <= W?
Which entry of the array X, if TRUE, implies that there is a subset whose elements sum to W?
X[1, W]  
X[n, 0]  
X[n, W]  
X[n1, n] 
Discuss it
Question 81 Explanation:
See Question 2 of http://www.geeksforgeeks.org/datastructuresandalgorithmsset21/
Question 82 
Consider the following ER diagram.
The minimum number of tables needed to represent M, N, P, R1, R2 is
2  
3  
4  
5 
Discuss it
Question 82 Explanation:
Answer is B, i.e, 3 minimum tables.
M, P are strong entities hence they must be represented by separate tables.
Manytoone and onetomany relationship sets that are total on the manyside can be represented by adding an extra attribute to the “many” side, containing the primary key of the “one” side. ( This way no extra table will be needed for Relationship sets )
M table is modified to include primary key of P side(i.e. P1). N is weak entity, and is modified to include primary key of P (i.e, P1).
Therefore there would be minimum of 3 tables with schema given below :
M ( M1, M2, M3, P1) P ( P1, P2 ) N ( P1, N1, N2 )Note: This modification of a table in the case of onemany or manyone to include relationship set at the many side works well, but only in the case when the relationship set doesn't have its own attributes. If the relationship set has its own attribute then we need to make a separate table for the relationship set also.
Question 83 
Consider the data given in above question. Which of the following is a correct attribute set for one of the tables for the correct answer to the above question?
{M1, M2, M3, P1}  
{M1, P1, N1, N2}  
{M1, P1, N1}  
{M1, P1} 
Discuss it
Question 83 Explanation:
As given in the explanation http://quiz.geeksforgeeks.org/gategatecs2008question82/
We get 3 tables.
M: {M1, M2, M3, P1}
P: {P1, P2}
N: {P1, N1, N2}
The only attribute set that matches the given table sets is A. Therefore, option A
Question 84 
Consider the following C program that attempts to locate an element x in an array Y[] using binary search. The program is erroneous.
1. f(int Y[10], int x) { 2. int i, j, k; 3. i = 0; j = 9; 4. do { 5. k = (i + j) /2; 6. if( Y[k] < x) i = k; else j = k; 7. } while(Y[k] != x && i < j); 8. if(Y[k] == x) printf ("x is in the array ") ; 9. else printf (" x is not in the array ") ; 10. }On which of the following contents of Y and x does the program fail?
Y is [1 2 3 4 5 6 7 8 9 10] and x < 10  
Y is [1 3 5 7 9 11 13 15 17 19] and x < 1  
Y is [2 2 2 2 2 2 2 2 2 2] and x > 2  
Y is [2 4 6 8 10 12 14 16 18 20] and 2 < x < 20 and x is even 
Discuss it
Question 84 Explanation:
See question 3 of http://www.geeksforgeeks.org/datastructuresandalgorithmsset21/
Question 85 
Consider the data given in above question, the correction needed in the program to make it work properly is
Change line 6 to: if (Y[k] < x) i = k + 1; else j = k1;  
Change line 6 to: if (Y[k] < x) i = k  1; else j = k+1;  
Change line 6 to: if (Y[k] <= x) i = k; else j = k;  
Change line 7 to: } while ((Y[k] == x) && (i < j)); 
Discuss it
Question 85 Explanation:
See Question 4 of http://www.geeksforgeeks.org/datastructuresandalgorithmsset21/
There are 85 questions to complete.