Question 1



 A 1 B -1 C inf D -inf
Numerical Methods and Calculus    GATE CS 2008
Discuss it

Question 1 Explanation:
 Question 2
If P, Q, R are subsets of the universal set U, then
 A Qc U Rc B P U Qc U Rc C Pc U Qc U Rc D U
Set Theory & Algebra    GATE CS 2008
Discuss it

Question 2 Explanation:
 Question 3
The following system of equations has a unique solution. The only possible value(s) for α is/are
 A 0 B either 0 or 1 C one of 0, 1 or -1 D any real number E any real number other than 5
Numerical Methods and Calculus    GATE CS 2008
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 a-2 | 3

Apply R3 <- R3 - 3R2

1 1 2 | 1
0 1 1 | 1
0 0 a-5 | 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
 A the normalized value 2-127 B the normalized value 2-126 C the normalized value +0 D the special value +0
GATE CS 2008    Number Representation
Discuss it

Question 4 Explanation:

 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 A B B C C D D
Digital Logic & Number representation    GATE CS 2008
Discuss it

Question 5 Explanation:
 Question 6
Let r denote number system radix. The only value(s) of r that satisfy the equation
 A decimal 10 B decimal 11 C decimal 10 and 11 D any value > 2
Digital Logic & Number representation    GATE CS 2008
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 f1, f3 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 A B B C C D D
Digital Logic & Number representation    GATE CS 2008
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
s is  ( C) part.
 Question 8
Which of the following is true for the language
 A It is not accepted by a Turing Machine B It is regular but not context-free C It is context-free but not regular D It is neither regular nor context-free, but accepted by a Turing machine
Recursively enumerable sets and Turing machines    GATE CS 2008
Discuss it

