2006 _soluation

Upload: surajit-dutta

Post on 16-Jul-2015

401 views

Category:

Documents


0 download

TRANSCRIPT

1.Consider the polynomial p(x) = a0 + a1 x + a2 x2 + a3 x2 whereai

0

iThe

minimum number of multiplications needed to evaluate p on an input x is: (A) 3 (B) 4 (C) 6 (D) 9 Ans.) A p(x) can be written as a0 + (a1 + (a2 + a3 x)*x)*x, in which case the no.of multiplications are 3 2.LetX,Y,Zbesetsofsizesx,yandzrespectively.LetW=XYandEbetheset of all subsets of W. The number of functions from Z to E is: (A) (B) Z * 2x y (C) Z 2x+y (D) 2 xyz Ans.) D Ingeneralthenumberoffunctionsfromsetmtosetnis|n||m| 3.The Set { 1,2,3,5,7,8,9 } under multiplication modulo 10 is not a group. Given below are four plausible reasons. Which one of them is false? (A) It is not closed (B) 2 does not have an inverse (C) 3 does not have an inverse (D) 8 does not have an inverse. Ans.) C, Because 3 has 7 as its inverse. 4. A relation R is defined on ordered pairs of integers as follows: (x,y) R (u,v) if x < u and y>v. Then R is: (A) Neither a Partial Order nor an Equivalence Relation (B) A Partial Order but not a Total Order (C) A Total Order (D) An Equivalence Relation. Ans.) A because R is not reflexive. 5. For which one of the following reasons does Internet Protocol (IP) use the timeto-live (TTL) field in the IP datagram header? (A) Ensure packets reach destination within that time (B) Discard packets that reach later than that time (C) Prevent packets from looping indefinitely (D) Limit the time for which a packet gets queued in intermediate routers. Ans:(C) Time to live indicates the time or maximum number of hops the packet is allowed to make before it is discarded. normally it is set to twice the maximum length path from source to destination. 6. Consider three CPU-intensiveprocesses,whichrequire10,20and30timeunitsandarriveattimes0,2and6,respectively.Howmanycontext switchesareneedediftheoperatingsystemimplementsashortestremainingtimefirstschedulingalgorithm?Donotcountthecontextswitchesat time zero and at the end. (A) 1 (B) 2 (C) 3 (D)4 Ans:(B) At time 0, only p1 is available and it is executed, p2 and p3 arrive at times 2 and 6 respectively. p1 executes to completion according to shortest remaining first algorithm, then p2 and then p3. Therefore the number of context switches are 2. 7. Consider the following grammar. S S * E S E E F+E E F F id Consider the following LR(0) items corresponding to the grammar above. (i) S S * .E (ii) E F. + E (iii) E F + .E Given the items above, which two of them will appear in the same set in the canonical sets-of-items for the grammar? (A) (i) and (ii) (B) (ii) and (iii) (C) (i) and (iii) (D) None of the above Ans (D) None of the productions come together because , all of them are reading on different input symbols. i is on *, ii is on F, and iii is on +. 8. You are given a free running clock with a duty cycle of 50% and a digital waveformfwhichchangesonlyatthenegativeedgeoftheclock.Whichoneofthefollowingcircuits(usingclockedDflip-flops) will delay the phase offby180? (A)

9. A CPU has 24-bit instructions. A program starts at address 300 (in decimal). Which one of the following is a legal program counter (all values in decimal)?