Question 8 Explanation:
Turing machine can be designed for ap 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 non-black symbol from the left. Let this symbol occur at position ‘x’. Suppose ‘x’ is a prime number. If this non-blank 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 context-free, 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 context-free language is regular III. Whether two push-down automata accept the same language IV. Whether a given grammar is context-free  A I and II B I and IV C II and III D II and IV Undecidability GATE CS 2008 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 LR-parsing) appropriately?  A It is the position in a sentential form where the next shift or reduce operation will occur B It is non-terminal whose production will be used for reduction in the next step C 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 D 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 Parsing and Syntax directed translation GATE CS 2008 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 bottom-up 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 Non-terminal 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 Non-terminal S).  For Ex : Grammar is : S-> aAcBe A->Ab|b B->d Input string : abbcde Derivation : ( Top-Down, Right Most Derivation) S->aAcBe ->aAcde ->aAbcde ->abbcde  Here { 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 non-terminals during the derivation process ) Now, let's look at the question. The question is related to LR parsing which is a bottom-up 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 Handle-Pruning. Hence option D suits best.  Question 11 Some code optimizations are carried out on the intermediate code because  A they enhance the portability of the compiler to other target processors B program analysis is more accurate on intermediate code than on machine code C the information from dataflow analysis cannot otherwise be used for optimization D the information from the front end cannot otherwise be used for optimization Code Generation and Optimization GATE CS 2008 Discuss it Question 11 Explanation: Option (B) is also true. But the main purpose of doing some code-optimization 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  A regular B context-free C context-sensitive D recursive Recursively enumerable sets and Turing machines GATE CS 2008 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?  A Any size B 216 bytes - size of TCP header C 216 bytes D 1500 bytes Application Layer GATE CS 2008 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 14 Which of the following tuple relational calculus expression(s) is/are equivalent to  A I only B II only C III only D III and IV only ER and Relational Models GATE CS 2008 Discuss it Question 14 Explanation: Some transformation rules for tuple relational calculus are : Thus, using the above rules option (C) is correct. Please comment below if you find anything wrong in the above post.  Question 15 A clustering index is defined on the fields which are of type  A non-key and ordering B non-key and non-ordering C key and ordering D key and non-ordering File structures (sequential files, indexing, B and B+ trees) GATE CS 2008 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 non-key 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/indexing-in-databases-set-1/ This solution is contributed by Yashika Arora.  Question 16 Which of the following system calls results in the sending of SYN packets?  A socket B bind C listen D connect Transport Layer GATE CS 2008 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 SYN-ACK back to the client. 3) The client responds with an ACK, and the connection is established. Sources: Berkeley socketsTCP 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  A MNOPQR B NQMPOR C QMNPRO D QMNPOR GATE CS 2008 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/Breadth-first_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 )   A x = 3, y = 4, z = 2 B x = 6, y = 5, z = 3 C x = 6, y = 3, z = 5 D x = 5, y = 4, z = 5 Loops & Control Structure GATE CS 2008 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  A &thetha;(n) B &thetha;(m) C &thetha;(m + n) D &thetha;(mn) GATE CS 2008 Discuss it Question 19 Explanation: Number of connected components in undirected graph can simply calculated by doing a BFS or DFS. The best possible time complexity of BFS and DFS is O(m + n).  Question 20 The data blocks of a very large file in the Unix file system are allocated using  A contiguous allocation B linked allocation C indexed allocation D an extension of indexed allocation Input Output Systems GATE CS 2008 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  A 1000 l B 1000 C 100 l D 100 Numerical Methods and Calculus GATE CS 2008 Discuss it Question 21 Explanation: Trapezoidal rule error : Maximum error = 1/3 * 10-6 (given) Therefore, |En| < 1/3 * 10-6 a = 1 and b = 2 (given) Therefore, f''(x) = xex + 2ex f''(x) is maximum at x = 2. Therefore, f''(x) = 4e2 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 The Newton-Raphson iteration can be used to compute the.  A square of R B reciprocal of R C square root of R D logarithm of R Numerical Methods and Calculus GATE CS 2008 Discuss it Question 22 Explanation: According to Newton-Raphson method, xn+1 = xn − f(xn) / f′(xn)  So we try to bring given equation in above form. Given equation is : xn+1 = xn/2 + R/(2xn) = xn − xn/2 + R/(2xn) = xn − (xn2 − R2)/(2xn)  So clearly f(x) = x2 − R, so root of f(x) means x2 − 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.html  Question 23 Which of the following statements is true for every planar graph on n vertices?  A The graph is connected B The graph is Eulerian C The graph has a vertex-cover of size at most 3n/4 D The graph has an independent set of size at least n/3 Graph Theory GATE CS 2008 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  A P = Q - k B P = Q + k C P = Q D P = Q +2 k Numerical Methods and Calculus GATE CS 2008 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 3x4 - 16x3 + 24x2 + 37  A 0 B 1 C 2 D 3 Numerical Methods and Calculus GATE CS 2008 Discuss it Question 25 Explanation:  Question 26 If P, Q, R are Boolean variables, then (P + Q')(PQ' + PR)(P'R' + Q') simplifies  A PQ' B PR' C PQ' + R D PR'' + Q Digital Logic & Number representation GATE CS 2008 Discuss it Question 26 Explanation:  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?  A 0.24 B 0.36 C 0.4 D 0.6 Probability GATE CS 2008 Discuss it Question 27 Explanation:  Question 28 How many of the following matrices have an eigenvalue 1?   A one B two C three D four Linear Algebra GATE CS 2008 Discuss it Question 28 Explanation:  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  A 3 B 2 C sqrt(2) D 1 Probability GATE CS 2008 Discuss it Question 29 Explanation:  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 A B B C C D D Propositional and First Order Logic. GATE CS 2008 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.  Question 31 For a magnetic disk with concentric circular tracks, the seek latency is not linearly proportional to the seek distance due to  A non-uniform distribution of requests B arm starting and stopping inertia C higher capacity of tracks on the periphery of the platter D use of unfair arm scheduling policies Input Output Systems GATE CS 2008 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 auto-increment addressing mode? I. It is useful in creating self-relocating 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.  A I only B II only C III Only D II and III only Computer Organization and Architecture GATE CS 2008 Discuss it Question 32 Explanation: In auto-increment 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 P and Q are two propositions. Which of the following logical expressions are equivalent?  A Only I and II B Only I, II and III C Only I, II and IV D All of I, II, III and IV Propositional and First Order Logic. GATE CS 2008 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   A I only B II only C I and II only D I, II and III only Computer Organization and Architecture GATE CS 2008 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 multi-level cache hierarchy, which of the following are necessary? I. L1 must be a write-through cache II. L2 must be a write-through 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   A IV only B I and IV only C I, III and IV only D I, II, III and IV Computer Organization and Architecture GATE CS 2008 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.  A I and II only B I and III only C II and III only D I, II and III Computer Organization and Architecture GATE CS 2008 Discuss it Question 36 Explanation: I - False, Bypassing can't handle all RAW hazard, 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 - True, register renaming can eliminate all WAR Hazard. III- False, It cannot completely eliminate, though it can reduce Control Hazard Penalties  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   A I only B II only C III only D I, II and III Computer Organization and Architecture GATE CS 2008 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.  Question 38 In an instruction execution pipeline, the earliest that the data TLB (Translation Lookaside Buffer) can be accessed is  A before effective address calculation has started B during effective address calculation C after effective address calculation has completed D after data cache lookup has completed Computer Organization and Architecture GATE CS 2008 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 page-table (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) = 2n g(n) = n! h(n) = nlogn 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 A B B C C D D GATE CS 2008 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 A B B C C D D Array GATE CS 2008 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 (j-i+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 B-tree of order 4 is built from scratch by 10 successive insertions. What is the maximum number of node splitting operations that may take place?  A 3 B 4 C 5 D 6 B and B+ Trees GATE CS 2008 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 edge-disjoint spanning trees. Which of the following is NOT true for G?  A For every subset of k vertices, the induced subgraph has at most 2k-2 edges B The minimum cut in G has at least two edges C There are two edge-disjoint paths between every pair to vertices D There are two vertex-disjoint paths between every pair of vertices Graph Theory GATE CS 2008 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 sub-lists each of which contains at least one-fifth of the elements. Let T(n) be the number of comparisons required to sort n elements. Then  A T(n) <= 2T(n/5) + n B T(n) <= T(n/5) + T(4n/5) + n C T(n) <= 2T(4n/5) + n D T(n) <= 2T(n/2) + n Analysis of Algorithms Sorting GATE CS 2008 QuickSort 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 subset-sum 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 2-dimensional 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?  A X[i, j] = X[i - 1, j] V X[i, j -ai] B X[i, j] = X[i - 1, j] V X[i - 1, j - ai] C X[i, j] = X[i - 1, j] V X[i, j - ai] D X[i, j] = X[i - 1, j] V X[i -1, j - ai] GATE CS 2008 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[i-1, j] is true. 2) Sum of weights including ai is equal to j, i.e., if X[i-1, j-ai] 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  A only vertex a B only vertices a, e, f, g, h C only vertices a, b, c, d D all the vertices GATE CS 2008 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?  A O(Logn) B O(n) C O(nLogn) D none of the above, as the tree cannot be uniquely determined. Binary Search Trees GATE CS 2008 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/construct-bst-from-given-preorder-traversa/ 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 A B B C C D D GATE CS 2008 Discuss it Question 47 Explanation:  Question 48 Which of the following statements is false?  A Every NFA can be converted to an equivalent DFA B Every non-deterministic Turing machine can be converted to an equivalent deterministic Turing machine C Every regular language is also a context-free language D Every subset of a recursively enumerable set is recursive Regular languages and finite automata GATE CS 2008 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 A B B C C D D Regular languages and finite automata GATE CS 2008 Discuss it Question 49 Explanation: Solution for the problem is : Thus, option (A) is correct. Please comment below if you find anything wrong in the above post.  Question 50 Which of the following statements are true? I. Every left-recursive grammar can be converted to a right-recursive grammar and vice-versa II. All productions can be removed from any context-free grammar by suitable transformations III. The language generated by a context-free 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 non-terminal), is always regular IV. The derivation trees of strings generated by a context-free grammar in Chomsky Normal Form are always binary trees   A I, II, III and IV B II, III and IV only C I, III and IV only D I, II and IV only GATE CS 2008 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 type-3 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 Match the following:  A E - P, F - R, G - Q, H - S B E - R, F - P, G - S, H - Q C E - R, F - P, G - Q, H - S D E - P, F - R, G - S, H - Q GATE CS 2008 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 *  A P - 2, Q - 1, R - 3, S - 4 B P - 1, Q - 3, R - 2, S - 4 C P - 1, Q - 2, R - 3, S - 4 D P - 3, Q - 2, R - 1, S - 4 Regular languages and finite automata GATE CS 2008 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 P-1, Q-2, R-3, S-4 This explanation has been contributed by Yashika Arora.  Question 53 Which of the following are regular sets?  A I and IV only B I and III only C I only D IV only Regular languages and finite automata GATE CS 2008 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 = {xcy|x, y ∈ {a, b} ∗ } is a regular language which is concatenation of {x|x ∈ 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. Multi-level 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 stack-based allocation scheme for activation records V. Programming languages which permit a function to return a function as its result cannot be implemented with a stack-based storage allocation scheme for activation records  A II and V only B I, III and IV only C I, II and V only D II, III and V only Principles of Programming Languages GATE CS 2008 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 shift-reduce (S-R) conflicts if and only if  A the SLR(1) parser for G has S-R conflicts B the LR(1) parser for G has S-R conflicts C the LR(0) parser for G has S-R conflicts D the LALR(1) parser for G has reduce-reduce conflicts Parsing and Syntax directed translation GATE CS 2008 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, S-R 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, shift-reduce form will only take place if it is already there in LR(1) states. If there is no S-R 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 R-R 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  A does not increase B increases linearly C increases quadratically D increases exponentially Transport Layer GATE CS 2008 Discuss it Question 56 Explanation:  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?  A 1022 B 1023 C 2046 D 2047 GATE CS 2008 IP Addressing Discuss it Question 57 Explanation:  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?  A 1.6 seconds B 2 seconds C 5 seconds D 8 seconds GATE CS 2008 Discuss it Question 58 Explanation:  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?  A connect () system call returns successfully B connect () system call blocks C connect () system call returns an error D connect () system call results in a core dump GATE CS 2008 Discuss it Question 59 Explanation:  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();
}

 A 18 B 19 C 21 D 22
Advanced Pointer    GATE CS 2008
Discuss it

Question 60 Explanation:
 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") ;
}

 A ?1 is (getchar() != ’\n’) ?2 is getchar(c); B ?1 is (c = getchar() ) != ’\n’) ?2 is getchar(c); C ?1 is (c != ’\n’) ?2 is putchar(c); D ?1 is ((c = getchar()) != ’\n’) ?2 is putchar(c);
GATE CS 2008
Discuss it

Question 61 Explanation:
 Question 62
The following C function takes a single-linked 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;
}
}

 A 1,2,3,4,5,6,7 B 2,1,4,3,6,5,7 C 1,3,2,5,4,7,6 D 2,3,4,5,6,7,1
GATE CS 2008
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/data-structures-and-algorithms-set-15/ 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
 A 0 and 0 B 0 and 1 C 1 and 0 D 1 and 1
Process Management    GATE CS 2008
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/operating-systems-set-10/ This solution is contributed by Nitika Bansal
 Question 64
Which of the following statements about synchronous and asynchronous I/O is NOT true?
 A An ISR is invoked on completion of I/O in synchronous I/O but not in asynchronous I/O B In both synchronous and asynchronous I/O, an ISR (Interrupt Service Routine) is invoked after completion of the I/O C 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 D 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