(A) 400 (B) 500 (C) 600 (D) 700 10.Inabinarymaxheapcontainingnnumbers,thesmallestelementcanbefoundintime (A) O(n) (B) O(logn) (C) O(loglogn) (D) O(1) Ans.)A All the elements in the second half of the array are the possible candidates for the smallest element. 11. Consider a weighted complete graph G on the vertex set {v1 ,...,vn } such that the weight of the edge (vi,vj) is 2|i - j|. The weight of a minimum spanning tree of G is: (A) n-1 (B) 2n - 2 (C) nc2 (D) n2 ANS) B The minimum weight in G is 2 and weight of each edge (v ,v ) is 2, choosing these edges gives us a minimum spanning tree of weight 2n-2. i i+1 12. To implement Dijkstrasshortestpathalgorithmonunweightedgraphssothatitrunsinlineartime,thedatastructuretobeusedis: (A) Queue (B) Stack (C) Heap (D) B-Tree Ans.) A As BFS can be used to find the shortest paths, A Queue should be required. 13.AschemeforstoringbinarytreesinanarrayXisasfollows.IndexingofXstartsat1insteadof0.therootisstoredatX[1].Foranodestoredat X[i],theleftchild,ifany,isstoredinX[2i]andtherightchild,ifany,inX[2i+1].Tobeabletostoreanybinarytreeonnverticestheminimumsize of X should be (A) log2 n (B) n (C) 2n + 1 (D) 2n - 1 Ans:(D) In the worst case the space required is 2n - 1 and will be for right-skewtree. 14.Whichoneofthefollowinginplacesortingalgorithmsneedstheminimumnumberofswaps? (A) Quick sort (B) Insertion sort (C) Selection sort (D) Heap sort Ans.) C Selection Sort requires at most n swaps, because at the Kthstepinthealgorithm,atmostoneswapisrequired. 15. Consider the following C-program fragment in which , and i, j and n are integer variables. for(i = n, j = 0; i > 0; i /= 2, j +=i) ; Let val(j) denote the value stored in the variable j after termination of the for loop. Which one of the following is true? (A) val(j)= (logn) (B) val(j) = ( ) (C) val(j) = (n) (D) val(j) = (nlogn) Ans.)C The recurrence relation is T(n) = T(n/2) + n/2, if (n>0) =else1 which is (n). 16. Let S be an NP-complete problem and Q and R be two other problems not known to be in NP. Q is polynomial time reducible to S and S is polynomial-timereducibletoR.Whichoneofthefollowingstatementsistrue? (A) R is NP-complete (B) R is NP-hard (C) Q is NP-complete (D) Q is NP-hard. Ans.) B 17.AnelementinanarrayXiscalledaleaderifitisgreaterthanallelementstotherightofitinX.Thebestalgorithmtofindallleadersinanarray (A) Solves it in linear time using a left to right pass of the array (B) Solves it in linear time using a right to left pass of the array (C) Solves it using divide and conquer in time n n log (D) Solves it in time n2 Ans.) B while scanning the array from right to left remember the greatest element seen so far and compare it with the current element to test for leadership 18. We are given a set X ={x1 ,,xn } where xi = 2i.AsampleS valueofthesmallestnumberinsampleSis: (A) 1/n (B) 2 (C) (D) n Ans.) D X is drawn by selecting each xi independently with probability 1/2. The expected

probability that 2i is the smallest element in S is 1/2i So the expected value of the smallest number in S is =n

19. Let L1 ={0m+n 1n 0m |n,m0},L2 = {0m+n 1n+m 0m |n,m0} and L3 = {0m+n 1n+m 0n+m |n,m0}.WhichoftheselanguagesareNOTcontextfree? (A) L1 only (B) L3 only (C) L1 and L2 (D) L2 and L3 Ans.) L2 can be written as {0p 1p 0q|n,m0andq Fu-Fv=0=>F.(u-v) = 0 and (u-v) 0. vandFu=b,Fv=b.Whichoneofthe

24. Given a set of elements N = {1, 2,..,n} and two arbitrary subsets A N and B N howmanyofthen!permutations from N to N satisfy min( (A)) = min( (B)), where min(S) is the smallest integer in the set of integers S and (S) is the set of integers obtained by applying permutaion to each element of S. (A) (n -(|A U B|)) |A| |B| (B) (|A|2 + |B|2 ) n2 (C) n! |A B| / |A U B| (D) |A B|2 / n c |A B| Ans.) C The number of permutations are nc|A nc|AU B| U B|

. |A B|. (|A U B| -1)! (n- |A U B|)!

: for choosing |A U B| elements from n elements

and then assigning the minimum element of the set AUB to any one of the AB elements , which is |A B| and then permuting the elements of AUB except the minimum assigned element, which is (|A U B| -1)! and then permuting the remaining n-AUB elements among themselves, which is (n- |A U B|)! So the expression can be written as (nc|A U B| . |A B|. (|A U B|)! (n- |AUB|)!)/(|AUB|)=(np|A U B| . |A B|. (n- |A U B|)! ) / (|A U B|) =

(n! . |A B| ) / (|A U B|) 25. Let S = {1, 2, 3, ..,m}, m>3. Let X1 ,X2,....,Xn be subsets of S each of size 3. Define a function f from S to the set of natural numbers as, f(i) is the number of sets Xjthatcontaintheelementi.Thatisf(i)=|{j|i Xj }|. Then (A) 3m (B) 3n (C) 2m + 1 (D) 2n + 1 Ans.) B Every element included in a set is counted exactly once in the expression 3.n (since each set has exactly 3 elements). 26.WhichoneofthefirstorderpredicatecalculusstatementsgivenbelowcorrectlyexpressesthefollowingEnglishstatement? Tigers and lions attack if they are hungry or threatened. A.)x [ (tiger(x) lion(x)) {(hungry(x) threatened(x)) attacks(x)}] B.)x [ (tiger(x) lion(x)) {(hungry(x) threatened(x)) attacks(x)}] C.)x [ (tiger(x) lion(x)) { attacks(x) (hungry(x) threatened(x))}] D.)x [ (tiger(x) lion(x)) {(hungry(x) threatened(x)) attacks(x)}}] Ans.) D 27. Consider the following propositional statements: P1 : ((A B) C)) ( (A C) (B C) ) P2 : ((A B) C)) ( (A C) (B C) ) Which one of the following is true? (A) P1 is a tautology, but not P2. (B) P2 is a tautology, but not P1. (C) P1 and P2 are both tautologies. (D) Both P1 and P2 are not tautologies. Ans.) B P2 is not a tautology because consider the statement S1 : "If x is divisible by 3 and x is divisible by 2 then x is divisible by 6" but S1 does imply neither "If x is divisible by 3 then x is divisible by 6" nor "If x is divisible by 2 then x is divisible by 6" A logical binary relation , is defined as follows: W ABA B TrueTrueTrue TrueFalseTrue FalseTrueFalse FalseFalseTrue . so the value of the expression the total number of elements i.e is

29.Let ~ be the unary negation (NOT) operator, with higher precedence than Which one of the following is equivalent to A B. (A) (~A B) (B) ~(A ~B) (C) ~(~A ~B). (D) ~(~A B). Ans:(B) 29. If s is a string over (0+1)*, then let n0 (s) denote the number of 0s in s. and n1 (s) denote the number of 1s in s. Which one of the following languages is not regular? (A) L = { s (B) L = { s (C) L = { s (D) L = { s (0 + 1)* | no (s) is a 3-digit prime} (0 + 1)* | for every prefix s' of s |no (s') - n1 (s')| ab, S -> ba, S -> } I. G is ambiguous

II. G produces all strings with equal number of as and bs III. G can be accepted by a deterministic PDA. Which combination below expresses all the true statements about G? (A) I only (B) I and III only (C) II and III only (D) I, II and III Ans.) B is ambiguous because can be derived using more than one derivation tree. Is regular and can be written as (ab+ba)* , so can be accepted by a deterministic PDA. 33. Let L1 be a regular language, L2 be a deterministic context-free language and L3 is recursively enumerable, but not recursive, language. Which one of the following statements is false? (A) L1 L2 is a deterministic CFL (B) L3 (D) L1 L1 is recursive L2 L3 is recursively enumerable (C) L1 U L2 is context free Ans.) B A is true since a regular language is a DCFL and DCFL's are closed under union. B is false , since L3 L1 isrecursive, isrecursiveand is recursive so it should be the case that but this contradicts that L3 not recursive C is true D is true since all are R.E's 34.ConsidertheregularlanguageL=(111+11111)*.TheminimumnumberofstatesinanyDFAacceptingthislanguagesis: (A) 3 (B) 5 (C) 8 (D) 9 Ans.) D

-

, which is

is recursive,

35.) Consider the circuit above. Which one of the following options correctly ( ) represents f x y z , , ? (A) x z xy y z + + (B) x z xy yz + + (C) xz xy yz + + (D) xz x y yz + +

36.Giventwothreebitnumbersaaabbbcthecarryin,thefunctionandand,thatrepresentsthecarrygeneratefunctionwhenthesetwonumbers are added is: (A) a b a a b a a a b a a bb a bb a a bb a bbb + + + + + + 222112100201012110200210 (B) a b a bb a a bb a a bb a a b a a bb a a bb + + + + + + 222102110102110210202010 ( ) ( ) ( ) ( ) (C) a b a b a b a b a b + + + + + 2222111100 (D) a b a a b a a a b a a bb a bb a a bb a bbb + + + + + + 222112100201012110200210