Input Output Systems    GATE CS 2008
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/operating-systems-set-10/ Reference: https://msdn.microsoft.com/en-us/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?
 A In deadlock prevention, the request for resources is always granted if the resulting state is safe B In deadlock avoidance, the request for resources is always granted if the result state is safe C Deadlock avoidance is less restrictive than deadlock prevention D Deadlock avoidance requires knowledge of resource requirements a priori
GATE CS 2008    Deadlock
Discuss it

Question 65 Explanation:
 Question 66
A process executes the following code
  for (i = 0; i < n; i++) fork();
The total number of child processes created is
 A n B 2^n - 1 C 2^n D 2^(n+1) - 1;
Process Management    GATE CS 2008
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 n-1, 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 30-31 are used to index into the first level page table • Bits 21-29 are used to index into the second level page table • Bits 12-20 are used to index into the third level page table, and • Bits 0-11 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.
 A 20, 20 and 20 B 24, 24 and 24 C 24, 24 and 20 D 25, 25 and 24
Memory Management    GATE CS 2008
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?
 A Only I and II B Only I and III C Only I, II and III D Only I, III and IV
ER and Relational Models    GATE CS 2008
Discuss it

Question 68 Explanation:
 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 --> Price 
Assume {Author, Title} is the key for both schemes. Which of the following statements is true?
 A Both Book and Collection are in BCNF B Both Book and Collection are in 3NF only C Book is in 2NF and Collection is in 3NF D Both Book and Collection are in 2NF only