37. Consider the circuit in the diagram. The operator represents Ex-OR. The D flipflops are initialized to zeroes (cleared). The following data: 100110000 is supplied to the dataterminalinnineclockcycles.Afterthatthevaluesofqqqare: 210 (A) 000 (B) 001 (C) 010 (D) 101

()38.ConsideraBooleanfunctionfwxyzsupposethatexactlyoneofitsinputsis,allowedtochangeatatime.Ifthefunctionhappenstobetrue fortwoinputvectorsiwxyz=,,,andiwxyz=,,,,wewouldlikethefunctionto1111122222 remain true as the input changes from ( ) i i i i without becoming false to and differ in exactly one bit position , ( ) ( ) momentarily. Let f w x y z , , , 5,7,11,12, 13,15 . = Which of the following cube covers of f will ensure that the required property is satisfied? (A) , , , , wxz wx y xy z xyz wyz (B) , , wxy wxz wyz (C) , , wxyz xz wxyz (D) , , , , , wzy wyz wxz wxz x yz xyz

39. nn a a nn

We consider the addition of two 2s complement numbers b b b . and - 120 a . . A binary adder for adding unsigned binary numbers is used to add - 120

the two numbers. The sum is denoted by c c c . and the carry-out by . c n n - 120out Which one of the following options correctly identifies the overflow condition? ()

40. Consider numbers represented in 4-bit gray code. Let h h h h be the gray code 3210 representation of a number n and let gggg be the gray code of 3210 ( ) ( ) n + 1 modulo 16 value of the number. Which one of the following functions is correct? ( ) ( ) (A) g h h h h = 1, 2, 3,6,10,13,14,15 ( ) ( ) (B) g h h h h = 4,9,10,11,12,13,14, 15 ( ) ( ) (C) g h h h h = 2, 4,5, 6, 7,12, 13,15 ( ) ( ) (D) g h h h h = 0,1, 6, 7, 10,11,12,13

41. A CPU has a cache with block size 64 bytes. The main memory has k banks, each bank being c bytes wide. Consecutive c byte chunks are mapped on consecutive banks with wrap-around.Allthekbankscanbeaccessedinparallel,buttwoaccessestothesamebankmustbeserialized.Acache blockaccessmayinvolvemultipleiterationsofparallelbankaccessesdependingontheamountofdataobtainedbyaccessingallthekbanksin parallel.EachiterationrequiresknsThedecodingthebanknumberstobeaccessedinparallelandthistakes.latencyofonebankaccessis80ns. If the latency of retrieving c k = = 2 and 24, a cache block starting at address zero from main memory is: (A) 92 ns (B) 104 ns (C) 172 ns (D) 184 ns

42. A CPU has a five-stagepipelineandrunsat1GHzfrequency.Instructionfetchhappensinthefirststageofthepipeline.Aconditionalbranch instructioncomputesthetargetaddressandevaluatestheconditioninthethirdstageofthepipeline.Theprocessorstopsfetchingnewinstructions followingaconditionalbranchuntilthebranchoutcomeisknown.Aprogramexecutes10instructions9outofwhich20%areconditionalbranches.If eachinstructiontakesonecycletocompleteonaverage,thetotalexecutiontimeoftheprogramis: (A) 1.0 second (B) 1.2 seconds (C) 1.4 seconds (D) 1.6 seconds

43. Consider a new instruction named branch-on-bit-set(mnemonicbbs).Theinstructionbbs reg, pos, labeljumps to label if bit in position pos of registeroperandregisone.Aregisteris32bitswideandthebitsarenumbered0to31,bitinposition0beingtheleastsignificant.Considerthe followingemulationofthisinstructiononaprocessorthatdoesnothavebbsimplemented.tempreg&mask Branch to label if temp is non-zero. The variable temp is a temporary register. For correct emulation, the variable mask must be generated by (A)01maskpos0 (B)0maskffffffffpos2 (C) mask pos (D)0maskf

44.StationAuses32bytepacketstotransmitmessagestoStationBusingaslidingwindowprotocol.TheroundtripdelaybetweenAandBis80 millisecondsandthebottleneckbandwidthonthepathbetweenAandBis128kbps.WhatistheoptimalwindowsizethatAshoulduse? (A) 20 (B) 40 (C) 160 (D) 320 Ans:(B) The packet size is 32 bytes = 32*8 bits. Roundtriptimeis80ms.Bandwidthis128kbps.Thereforein1RTT,thesourcecantransmit128kbps*80msbitsofdata. Thedatapossibletobetransmitteddividedbythepacketsizegivesthewindowsize.whichis(128k*80ms)/(32*8)=40. 45. Two computers C1 and C2 are configured as follows. C1 has IP address 203.197.2.53 and netmask 255.255.128.0. C2 has IP address 203.197.75.201 and netmask 255.255.192.0. which one of the following statements is true? (A) C1 and C2 both assume they are on the same network (B) C2 assumes C1 is on same network, but C1 assumes C2 is on a different network (C) C1 assumes C2 is on same network, but C2 assumes C1 is on a different network (D)C1andC2bothassumetheyareondifferentnetworks. Ans:(C) IP address of C1 is 203.197.2.53 and Subnet mask is 255.255.128.0 anding gives the network id which is 203.197.0.0. when C1 sees the ip address 203.197.75.201, to find the network id it will and with its subnet mask, which gives 203.197.0.0. so C1 assumes that C2 is on the same network with C1. similarly,IPaddressofC2is203.197.75.201,subnetmaskis255.255.192.0andinggivesthenetworkidwhichis203.197.64.0. when this computer looks at IP address of C1, to find the network id, it will and with its network mask giving 203.197.0.0. Therefore C1 assumes that C2 is on the same network with C2, but C2 assumes C1 is on a different network.

46.StationAneedstosendamessageconsistingof9packetstoStationBusingaslidingwindow(windowsize3)andgo-back-n error control strategy.Allpacketsarereadyandimmediatelyavailablefortransmission.Ifevery5thpacketthatAtransmitsgetslost(butnoacksfromBeverget lost),thenwhatisthenumberofpacketsthatAwilltransmitforsendingthemessagetoB?

(A) 12 (B) 14 (C) 16 (D)18 Ans:(C)

Assuming that correctly transmitted packet is acknowledged at the same time. when a packet is lost, the receiver waits for certain duration but the sender can send up to its window size. The total number of packets sent is 16. 47. Consider the following graph:

Which one of the following cannot be the sequence of edges added, in that to order a minimum spanning tree using Kruskalsalgorithm? (A) (a-b),(d-f),(b-f),(d-c),(d-e) (B) (a-b),(d-f),(d-c),(b-f),(d-e) (C) (d f),(a-b),(d-c),(b-f),(d-e) (D) (df),(ab),(bf),(de),(dc) Ans:(D) weight of (de) > (dc)

48.LetTbeadepthfirstsearchtreeinanundirectedgraphG.Verticesanduarevleavesofthistree.ThedegreesofbothuandvinGareatleast 2.whichoneofthefollowingstatementsistrue? (A) There must exist a vertex w adjacent to both u and v in G (B) There must exist a vertex w whose removal disconnects u and v in G (C) There must exist a cycle in G containing u and v (D) There must exist a cycle in G containing u and all its neighbours in G. Ans.) D AandBarefalseforadisconnectedgraph,containingtwocycles,isinonecycleandvisinother. C is false in case where B is true. D is true : Let x1 , x2 , ......., xn be the edges that are adjacent to u without loss of generality let x1 be the vertex adjacent to u in T, and x2 ,.....,xn vertices has been visited before u otherwise u would not be a leaf. and there is an edge between x1 to x2 other wise x2 would be adjacent to u in T. extending this argument we can say that xi is adjacent to xi+1 by which there is cycle having vertices u and x1 , x2 , ......., xn . 49. An implementation of a queue Q, using two stacks S1 and S2, is given below: void insert (Q, x) {

push(S1,x) } void delete (Q) { if(stack-empty(S2)) then if(stack-empty(S1)) then { print(Q is empty); return; } elsewhile(!(stack-empty(S1))){ x=pop(S1) push(S2,x) } x=pop(S2) } Letninsertandm(