Database Design(Normal Forms)    GATE CS 2008
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 non-prime attributes (Publisher Year) are transitively dependent on key [Title, Author].
• Book is in 2NF because every non-prime 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, non-prime attributes (attributes that do not occur in any candidate key) are Publisher, Year and Prince
Please refer Database Normalization | Normal Forms for details of normal forms.
 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 non-key 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 multi-level index scheme is used to store the secondary index, the number of first-level and second-level blocks in the multi-level index are respectively.
 A 8 and 0 B 128 and 6 C 256 and 4 D 512 and 5
GATE CS 2008
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
-----------------------------------
| Search-Key  |  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/ecs165a-w11/7-indexes.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 2-way 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 pre-fetching 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
 A 32 Kbits B 34 Kbits C 64 Kbits D 68 Kbits
Computer Organization and Architecture    GATE CS 2008
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 = 211 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 * 211 (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]?
 A ARR[0][4] B ARR[4][0] C ARR[0][5] D ARR[5][0]
GATE CS 2008
Discuss it

Question 72 Explanation:
Total number of elements in array = 210 * 210 = 220 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 * 211 * 2 = 213 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
 A 0% B 25% C 50% D 75%
Computer Organization and Architecture    GATE CS 2008
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(n-1) + 3*f1(n-2));
}

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[i-1] + Z[i-2];
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 A B B C C D D
GATE CS 2008
Discuss it

Question 74 Explanation:
 Question 75
Consider the program given in above question, f1(8) and f2(8) return the values
 A 1661 and 1640 B 59 and 59 C 1640 and 1640 D 1640 and 1661
GATE CS 2008
Discuss it

Question 75 Explanation:
 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,
 A the instruction following the conditional branch instruction in memory is executed B the first instruction in the fall through path is executed C the first instruction in the taken path is executed D the branch takes longer to execute than any other instruction
GATE CS 2008
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← R5-R6
I3 : ADD R1← R2+R3
I4 : STORE Memory [R4]←[R1]
BRANCH to Label if R1== 0
Which of the instructions I1, I2, I3 or I4 can legitimately occupy the delay slot without any other program modification?
 A I1 B I2 C I3 D I4
GATE CS 2008
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 R5-R6.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 A B B C C D D
GATE CS 2008
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.
 Question 79
The value of X5 is
 A 5 B 7 C 8 D 16
GATE CS 2008
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.
 Question 80
The subset-sum 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 2-dimensional 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?
 A X[i, j] = X[i - 1, j] V X[i, j -ai] B X[i, j] = X[i - 1, j] V X[i - 1, j - ai] C X[i, j] = X[i - 1, j] V X[i, j - ai] D X[i, j] = X[i - 1, j] V X[i -1, j - ai]
GATE CS 2008
Discuss it

Question 80 Explanation:
 Question 81
The subset-sum 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 2-dimensional 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?
 A X[1, W] B X[n, 0] C X[n, W] D X[n-1, n]
GATE CS 2008
Discuss it

Question 81 Explanation:
 Question 82
Consider the following ER diagram. The minimum number of tables needed to represent M, N, P, R1, R2 is
 A 2 B 3 C 4 D 5
ER and Relational Models    GATE CS 2008
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. Many-to-one and one-to-many relationship sets that are total on the many-side 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 one-many or many-one 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?
 A {M1, M2, M3, P1} B {M1, P1, N1, N2} C {M1, P1, N1} D {M1, P1}
ER and Relational Models    GATE CS 2008
Discuss it

Question 83 Explanation:
As given in the explanation http://quiz.geeksforgeeks.org/gate-gate-cs-2008-question-82/ 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?
 A Y is [1 2 3 4 5 6 7 8 9 10] and x < 10 B Y is [1 3 5 7 9 11 13 15 17 19] and x < 1 C Y is [2 2 2 2 2 2 2 2 2 2] and x > 2 D Y is [2 4 6 8 10 12 14 16 18 20] and 2 < x < 20 and x is even
GATE CS 2008
Discuss it

Question 84 Explanation:
 Question 85
Consider the data given in above question, the correction needed in the program to make it work properly is
 A Change line 6 to: if (Y[k] < x) i = k + 1; else j = k-1; B Change line 6 to: if (Y[k] < x) i = k - 1; else j = k+1; C Change line 6 to: if (Y[k] <= x) i = k; else j = k; D Change line 7 to: } while ((Y[k] == x) && (i < j));
GATE CS 2008
Discuss it

There are 85 questions to complete.

## GATE CS Corner

See Placement Course for placement preparation, GATE Corner for GATE CS Preparation and Quiz Corner for all Quizzes on GeeksQuiz.