You are on page 1of 400

2/26/2015

GATEOverflow Book

GATEOverflowBook

http://gateoverflow.in/book

1/400

2/26/2015

GATEOverflow Book

ThisbookiscomposedofallquestionsatGATEOverflow,
orderedbydate,sortedbycategories,includingtheiranswers
thatwereselectedasbest.
Questionswithoutqualifyinganswersarenotincludedherein.
ThebookwascreatedprogramaticallybyGATEOverflowon
Feb26,2015.

http://gateoverflow.in/book

2/400

2/26/2015

GATEOverflow Book

TableofContents
Algorithms
GATE2012_4
GATE2012_5
GATE2012_16
GATE2012_18
DoineedtostudyP,NPcomputationalproblemslikevertexcoverproblemalsoforgate2015oronlythebasicdefinitions?
Supposethereisabalancedbinarytreewithnnodes
Isthefollowingstatementvalid?
log(n!) = (n log n)

Whatisthetimecomplexity?
GATE2003_66
Givenaninteger
GATE2008_40
GATE2008_45
GATE2008_74,75
GATE2000_2.15
GATE2000_2.16
GATE2000_2.18
GATE2001_1.14
GATE2002_1.4
GATE2006_10
GATE2003_12
GATE2003_20
GATE2006_14
GATE2006_15
GATE2006_16
GATE2006_17
GATE2004_6
GATE2004_29
GATE2004_83
GATE2004_84
GATE2003_23
GATE1994_23Shouldn'ttheanswerbebothaandb?
GATE2007_14
GATE2007_39
GATE2007_76,77
GATE2009_14
GATE2009_38
GATE2009_39
GATE2005_6
GATE2005_45
GATE2013_6
GATE1999_1.12
GATE1999_1.14
GATE1999_2.21
GATE2013_30
GATE2013_31
GATE2013_43
GATE2013_50,51
GATE1998_1.22
GATE20141_11
GATE20141_14
GATE2006_47
GATE2006_51
GATE2006_54
GATE2008_42
GATE20141_38
GATE20141_41
GATE20141_42
GATE20142_38
GATE20143_10
GATE20143_12
GATE20143_13
GATE20143_14
GATE20143_37
GATE2011_25
GATE2011_37
GATE2010_34
GATE1997_4.6
GATE1993_7.4
GATE2010_35
GATE2010_36
GATE2010_50,51
GATE1994_1.7
GATE1994_1.11
GATE1994_1.17
http://gateoverflow.in/book

3/400

2/26/2015

GATEOverflow Book

GATE1994_1.19
GATE1994_1.23
GATE1994_6
GATE1994_25
GATE1995_1.5
GATE1995_1.16
GATE1995_2.9
GATE1995_2.22
GATE1995_12
GATE1995_22
GATE1996_2.13
GATE1996_2.15
GATE2008IT_11
GATE2008IT_12
GATE2007IT_27
GATE2006IT_10
GATE2004IT_13
GATE2004IT_52
GATE2004IT_57
GATE2004IT_58
GATE2005IT_53
GATE2005IT_57
GATE2005IT_58
GATE2005IT_59
GATE2005IT_84a
B+TreesProblem
Hashing
TimeComplexity
timecomplexityofaprogramis?
Answerthefollowingquestion
Whatisthecomplexityoffinding50thsmallestelementinanalreadyconstructedbinaryminheap?
GATE20151_2
GATE20152_2
GATE20152_11
GATE20151_6
GATE20152_22
GATE20152_36
GATE20151_31
GATE20151_43
GATE20151_45
GATE20151_49
GATE20153_4
GATE20153_27
GATE20153_30
GATE20153_39
GATE20153_40
GATE20153_42
GATE20153_49
GATE20153_53
CO&Architecture
GATE2012_20
Whynotd?
GATE2004_47
GATE2013_45
GATE2008_38
GATE2008_71,72,73
GATE2008_76,77
GATE2000_1.8
GATE2000_1.10
GATE2000_12
GATE2001_2.9
GATE2001_9
GATE2002_1.13
GATE2002_1.24
GATE2002_10
GATE2004_39
GATE2007_80,81
GATE2005_65
GATE2005_66
GATE2013_20
GATE1999_13
GATE2013_48,49
GATE1998_1.19
GATE1998_2.18
GATE20141_9
GATE2006_42
GATE2006_74,75
GATE2006_80,81
GATE20141_43
GATE20141_44
GATE20141_55
http://gateoverflow.in/book

4/400

2/26/2015

GATEOverflow Book

GATE20142_9
GATE20142_43
GATE20142_44
GATE20143_9
GATE20143_43
GATE20143_44
GATE2011_28
GATE2011_41
GATE2012_54,55
GATE2010_33
GATE2010_48,49
GATE1995_1.6
GATE1996_26
GATE2008IT_38
GATE2008IT_80
GATE2008IT_81
GATE2007IT_37
GATE2006IT_39
GATE2006IT_40
GATE2006IT_42
GATE2006IT_79
GATE2004IT_12
GATE2004IT_49
GATE2005IT_49
GATE2005IT_61
GATE20152_24
GATE20152_42
GATE20151_38
GATE20153_14
GATE20153_47
OperatingSystem
GATE2012_8
Cananyonepleasehelp(orprovidesomelinkstatedclearly)inMultilevelPagetableandPagingwithSegmentation?
Pagereplacement
GATE2013_52,53
GATE2008_67
GATE1991_02,iii
GATE1992_02,x
GATE2001_1.7
GATE2003_78,79
GATE2002_1.23
GATE2003_76
GATE2004_12
GATE2004_21
GATE2007_55
GATE2009_31
GATE2005_21
GATE1999_2.11
GATE1999_19
GATE2013_39
GATE1998_1.29
GATE1998_1.31
GATE1998_1.32
GATE1998_2.9
GATE20141_31
GATE20141_32
GATE20141_33
Gate2006_62
GATE2006_64
GATE20142_55
GATE20143_31
GATE20143_33
GATE2011_20
GATE2011_35
GATE2011_44
GATE2012_42
GATE2010_23
GATE2010_24
GATE2010_25
GATE1997_3.9
GATE1997_3.10
GATE2010_46
Diskscheduling
GATE1994_1.13
GATE1994_1.24
GATE1994_28
GATE1995_1.15
GATE1995_19
GATE1995_20
GATE1996_1.18
GATE1996_1.19
http://gateoverflow.in/book

5/400

2/26/2015

GATEOverflow Book

GATE1996_1.20
GATE1996_2.17
GATE1996_2.18
GATE1996_2.19
GATE1996_2.20
GATE1996_22
GATE2008IT_16
GATE2008IT_41
GATE2008IT_53
GATE2008IT_55
howmanyprocesscreated?
GATE2004IT_14
GATE2004IT_63
GATE2004IT_64
GATE2004IT_66
GATE2005IT_17
GATE2005IT_62
CPUScheduling
whatisthedifferencebetweenlivelockanddeadlock
AddressTranslation
Deadlock
Acertaincomputersystemhasthesegmentedpagingarchitectureforvirtualmemory.
MysteriousFork()call?
consideramachinewith64Mbytephysicalmemoryanda32bitvirtualaddress.ifthepagesizeis4kByte,whatistheapproximatesizeof
thepagetable?a)16Mbyteb)8Mbytec)2Mbyted)24Mbyte
GATE20152_23
GATE20152_25
GATE20151_9
GATE20152_30
GATE20151_12
GATE20151_30
GATE20152_47
GATE20152_49
GATE20151_46
GATE20151_47
GATE20151_48
GATE20153_1
GATE20153_10
GATE20153_34
GATE20153_52
Databases
GATE2012_2
GATE2012_14
GATE2012_15
GATE2008_70
GATE2008_15
GATE2008_68
GATE2008_69
GATE2000_2.24
GATE2000_2.25
GATE2000_2.26
GATE2001_2.23
GATE2002_1.19
GATE2004_14
GATE2004_50
GATE2007_60
GATE2007_62
ConsidertableR(A,B,C,D,E)withFDsasA>B,BC>EandED>A.Thetableisinwhichnormalform?Justifyyouranswer.
GATE2009_45
GATE2005_29
GATE2005_30
GATE2005_76
GATE1999_2.25
Trivialfunctionaldependency
GATE2013_54,55
GATE1998_2.19
GATE20141_21
GATE20141_22
GATE20141_30
GATE2006_70
GATE20141_54
GATE20142_22
GATE20143_21
GATE20143_22
GATE20143_30
GATE20143_54
GATE2011_32
GATE2011_46
GATE2012_43
GATE2010_42
GATE2010_43
http://gateoverflow.in/book

6/400

2/26/2015

GATEOverflow Book

GATE1995_27
GATE1996_27
functionaldependency
FindthenumberofcandidateskeysthatincludesattributeA3
GATE2008IT_61
GATE2007IT_68
GATE2006IT_14
GATE2006IT_84
GATE2004IT_21
GATE2004IT_74
GATE2004IT_75
GATE2004IT_76
GATE2004IT_78
GATE2005IT_21
GATE2005IT_22
GATE2005IT_24
GATE2005IT_67
GATE2005IT_70
GATE2005IT_82a
GATE2005IT_82b
ThomasWriteRule
GATE20152_1
GATE20152_6
GATE20151_7
GATE20151_24
GATE20151_27
GATE20151_41
GATE20153_3
GATE20153_20
GATE20153_46
TheoryofComputation
GATE2012_12
Considerthefollowinglanguages
IdentifytheclassofL
Let = {a, b, c} .Whichofthefollowingstatementsistrue?
AppropriateoptionforL
L={|L(M)isinfinite}
L={|L(M)=*}
GATE2003_15
TosayP=NP
LetLbearegularlanguage
Whichofthefollowingareusefulinprovingalanguagetoberegular?
GATE2003_54
GATE2003_52
GATE1999_1.6
GATE2008_10
GATE2008_13
GATE2008_48
GATE2008_51
GATE2008_52
GATE1991_03,xiii
GATE1991_03,xiv
GATE1992_02,xvii
GATE2000_1.4
GATE2000_1.5
GATE2000_2.8
GATE2000_2.9
GATE2001_1.4
GATE2001_1.5
GATE2001_2.7
GATE2001_7
GATE2002_2.14
GATE2003_13
GATE2003_14
GATE2003_53
GATE2003_55
GATE2004_86
findminimaldfaforL
GATE2007_6
GATE2007_7
GATE2007_30
GATE2007_31
GATE2007_74,75
GATE2006_34
GATE2009_12
GATE2009_15
GATE2009_16
GATE2005_56
GATE2005_57
GATE2013_8
GATE1999_1.5
http://gateoverflow.in/book

7/400

2/26/2015

GATEOverflow Book

GATE2013_32
GATE2013_41
GATE2012_24
GATE2012_25
GATE1998_1.9
GATE1998_1.11
GATE1998_1.12
GATE1998_2.6
GATE20141_16
GATE20141_35
GATE20141_36
GATE20142_15
GATE20142_16
GATE20142_35
GATE20142_36
GATE20143_15
GATE20143_35
GATE20143_36
GATE2011_8
GATE2011_26
GATE2011_42
GATE2010_17
GATE1997_6.4
GATE1997_6.5
GATE1997_21
GATE1993_27
GATE2010_39
GATE2010_40
GATE2010_41
Toctheoremproof
GATE1994_1.16
GATE1994_2.10
GATE1994_19
GATE1995_1.9
GATE1995_2.20
GATE1995_2.23
GATE1995_2.24
GATE1996_1.8
GATE1996_1.9
GATE1996_1.10
GATE1996_2.8
GATE1996_13
GATE1998_3b
Regularornot?
GATE2008IT_5
GATE2008IT_35
GATE2008IT_36
Gate2011_24
GATE2006IT_29
GATE2006IT_30
GATE2006IT_37
GATE2004IT_9
GATE2004IT_41
GATE2005IT_4
GATE2005IT_5
GATE2005IT_6
GATE2005IT_37
GATE2005IT_39
GiventhatalanguageLA=L1UL2,
HowtodrawNPDAforlanguageL={a^ib^jc^m|m>=min(i,j)}
GivenLanguageisRECorNonRE
Whichistrue?
LetL1isregularandL2isCFG.ThenwhatisL1L2?
Ithinktheanswershouldbe32butitsnotinoptions?Helpmeinthisquestion..
plzanswer...
DoesPDAacceptsL={a^nb^n|n>=0,n!=13}???
mydoubtisthatwhennotmentionedweshouldconsideritdfaornfacozanswillvary
WhethergivenCFLisRegularisDecidable?
ThenumberofstatesinaDFAacceptingallthestringsover{0,1}inwhich5thsymbolfromrighthandsideisalways'1'is?
LanguageacceptedbyPDAis__________?
equivalentregularexpression?
toc
WhichofthefollowinglanguagesareRecursivelyEnumerablelanguage?
No.ofstatesintheminimalfiniteautomatawhichacceptsthebinarystringswhoseequivalentisdivisibleby32is________?
GATE20151_3
GATE20152_21
GATE20152_35
GATE20152_51
GATE20152_53
GATE20151_51
GATE20151_52
http://gateoverflow.in/book

8/400

2/26/2015

GATEOverflow Book

GATE20153_18
GATE20153_32
ComputerNetworks
GATE2012_10
Ifaorganisationrequires30hosts.whichisthebestpossiblemaskthatcanbeused?
GATE2008_14
GATE2006_05
GATE2003_82
GATE2003_84
GATE2004_15
GATE2004_55
GATE2004_56,57
GATE2007_65
GATE2007_70
GATE2009_57,58
GATE2005_23
GATE2005_24
GATE2005_25
GATE2005_74
GATE2012_22
GATE20141_24
GATE20141_26
GATE20141_27
GATE2006_46
GATE20142_25
GATE2010_15
GATE2008IT_65
GATE2008IT_70
GATE2007IT_64
GATE2006IT_70
GATE2004IT_25
GATE2004IT_26
GATE2004IT_45
GATE2004IT_80
GATE2004IT_81
GATE2004IT_86
GATE2005IT_25
GATE2005IT_26
ARPprotocolbelongstowhichlayerofOSImodel.?Accordingtomeitisneithercompletelylayer3(Networklayer)norcompletelylayer
2(datalinklayer).Pleaseclarify
GATE20152_8
GATE20152_20
GATE20152_34
GATE20151_17
GATE20151_19
GATE20151_22
GATE20151_21
GATE20152_52
GATE20151_53
GATE20153_6
GATE20153_22
GATE20153_28
GATE20153_36
GATE20153_38
DigitalLogic
GATE2012_6
GATE2012_7
GATE2012_19
tomultiplyabinarynumberwehavetodoleftshift...fordivisionrightshift....ithinkthisisapplicableonlyonlywegettheresultaspure
integer...iftheresultisfraction..thenthiswillnotwork....writeurcomments...pls
GATE1991,05,c
GATE2008_6
GATE2008_8
GATE2008_26
GATE1991_01,iii
GATE1992_01,i
GATE1992_02,i
GATE2000_1.6
GATE2000_2.14
GATE2001_1.11
GATE20012.10
GATE2001_2.12
GATE2002_2.1
GATE2009_5
GATE2005_16
GATE2005_17
GATE2005_64
GATE2013_4
GATE2013_5
GATE1999_2.16
GATE1999_2.17
http://gateoverflow.in/book

9/400

2/26/2015

GATEOverflow Book

GATE2013_21
GATE1998_1.13
GATE1998_1.14
GATE20141_8
GATE20141_45
GATE20143_7
GATE20143_45
GATE2011_14
GATE2011_15
GATE2010_6
GATE2010_7
GATE2010_9
GATE1997_2.1
GATE1995_2.2
GATE1995_2.5
GATE1995_2.12
GATE1996_2.22
Kindlyhaveatry....INcanonicalPOSformfollowingequationiswrittenas(ABC)=AB+BC+AC(A)M(0,1,2,4)(B)M(3,5,6,7)
(A)M(0,1,2,3)(A)M(4,5,6,7)
GATE2008IT_1
GATE2008IT_7
GATE2007IT_7
GATE2007IT_42
GATE2004IT_8
GATE2004IT_10
GATE2004IT_42
GATE2004IT_44
GATE2005IT_9
GATE2005IT_10
GATE2005IT_11
GATE2005IT_47
Letf(x,y,z)=x'+y'x+xzbeaswitchingfunction.Whichoneofthefollowingisvalid?
whichoneisnotselfcomplemetrycode
GATE2015_7feb2nd
GATE20151_20
GATE20152_48
GATE20151_37
GATE20153_35
GATE20153_43
GATE20153_44
IS&SoftwareEngg.
GATE2009_50
GATE20141_18
GATE20143_19
GATE2011_7
GATE2011_10
GATE2010_21
GATE2010_22
GATE2010_44
GATE2008IT_60
GATE2006IT_16
GATE2006IT_17
GATE2004IT_69
GATE2004IT_70
GATE2004IT_71
GATE2004IT_72
GATE20151_1
GATE20152_4
GATE20152_12
GATE20152_43
GATE20151_42
GATE20153_11
GATE20153_21
GATE20153_55
WebTechnologies
GATE2009_20
GATE20142_28
GATE2011_9
GATE2010_16
GATE2004IT_24
GATE2004IT_90
GATE2005IT_30
GATE20152_13
GATE20151_15
GATE20153_8
VerbalAbility
GATE20141_GA_1
GATE20141_GA_2
GATE20141_GA_3
GATE20141_GA_6
GATE20141_GA_7
http://gateoverflow.in/book

10/400

2/26/2015

GATEOverflow Book

GATE2013_56
GATE2013_57
GATE2013_59
GATE2013_60
GATE2013_63
GATE20142_GA_1
GATE20142_GA_3
GATE20142_GA_6
GATE20142_GA_7
GATE20143_GA_1
GATE20143_GA_2
GATE20143_GA_3
GATE20143_GA_6
GATE20143_GA_7
GATE2011_56
GATE2012_57
GATE2012_58
GATE2012_59
GATE2012_60
GATE2012_61
GATE2010_56
GATE2010_57
GATE2010_58
GATE2010_60
GATE2010_63
Completethesentence:Dare__mistake.
GATE20151_GA_1
GATE20151_GA_2
GATE20151_GA_5
GATE20151_GA_7
GATE20151_GA_8
GATE20152_GA_1
GATE20152_GA_2
GATE20152_GA_4
GATE20153_GA_2
GATE20153_GA_3
GATE20153_GA_4
GATE20153_GA_6
GATE20153_GA_7
GATE20153_GA_9
NumericalAbility
GATE20141_GA_5
GATE20141_GA_4
GATE20141_GA_8
GATE20141_GA_9
GATE20141_GA_10
GATE2013_64
GATE2013_65
GATE20142_GA_4
GATE20142_GA_5
GATE20143_GA_4
GATE20143_GA_10
GATE2011_57
GATE2011_62
GATE2011_64
GATE2011_65
GATE2012_56
GATE2012_62
GATE2012_63
GATE2012_64
GATE2012_65
GATE2010_59
GATE2010_61
GATE2010_64
Conditionalprobability
GATE20151_GA_3
GATE20151_GA_4
GATE20151_GA_6
GATE20151_GA_9
GATE20151_GA_10
GATE20152_GA_5
GATE20153_GA_1
GATE20153_GA_5
GATE20153_GA_8
GATE20153_GA_10
MathematicalLogic
GATE2012_1
GATE2012_13
GATE2013_47
logicaldeduction
GATE1992_92,xv
http://gateoverflow.in/book

11/400

2/26/2015

GATEOverflow Book

GATE2008_31
GATE2001_1.3
GATE2009_23
GATE2002_1.8
GATE2003_32
GATE2003_33
GATE2010_30
GATE2005_41
GATE2007_22
GATE1998_1.5
GATE20141_53
GATE20143_1
GATE20143_53
GATE1997_3.2
GATE1993_8.2
GATE1994_3.13
GATE1996_2.3
GATE2008IT_22
GATE2006IT_21
Assumethefollowingpredicateandconstantsymbols:
Usequantifierstoexpress:>Thereisexactlyonepersonwhomeverybodyloves
GATE2002_5b
Commenton(R,*)group/commutative/monoid
Whichofthefollowingisatautology?
Howmanysolutionsaretheretotheequationx+y+z=17?Theyarenonnegativeintegers
GATE20152_3
GATE20151_14
GATE20153_24
Probability
GATE2013_2
randomvariableX 2 + Y 2 > 1
GATE2008_27
GATE2000_1.1
GATE2000_2.2
GATE2001_2.4
GATE1995_1.18
GATE2002_2.10
GATE2002_2.16
GATE2006_21
GATE2004_25
GATE2004_78
GATE2010_27
GATE2005_52
GATE1999_2.1
GATE2013_24
GATE1998_1.1
GATE1998_3a
GATE20141_2
GATE20141_48
GATE20142_1
GATE20142_2
GATE20142_48
GATE20143_48
GATE2011_3
GATE2011_33
GATE1994_1.4
GATE1994_2.8
GATE1995_2.14
GATE1996_1.5
GATE1996_2.7
GATE2006IT_22
AandBarefriends.Theydecidetomeetbetween1:00pmand2:00pmonagivenday.
Afaircoinistossed100times.TheProbabilityofgetting50headsisclosetooneofthefollowingnumbers:a)0.001b)0.1c)0.3d)0.4
BayesTheorem
GATE20151_29
GATE20153_37
SetTheory&Algebra
GATE2013_1
numberofsymmetricfuntions
GATE2009_1
GATE2009_4
GATE2006_24
GATE2010_3
GATE2005_13
GATE2005_42
GATE2007_3
GATE1999_3
GATE1998_1.6
GATE20141_50
GATE20142_5
GATE20143_2
http://gateoverflow.in/book

12/400

2/26/2015

GATEOverflow Book

GATE20143_49
GATE20143_50
GATE1997_6.1
GATE1996_2.1
Onasetofnelements,howmanyrelationsaretherethatarebothirreflexiveandantisymmetric?
GATE2008IT_26
GATE2007IT_76
GATE2005IT_31
GATE2005IT_33
Noofsurjectivefunctions
maths_mock_test3
maths_mock_test4
GATE20151_5
GATE20152_GA_3
GATE20152_GA_9
GATE20152_9
GATE20152_16
GATE20152_18
GATE20152_26
GATE20152_40
GATE20151_28
GATE20151_16
GATE20151_26
GATE20152_54
GATE20151_34
GATE20151_39
GATE20153_2
GATE20153_5
GATE20153_23
GATE20153_41
Combinatory
GATE2008_24
GATE2002_13
GATE2003_4
GATE2003_5
GATE2005_35
GATE20141_49
GATE20142_49
GATE2011_29
GATE1994_1.15
GATE2008IT_24
GATE2008IT_25
GATE2005IT_46
Aprofessorwrites20multiplechoicequestions,eachwiththepossibleanswera,b,c,ord,foradiscretemathematicstest.Ifthenumberof
questionswitha,b,c,anddastheiransweris8,3,4,and5,respectively,howmanydifferentanswerkeysarepossible,ifthequestionscan
beplacedinanyorder?
Themaximumnumberofdistinctsubwordsoftheword"AXIOMATIZABLE"is:a)183b)111c)92d)88
GraphTheory
GATE2012_17
directedgraph
Thenumberofdistinctsimplegraphswithuptothreenodesare
GATE2012_38
GATE2002_1.25
GATE2003_36
GATE2003_40
GATE2004_77
GATE2005_11
GATE2013_25
GATE2006_71,72,73
GATE20141_51
GATE20141_52
GATE20142_3
GATE20142_51
GATE20143_3
GATE20143_51
GATE2011_17
GATE1994_2.5
GATE1995_1.25
GATE1995_24
GATE2008IT_27
GATE2004IT_37
GATE2005IT_56
Maxnoofedgesindisconnectedgraph
Numberofdistinctgraphs
GATE20152_28
GATE20152_50
GATE20151_54
LinearAlgebra
GATE2012_11
GATE2007_25
GATE2003_41
http://gateoverflow.in/book

13/400

2/26/2015

GATEOverflow Book

GATE2004_27
GATE2013_3
GATE1998_1.2
GATE1998_2.1
GATE1998_2.2
GATE20142_47
GATE20143_5
GATE2011_40
GATE1997_1.3
GATE2008IT_29
GATE2004IT_6
GATE2004IT_36
GATE20152_5
GATE20152_27
GATE20151_18
GATE20151_36
NumericalMethods
GATE20142_46
GATE2008IT_30
GATE20153_50
Calculus
GATE2012_9
GATE2009_25
GATE1998_8
GATE20141_47
GATE20143_47
GATE2011_31
GATE1996_3
GATE20151_4
GATE20151_44
GATE20153_9
GATE20153_45
Programming
GATE2013_42
Ihavebeenstrugglingwithpointersinmultidimensionalarrays.Pleasehelpmewiththiscode:
Parameterpassingtechnique
GATE1994_1.20
GATE2008_61
GATE1991_09,a,b
GATE2000_1.11
GATE2000_1.17
GATE2001_2.17
GATE2001_2.18
GATE2002_1.16
GATE2002_1.17
GATE2002_2.8
GATE2003_89
GATE2004_1
GATE2004_31
GATE2004_90
GATE1999_2.13
GATE1998_2.15
GATE2012_36
GATE20141_10
GATE2006_56
GATE2006_57
GATE20142_11
GATE20142_42
GATE20143_42
GATE2011_22
GATE2012_48,49
GATE2010_11
GATE2010_14
GATE1997_1.10
GATE2008IT_13
GATE2008IT_51
GATE2008IT_52
GATE2007IT_32
GATE2007IT_33
GATE2007IT_34
GATE2007IT_35
GATE2006IT_51
GATE2004IT_59
GATE2004IT_60
GATE2004IT_61
WhatisthebestwaytostudyCprogrammingforGATE2015?
ifelseconditionbasedquestion
trytoprintthisinoneloopitself.
whyisthereadifferenceintheexecution
Charpointertoaccessanint
Whatwillbethesecondvalueprintedbytheprogramifparameterpassingmechanismiscallbyreference?
http://gateoverflow.in/book

14/400

2/26/2015

GATEOverflow Book

whatisdifferencebetweendeepbindingandshallowbinding?Explainwiththiscode.
Considerthefollowingprogram
useofunionsinc
Whatistheoutput,explain
pleaseexplainthereasonforthe"weird"falseconditioncomingoutfromforconditionalchecking.
GATE2015_7feb
GATE20152_15
GATE20151_11
GATE20151_33
GATE20151_35
GATE20153_7
GATE20153_26
GATE20153_48
GATE20153_54
DS
GATE2013_44
GATE1991_01,ix
GATE1991_01,viii
GATE1991_03,vii
GATE2002_2.12
GATE2003_64
GATE2003_90
GATE2004_5
GATE2004_7
GATE2004_36
GATE2007_38
GATE2007_43
GATE2009_59,60
GATE2005_2
GATE2005_5
GATE2005_34
GATE1998_2.11
GATE1998_2.14
GATE2006_49
GATE20141_40
GATE20142_12
GATE20142_41
GATE20143_40
GATE1997_4.7
GATE1994_1.14
GATE1996_1.12
GATE1996_1.14
GATE1996_2.11
GATE2008IT_72
GATE2008IT_76
GATE2008IT_77
GATE2007IT_29
GATE2006IT_44
GATE2006IT_45
GATE2006IT_71
GATE2006IT_73
GATE2004IT_53
GATE2004IT_54
GATE2005IT_12
GATE2005IT_13
GATE2005IT_16
GATE2005IT_50
GATE2005IT_54
GATE2005IT_55
GATE20151_10
GATE20152_38
GATE20151_23
GATE20151_25
GATE20151_32
GATE20151_40
GATE20153_12
GATE20153_13
GATE20153_17
GATE20153_19
GATE20153_25
Others
C++andjavaarenotinsyllabusforgateCSE?
OutofSyllabusNow
linearprogramming....explainit

http://gateoverflow.in/book

15/400

2/26/2015

GATEOverflow Book

Algorithmstop
GATE2012_4top
AssumingPNP,whichofthefollowingisTRUE?
(A)NPcomplete=NP
(B)NPcomplete P=
(C)NPhard=NP
(D)P=NPcomplete

Answeris
(B)NPcomplete P=
Since,P NP,thereisatleastoneprobleminNP,whichisharderthanallPproblems.Letstakethehardestsuchproblem,sayX .Since,P NP,X

P.

Now,bydefinition,NPcompleteproblemsarethehardestproblemsinNPandsoX problemisinNPcomplete.AndbeinginNP,X canbereducedtoall


problemsinNPcomplete,makinganyotherNPcompleteproblemashardasX .So,sinceX P,noneoftheotherNPcompleteproblemscanalsobenotinP.

name

GATE2012_5top
Theworstcaserunningtimetosearchforanelementinabalancedbinarysearchtreewithn2 n elementsis
(A)(n log n)(B)(n2 n ) (C)(n) (D)(log n)
Binarysearchtakes(log n) forn elementsintheworstcase.So,with(n2 n )elements,theworstcasetimewillbe
(log(n2

))

= (log n + log 2

= (log n + n)

= (n)

name

GATE2012_16top
TherecurrencerelationcapturingtheoptimalexecutiontimeoftheT owersof H anoi problemwithn discsis
(A)T (n) = 2T (n 2) + 2
(B)T (n) = 2T (n 1) + n
(C)T (n) = 2T (n/2) + 1
(D)T (n) = 2T (n 1) + 1

RecurrencerelationforTowersofHanoiis
T(1)=1
T(n)=2T(n1)+1
SoAnswershouldbe(D)
name

GATE2012_18top
LetW (n) andA(n) denoterespectively,theworstcaseandaveragecaserunningtimeofanalgorithmexecutedonaninputofsizen .Whichofthe
followingis<b>ALWAYSTRUE</b>?
(A)A(n) = (W (n))
(B)A(n) = (W (n))
(C)A(n) = O(W (n))
(D)A(n) = o(W (n))
Worstcasecomplexitycanneverbelowerthantheaveragecasecomplexity,butitcanbehigher.So,(C)istheanswer.
http://gateoverflow.in/book

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

16/400

2/26/2015

GATEOverflow Book
A(n) = O(W (n))

name

DoineedtostudyP,NPcomputationalproblemslikevertexcoverproblemalsoforgate2015or
onlythebasicdefinitions?top
Youwouldneedtoknowsomeexamples(notall)ofNPCompleteproblemsandwhytheyareNPComplete.Forexample3SATproblemis
NPCandinGATEtheyhaveaskedabout2SAT.So,justlearningsomeexampleswon'tbeenough.
name

Supposethereisabalancedbinarytreewithnnodestop

Answershouldbe(A).
Wefirstfinda intheBSTinO(log n) time.Nowtherearetwopossibilities,bcanbeintherightsubtreeofa orbcanbeintherightsubtreeofanyofthe
parentsofa .Forthefirstcase,wesimplysearchforb ,intherightsubtreeofa andateachstepweaddthenumberofelementsintheleftsubtree+1,ifwe
aremovingrightandsimply1ifwearemovingleft.Whenwefindb ,thissumwillgiveastherequirednumberofelements.
Forthesecondcasealsowedothesamemethod.Butfirstwefindthecommonancestorofa andb (possibleinO(log n) sayp andfromp toa addthe
numberofnodesintherightsubtreeforeachlevelandaddthistotherequiredsum.So,intheworstcasewehavetodoO(log n) additions.
name

Isthefollowingstatementvalid?
log(n!) = (n log n)

top

Ithinkitissterling'sapproximation

ln N ! = N ln N N + ln 2n

name

Whatisthetimecomplexity?top
double foo(int n)
{
int i;
double sum;
if(n == 0)
{
return 1.0;
}
else
{
sum = 0.0;
for(i = 0; i < n; i++)
{
sum += foo(i);
}
return sum;
}

http://gateoverflow.in/book

17/400

2/26/2015

GATEOverflow Book

Thetimecomplexityoftheabovecodeis?

AnswerisO(2 n )

Thelastcn isforthen timestheforloopisexecuting.


T(0)=1
T(1)=2
T(2)=5
T(3)=11
T(4)=23
T(5)=47
So,
T (n) = 2

+ 2

n1

1 = O(2

name

GATE2003_66top
The cube root of a natural number n is defined as the largest natural number m such that (m
representedbybinarynotation)is

n) . The complexity of computing the cube root of n (n is

(A)O(n) butnotO(n 0.5 )


(B)O(n 0.5 ) butnotO((log n)
(C)O((log n)

) foranyconstantk > 0

) forsomeconstantk > 0 ,butnotO((log log n)

(D)O((log log n)

)foranyconstantm > 0

)forsomeconstantk > 0.5 ,butnotO((log log n)

0.5

Wecansimplydoabinarysearchinthearrayofnaturalnumbersfrom1..nandcheckifthecubeofthenumbermatchesn.Inthiswaywecanfindthecube
rootinO(log n) .So,options(A)and(B)arewrong.
Now,anumberisrepresentedinbinaryusinglog nbit.Sinceeachbitisimportantinfindingthecuberoot,anycuberootfindingalgorithmmustexamine
eachbitatleastonce.Thisensuresthatcomplexityofcuberootfindingalgorithmcannotbelowerthanlog n.(Itmustbe log n ).So,(D)isalsofalseand
(C)isthecorrectanswer.
gatecse

Givenanintegertop
Givenanintegern 3,considertheproblemofdeterminingifthereexistintegersa, b 2 suchthatn = ab .Callthistheforwardproblem.Thereverse
problemis:givena andb ,computeab ( mod b) .Notethattheinputlengthfortheforwardproblemislog n + 1 ,whiletheinputlengthforthereverse
problemislog a + log b + 2 .WhichofthefollowingstatementsisTRUE?
(a)Boththeforwardandreverseproblemscanbesolvedintimepolynomialinthelengthsoftheirrespectiveinputs.
(b)Theforwardproblemcanbesolvedinpolynomialtime,howeverthereverseprobleminNPhard.
(c)Thereverseproblemcanbesolvedinpolynomialtime,howevertheforwardprobleminNPhard.
(d)BoththeforwardandreverseproblemsareNPhard.
(e)Noneoftheabove.

Thereverseproblemcanbesolvedinpolynomialtimeasab requiresatmostlog b recursivecallsusingtheapproachgivenbelow:


pow(int a, int b)
{
if(b%2)
return a* pow(a*a, b/2);
else
return pow(a*a, b/2);
}

Now,theforwardproblemisalsosolvableinpolynomialtime.Weneedtocheckforalltherootsofn (fromn tilln


)whetheritisaninteger.But
2
eachofthesecheckcanbedoneinlog ntimeusingabinarysearchonthesetofintegersfrom2..n andso,theoverallcomplexitywillbe(log n) whichis
polynomialinlog n(log nisthesizeofinput).So,(a)mustbetheanswer.
http://gateoverflow.in/book

log n

18/400

2/26/2015

GATEOverflow Book

gatecse

GATE2008_40top

Tocheckwhetheragivennumberisrepeatedn/2timesinthearraycanbedoneinO(logn)time.
Algo
1.findthefirstoccurrence(indexi)ofx(givennumber)inthearraywhichcanbedoneinO(logn)time(avariantofbinarysearch).
2.checkifA[i]==A[n/2+i]
returntrue
3.elsereturnfalse

name

GATE2008_45top

(d)allthevertices.JustsimulatetheDijkstra'salgorithmonit.Dijkstra'salgorithmisnotmeantforgraphswithnegativeedgesasitmightnotalwayswork,buthere
itdoesgivethecorrectshortestpath.

name

GATE2008_74,75top
ConsiderthefollowingCfunctions:
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];
}

http://gateoverflow.in/book

19/400

2/26/2015

GATEOverflow Book

74.Therunningtimeoff1(n)andf2(n)are
A.
B.
C.
D.

(n)and(n)
(2n)and(n)
(n)and(2n)
(2n)and(2n)

75.f1(8)andf2(8)returnthevalues
A.
B.
C.
D.

1661and1640
59and59
1640and1640
1640and1661

Timecomplexityoff1isgivenby
T(n)=T(n1)+T(n2),(multiplicationby2and3won'taffectcomplexityasitisaconstanttimeoperation)
T(0)=T(1)=1
Thesolutiontothis(fibonacciseries)isgivenbyGoldenratio.https://en.wikipedia.org/wiki/Golden_ratiowhichisO(2n).(Usingthetainquestionmustbea
mistake)
Timecomplexityoff2is(n)ashereallrecursivecallsareavoidedbysavingtheresultsinanarray(dynamicprogramming).
So,answerto74is(B).
75.Bothf1andf2arecalculatingthesamefunction.So,
f1(2)=2f1(1)+3f1(0)=2
f1(3)=2f1(2)+3f1(1)=7
f1(4)=20
f1(5)=61
f1(6)=182
f1(7)=547
f1(8)=1640=f2(8)
name

GATE2000_2.15top
Supposeyouaregivenanarrays[1....n]andaprocedurereverse(s,i,j)whichreversestheorderofelementsinsbetweenpositionsiandj(bothinclusive).Whatdoesthefollowing
sequencedo,where1kn:
reverse (s, 1, k);
reverse (s, k+1, n);
reverse (s, 1, n);

a. Rotatessleftbykpositions
b. Leavessunchanged
c. Reversesallelementsofs
d. Noneoftheabove

Answeris(a)
Effectoftheabove3reversalforanyKisequivalenttoleftrotationofthearrayofsizenbyk.
Let,S[1......7]
1

so,n=7,k=2
reverse(S,1,2)weget[2,1,3,4,5,6,7]
reverse(S,3,7)weget[2,1,7,6,5,4,3]
reverse(S,1,7)weget[3,4,5,6,7,1,2]
henceoption(a)Rotatessleftbykpositioniscorrect

name

GATE2000_2.16top
http://gateoverflow.in/book

20/400

2/26/2015

GATEOverflow Book

LetLASTPOST,LASTINandLASTPREdenotethelastvertexvisited`inapostorder,inorderandpreordertraversalrespectively,ofacompletebinarytree.Whichofthefollowingis
alwaystrue?

a. LASTIN=LASTPOST
b. LASTIN=LASTPRE
c. LASTPRE=LASTPOST
d. Noneoftheabove

TheanswerisD.
Takeanyrandomsequenceandcheckfortheinorder,postorderandpreorderLastNode.
name

GATE2000_2.18top
LetGbeanundirectedconnectedgraphwithdistinctedgeweights.Lete max betheedgewithmaximumweightande min theedgewithminimumweight.Whichofthefollowing
statementsisfalse?

a. EveryminimumspanningtreeofGmustcontaine
b. Ife
isinaminimumspanningtree,thenitsremovalmustdisconnectG
c. Nominimumspanningtreecontainse
d. Ghasauniqueminimumspanningtree
min

max

max

C.thecaseshouldbewrittenas"mayormaynot",tobetrue.
Dwillalwaysbetrueasperthequestionsayingthatthegraphhasdistinctweights.
name

GATE2001_1.14top
Randomizedquicksortisanextensionofquicksortwherethepivotischosenrandomly.Whatistheworstcasecomplexityofsortingnnumbersusing
Randomizedquicksort?
(A)O(n)
(B)O(n log n)
(C)O(n 2 )
(D)O(n!)
Inworstcase,wemaypickpivotelementsintheincreasingorder(inputalsogiveninsortedorder)whichwillresultinrunningtimeofO(n 2 )
Ans.C
name

GATE2002_1.4top
Theminimumnumberofcoloursrequiredtocolourtheverticesofacyclewithnnodesinsuchawaythatnotwoadjacentnodeshavethesamecolouris
A. 2
B. 3
C. 4
D. n 2[ n2 ] + 2

Chromaticnumberwillbe3forwhennisoddandwillbe2whenniseven.Option(d)isarepresentationforthis,hencethecorrectanswer
name

GATE2006_10top
Inabinarymaxheapcontaining numbers,thesmallestelementcanbefoundintime
(A)O(n)
(B)O(log n)
(C)O(log log n)
O(1)
http://gateoverflow.in/book

21/400

2/26/2015

GATEOverflow Book

(D)O(1)

(A)O(n)
Inamaxheap,thesmallestelementisalwayspresentataleafnodeandcanbefoundinO(n)time.
name

GATE2003_12top
RamandShyamhavebeenaskedtoshowthatacertainproblem isNPcomplete.Ramshowsapolynomialtimereductionfromthe3SATproblemto ,and
Shyamshowsapolynomialtimereductionfrom to3SAT.Whichofthefollowingcanbeinferredfromthesereductions?

A.

isNPhardbutnotNPcomplete

B.

isinNP,butisnotNPcomplete

C.

isNPcomplete

D.

isneitherNPhard,norinNP

C
Ram'sreductionshowsisNPhard.
Shyam'sreductionshowsisinNP.
SoNPC.
name

GATE2003_20top
Considerthefollowingthreeclaims
m

I. (n + k) = (n m ) wherekandmareconstants
II. 2 n+1 = O(2 n )
III. 2 2n+1 = O(2 n )
Whichofthefollowingclaimsarecorrect
A.
B.
C.
D.

IandII
IandIII
IIandIII
I,II,andIII

1)Clearlyrateofgrowthof(n+k)^m=n^masmisaconstant
soTRUE
2)2^(n+1)=2*(2^n)=theta(2^n)as2isaconstanthere
soas2^(n+1)isbothupperandlowerboundedby2^n
sowecansay2^(n+1)=O(2^n)
soTRUE
3)2^(2n+1)hassamerateofgrowthas2^(2n)
2^(2n)=(2^n)^2
http://gateoverflow.in/book

22/400

2/26/2015

GATEOverflow Book

so2^nisupperboundedby(2^n)^2,nottheotherwayround
soFALSE

CORRECTMEIFIAMWRONG
name

GATE2006_14top
Whichoneofthefollowinginplacesortingalgorithmsneedstheminimumnumberofswaps?
(A)Quicksort
(B)Insertionsort
(C)Selectionsort
(D)Heapsort
(C)Selectionsort
name

GATE2006_15top
ConsiderthefollowingCprogramfragmentinwhichi,jandnareintegervariables.

for( i = n, j = 0; i > 0; i /= 2, j +=i );

Letval(j)denotethevaluestoredinthevariablejafterterminationoftheforloop.Whichoneofthefollowingistrue?
(A)
(B)
(C)
(D)
Answerwillbetheta(n)
j=n/2+n/4+n/2+...+1
numberofiterationwillbe2^k=nork=logn
thisisingpfindsumtilllogn=thetha(n)
name

GATE2006_16top
LetSbeanNPcompleteproblemandQandRbetwootherproblemsnotknowntobeinNP.QispolynomialtimereducibletoSandSispolynomialtime
reducibletoR.Whichoneofthefollowingstatementsistrue?
(A)RisNPcomplete
(B)RisNPhard
(C)QisNPcomplete
(D)QisNPhard
QcannotbeNPhardasnonphardproblems(unlesstheyarenp)canbepolynomialtimereducibletonpcomplete.AnswerisB,asnpcproblemcanbe
reducibletonphardproblem.ButthereisconfusionifQisnotNPhardthenwhatcomplexityclassitisin!!
name

GATE2006_17top
AnelementinanarrayXiscalledaleaderifitisgreaterthanallelementstotherightofitinX.Thebestalgorithmtofindallleadersinanarray
(A)Solvesitinlineartimeusingalefttorightpassofthearray
(B)Solvesitinlineartimeusingarighttoleftpassofthearray
(C)Solvesitusingdivideandconquerintime(n log n)
(D)Solvesitintime(n 2 )

AnsBshouldbecorrect.
http://gateoverflow.in/book

23/400

2/26/2015

GATEOverflow Book

Wecanmovefromrightkeepinganoteofthemaximumelement(supposecurrent_max).Atthestarttherightmostelementwill
alwaysbealeader.Ifanelementisgreaterthanourcurrent_max,itwillaleader.Addthiselementtoleaders.Setcurrent_maxtothis
elementandcarryonleftward.TimeComplexitywouldbeO(n)
name

GATE2004_6top

Breadthfirstseach.
anshu

GATE2004_29top
Thetightestlowerboundonthenumberofcomparisons,intheworstcase,forcomparisonbasedsortingisoftheorderof
(a)n
(b)n 2
(c)n log n
(d)n log2 n
Forcomparisonbasedsortingtheasymptoticallytightboundforworstcaseisgivenby(log n) ,whichmeansitisthetightestupperbound(bigO)aswell
asthetightestlowerbound(bigomega).So,answerisn log n .
Tightestlowerboundofsorting(sayS(n))isn log n meansthereisnofunctionf whichhasanorderofgrowthlargerthann log n and
f (n) = (S (n))holds.
Ausualmistakeistothinkworstcasechangeswithlowerandupperbounds,butthatisnotthecase.Worstcaseisdefinedfortheproblemanditisalways
theinputwhichcausesthealgorithmthemaximumcomplexity.
name

GATE2004_83top
ThetimecomplexityofthefollowingCfunctionis(assumen>0)
int recursive (int n) {
if(n == 1)
return (1);
else
return (recursive (n-1) + recursive (n-1));
}

(a)O(n) (b)O(n log n)(c)O(n 2 ) (d)O(2 n )

Itssimilartotowerofhanoiproblem

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

T(1)=1
T(2)=2.1+1=3
T(3)=2.3+1=7
T(4)=2.7+1=15.........
T(n)=2.T(n1)+1
wecanseethatitsapatterngettingformedwhichist(n)
name

http://gateoverflow.in/book

= 2

soitsdO(2 n )

24/400

2/26/2015

GATEOverflow Book

GATE2004_84top
Therecurrenceequation

T (1) = 1

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

evaluatesto
(a)2 n+1

n 2

(b)2 n

(c)2 n+1

2n 2

(d)2 n

+ n

T(n)=2T(n1)+n,n>=2&T(1)=1
T(n)=n+2(n1)+22(n2)+...........+2(n1)(n(n1))
=n(1+2+......+2n1)(1.2+2.22+3.23+.....+(n1).2n1)
=n(2n1)(n.2n2n+1+2)
=2n+1n2
name

GATE2003_23top
Inaminheapofsizen the7thsmallestelementcanbefoundin

Timetofindthesmallestelementonaminheaponeretrieveoperation(1)
Timetofindthesecondsmallestelementonaminheaprequires2 2 1 = 3 checkoperationstofindthesecondsmallestelementoutof3elements
(1)

Timetofindthe7thsmallestelementrequiresO(2 7

1) = O(127)

checkoperationstofindtheseventhsmallestelementoutof127possibleones

(1)

Inshortifthenumberofrequiredoperationsisindependentoftheinputsizen,thenitisalways(1) .
(Here,wearedoingalevelordertraversaloftheheapandcheckingtheelements)
gatecse

GATE1994_23Shouldn'ttheanswerbebothaandb?top
Shouldn'ttheanswerbebothaandb?

Yes.Both(a)and(b)arecorrect.n2isO(n3)
gatecse

http://gateoverflow.in/book

25/400

2/26/2015

GATEOverflow Book

GATE2007_14top

A.
Irrespectiveoftheinput,Mergesortalwayshaveatimecomplexityoftheta(nlogn).
name

GATE2007_39top

TheanswerisA.
Takethefirstnodeinpreordertraversalawillbetherootofthetree
Allnodestotheleftof'a'ininordertraversalwillbeintheleftsubtreeof'a'andallelementsontherightwillbeintherightsubtreeof'a'.
Takethesecondelementfrompreordertraversal'b'goestoleftsubtreeof'a'asitisintheleftof'a'ininorderlist.
Proceedinglikewisewecanconstructthebinarytreeas:

name

GATE2007_76,77top

Basedontheprobabilities,wecansaytheprobablefrequencyoftheletterswillbe
16,8,4,2,1,1
Now,theHuffmantreecanbeconstructedasfollows:
http://gateoverflow.in/book

26/400

2/26/2015

GATEOverflow Book

So,Aistheanswerfor76.
Averagelengthwillbe1/2*1+1/4*2+1/8*3+1/16*4+1/32*5+1/32*5
=62/32=1.9375
https://www.siggraph.org/education/materials/HyperGraph/video/mpeg/mpegfaq/huffman_tutorial.html
name

GATE2009_14top

AproblemwhichisinP,isalsoinNPsoAcanisfalse.IfproblemcanbesolveddeterministicallyinPolynomialtime,thenalsowecan'tcomment
anythingaboutP=NP,wejustputthisprobleminP.So,Balsofalse.CisTRUEbecausethatisthedefinitionofNPcomplete.

name

http://gateoverflow.in/book

27/400

2/26/2015

GATEOverflow Book

GATE2009_38top

inoptiondbcwithweight4isaddedbeforeacwithweight3isadded.Inkruskal'salgorithmedgesshouldbeaddedinnondecreasingorderofweight
SooptionDmaybecorrect
name

GATE2009_39top

B.
T(n)=O(n)pivotselectiontime+O(n)partitiontime+T(n/41)+T(3n/4)
which'llgivetheta(nlog4/3n).
name

GATE2005_6top

fromthegivendatagivengraphisacompletegraphwithalledgeweightsare1.AMSTwillcontainn1edges.HenceweightofMSTisn1.Thegraphwill
havemultipleMST.infactallspanningtreesofthegivengraphwllbeMSTsalsosincealledgeweightsareequal.
name

GATE2005_45top
ConsiderthreedecisionproblemsP1,P2andP3.ItisknownthatP1isdecidableandP2isundecidable.WhichoneofthefollowingisTRUE?
A.
B.
C.
D.

P3isdecidableifP1isreducibletoP3
P3isundecidableifP3isreducibletoP2
P3isundecidableifP2isreducibletoP3
P3isdecidableifP3isreducibletoP2'scomplement

(A)IfP1isreducibletoP3,thenP3isatleastashardasP1.So,noguaranteeifP3isdecidable.
(B)IfP3isreducibletoP2,thenP3cannotbeharderthanP2.ButP2beingundecidable,thiscan'tsayP3isundecidable.

http://gateoverflow.in/book

28/400

2/26/2015

GATEOverflow Book

(C)IfP2isreducibletoP3,thenP3isatleastashardasP2.Since,P2isundecidable,thismeansP3isalsoundecidablehencetheanswer.
(D)Complementofanundecidableproblemisundecidable.Now,reducingtoanundecidableproblemcan'tproveP3isdecidable.
http://gatecse.in/wiki/Some_Reduction_Inferences
name

GATE2013_6top
Whichoneofthefollowingisthetightestupperboundthatrepresentsthenumberofswapsrequiredtosortn numbersusingselectionsort?
(A)O(log n )
(B)O(n )
(C)O(n log n )
(D)O(n 2 )
Inselectionmaxyoucandoisnswaps..selectingthesmallestelementfromalltheelementsandreplacingitcorrectpositionsoO(n)
name

GATE1999_1.12top

(c)Ifitmantainstherelativeorderofoccurrenceofnondistinctelements.
(fromdefinitionofstablesorting)
name

GATE1999_1.14top

20471589440301217
\/\/\/\/\/
20478154930401217after1stpass
\/\/\/
\/\/\/
8,15,20,474,9,30,4012,17after2ndpass

Ans.B
name

GATE1999_2.21top
IfT1

= O(1)

,givethecorrectmatchingforthefollowingpairs:
(M)Tn = Tn1 + n
(N)Tn = T + n
n

(O)Tn

= T

+ n log n

(P)Tn
http://gateoverflow.in/book

(U)Tn
(V)Tn
(W)T

= O(n)
= O(n log n)
2

= O(n )

= Tn1 + log n
n

= O(

n)

29/400

2/26/2015
n

n1

GATEOverflow Book

+ log n

(X)Tn

= O(log

n)

(A)MWNVOUPX
(B)MWNUOXPV
(C)MVNWOXPU
(D)MWNUOVPX
(M)T (n) =Sumoffirstnnaturalnumbers=
(N)T (n)
(f (n)
af (

n
b

= n = (n
) < cf (n)

(O)T (n)
(f (n)
af (

n
b

= (n) = O(n)
log b a+

n
2

log 2 1+

) < cf (n)

log b a+

f(

n
2

= O(n )

) = (n

) = (n

) < cf (n)

= (n log n) = O(n log n)

= n log n = (n

,thirdcaseofMastertheorem

) = (n

f(

n(n+1)

n
2

) ,satisfiedforanypositive lessthan0.5 .Also,


,satisfiedforanyc between0 and0.5)

0.5+

< cn

,thirdcaseofMastertheorem

log 2 1+

) < cf (n)

) = (n
n
2

log

n
2

0.5+

,satisfiedforpositive = 0.5.Also,
,satisfiedforc = 0.5 )

< cn log n

(P)Likein(M),hereweareaddingthelogofthefirstnnaturalnumbers.So,
Tn = log 1 + log 2 + log 3+. . . . log n
= log(1 2 n)

= log(n!)

= n log n n + 1

(Stirling'sApproximation)

= O(n log n)

name

GATE2013_30top
Thenumberofelementsthatcanbesortedin(log n) timeusingheapsortis

log n

(A)(1) (B)(logn) (C)( log log n )(D)(log n)

log n

Tosortk elementsinaheap,complexityis(k log k) .Letsassumethereare log log n elementsintheheap.


log n

Complexity=( log log n


= (

log n
log log n

log n
log log n

))

(log log n log log log n))

= (log n

= (log n)

log(

log n log log log n


log log n

(asshownbelow)

So,(c)istheanswer.

log log n > log log log n

log log log n

log n log log log n

log log n

< 1

log log n

(log n

< log n

log n log log log n


log log n

) = (log n)

name

GATE2013_31top
http://gateoverflow.in/book

30/400

2/26/2015

GATEOverflow Book

Considerthefollowingfunction:
int unknown(int n){
int i, j, k=0;
for (i=n/2; i<=n; i++)
for (j=2; j<=n; j=j*2)
k = k + n/2;
return (k);
}

Thereturnvalueofthefunctionis
(A)(n 2 )(B)(n 2 log n) (C)(n 3 )(D)(n 3 log n)

Theouterloopisrunningforn/2timesandinnerloopisrunningforlog2ntimes(eachiterationdoublesjandjstopsatnmeanslog2ntimesjloopwill
iterate).
Nowineachiterationkisincrementedbyn/2.So,overallkwillbeaddedn/2*logn*n/2withaninitialvalueof0.So,finalvalueofkwillbe(n2logn)
name

GATE2013_43top
Thepreordertraversalsequenceofabinarysearchtreeis30,20,10,15,25,23,39,35,42.Whichoneofthefollowingisthepostordertraversalsequenceofthe
sametree?
(A)10,20,15,23,25,35,42,39,30
(B)15,10,25,23,20,42,35,39,30
(C)15,20,10,23,25,42,35,39,30
(D)15,10,23,25,20,35,42,39,30

Sinceitisabinarysearchtree,itsinordertraversalproducesasortedsequencei.e.10,15,20,23,25,30,35,39,42.
Nowgiveninorderandpreordertraversals,wegetfollowingtree:

Fromthis,wecangivepostordertraversalsequenceas15,10,23,25,20,35,42,39,30i.e.option(D).
name

GATE2013_50,51top
TheproceduregivenbelowisrequiredtofindandreplacecertaincharactersinsideaninputcharacterstringsuppliedinarrayA.Thecharacterstobereplaced
aresuppliedinarrayoldc,whiletheirrespectivereplacementcharactersaresuppliedinarraynewc.ArrayAhasafixedlengthoffivecharacters,whilearrays
oldcandnewccontainthreecharacterseach.However,theprocedureisflawed.
void find_and_replace (char *A, char *oldc, char *newc) {
for (int i=0; i<5; i++)
for (int j=0; j<3; j++)
if (A[i] == oldc[j]) A[i] = newc[j];
}

Theprocedureistestedwiththefollowingfourtestcases.
(1)oldc=abc,newc=dab(2)oldc=cde,newc=bcd
(3)oldc=bca,newc=cda(4)oldc=abc,newc=bac
Q.50Thetesternowteststheprogramonallinputstringsoflengthfiveconsistingofcharactersa,b,c,dandewithduplicatesallowed.Ifthetester
carriesoutthistestingwiththefourtestcasesgivenabove,howmanytestcaseswillbeabletocapturetheflaw?
(A)Onlyone(B)Onlytwo(C)Onlythree(D)Allfour

Q.51IfarrayAismadetoholdthestringabcde,whichoftheabovefourtestcaseswillbesuccessfulinexposingtheflawinthisprocedure?
(A)None(B)2only(C)3and4only(D)4only
http://gateoverflow.in/book

31/400

2/26/2015

GATEOverflow Book

Thetestcases3and4aretheonlycasesthatcapturetheflaw.Thecodedoesn'tworkproperlywhenanoldcharacterisreplacedbyanew
characterandthenewcharacterisagainreplacedbyanothernewcharacter.Thisdoesn'thappenintestcases(1)and(2),ithappensonlyin
cases(3)and(4).

50.B
51.C
name

GATE1998_1.22top

selectionsortO(n^2)
mergesortO(nlogn)
binarysearch(logn)
insertionsortO(n)noteifyouuseO(n^2)hereyouwillnotbeleftwithanychoicetofillselectionsort
name

GATE20141_11top
LetG beagraphwithn verticesandm edges.WhatisthetightestupperboundontherunningtimeofDepthFirstSearchonG ,whenG isrepresentedasan
adjacencymatrix?

(A)(n)
(B)(n + m)
(C)(n

(D)(m

Ans(C)
http://web.eecs.utk.edu/~huangj/CS302S04/notes/graphsearching.html
name

GATE20141_14top
LetP bequicksortprogramtosortnumbersinascendingorderusingthefirstelementasthepivot.Lett1 andt2 bethenumberofcomparisonsmadebyPforthe
inputs[12345]and[41532]respectively.Whichoneofthefollowingholds?
(A)t1

= 5

(B)t1

< t2

(C)t1

> t2

(D)t1

= t2

itwouldbet1>t2,becausethefirst case is the worst case of quicksort i.e. minimum number is chosen as pivot. Hence in the worst case the comparisons are high.
name
http://gateoverflow.in/book

32/400

2/26/2015

GATEOverflow Book

GATE2006_47top
Considerthefollowinggraph:

Whichoneofthefollowingcannotbethesequenceofedgesadded,inthatorder,toaminimumspanningtreeusingKruskalsalgorithm?
(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)(d f ), (a b), (b f ), (d e), (d c)

inkruskal'salgotheedgesareaddedinnondecreasingorderoftheirweight.ButinOptionDedgedewithweight3isaddedbeforeedgedcwithweight2.
HenceOptionDiswrongoption
name

GATE2006_51top
Considerthefollowingrecurrence:

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

Whichoneofthefollowingistrue?
(A)T (n)

= (log log n)

(B)T (n)

= (log n)

(C)T (n)

= (n )

(D)T (n)

= (n)

T (n) = 2T (n

) + 1

= 2(T (n

) + 1) + 1

= 2 T (n

= 4 T (n

) + 3

1
3

) + 5

= 2

(lg lg n)

+ 2 lg lg n + 1(Proved below)
= O(lg n)

http://gateoverflow.in/book

= 2

33/400

2/26/2015

GATEOverflow Book
1

= 2

(Putting 2 so that we can take log.


One more step of recurrence can't change the complexity.)
1
2

lg n = 1(Taking log both sides)

lg n = 2

k = lg lg n

name

GATE2006_54top
Giventwoarraysofnumbersa1 , . . . , an andb1 , . . . , bn whereeachnumberis0 or1 ,thefastestalgorithmtofindthelargestspan(i, j)suchthat
ai + ai+1 +. . . . aj = bi + bi+1 +. . . . . bj orreportthatthereisnotsuchspan,
(A)Takes0(3 n )and(2 n ) timeifhashingispermitted
(B)Takes0(n 3 )and(n 2.5 ) timeinthekeycomparisonmode
(C)Takes(n) timeandspace

(D)TakesO(n ) timeonlyifthesumofthe2n elementsisanevennumber

Answeris(C).Followingalgorithmwoulddo.
#include <stdio.h>
#define size 100 //assume n is less than 100
int main()
{
int n, a[size], b[size];
int start[2*size], end[2*size];
int sum1 = 0, sum2 = 0, i;
int diff[size];
printf("Enter n: ");
scanf("%d", &n);
for(i = 0; i < n; i++)
{
printf("Enter a[%d]: ", i);
scanf("%d", &a[i]);
}
for(i = 0; i < n; i++)
{
printf("Enter b[%d]: ", i);
scanf("%d", &b[i]);
}
for(i = 0; i < n; i++)
{
if(a[i]) sum1++;
if(b[i]) sum2++;
diff[i] = sum1 - sum2;
}
for(i = 0; i < 2*n; i++)
start[i] = -1;

start[n] = end[n] = 0; //initially sum is 0 at the beginning of array and the first n-1 elements of start and end are used if sum of
for(i=0; i < n; i++)
{
if(start[diff[i] + n] == -1)
start[diff[i] + n] = i;
end[diff[i] + n] = i;
}
int max = -1;
int savei = -1; //savei is for storing the sum having the largest span
for(i = 0; i < 2*n; i++)
{
if(start[i] > -1 && (end[i] - start[i] > max))
{
max = end[i] - start[i];
savei = i;
}

http://gateoverflow.in/book

34/400

2/26/2015

GATEOverflow Book
}
if(savei >= 0)
{
printf("The largest span is from %d to %d\n", start[savei]+(savei != n), end[savei]);

//when sum zero is having the largest span, span starts from first element itself. Else, the span starts from the next element from w
}
else
{
printf("No span\n");
}
}

name

GATE2008_42top
G
G

isagraphonn verticesand2n 2 edges.TheedgesofG canbepartitionedintotwoedgedisjointspanningtrees.WhichofthefollowingisNOTtruefor


?
a. Foreverysubsetofk vertices,theinducedsubgraphhasatmost2k 2edges.
b. TheminimumcutinG hasatleast2edges.
c. Thereareatleast2edgedisjointpathsbetweeneverypairofvertices.
d. Thereareatleast2vertexdisjointpathsbetweeneverypairofvertices.

Thereare2spanningtreesforG whichareedgedisjoint.Aspanningtreeforn nodesrequiren 1edgesandso2edgedisjointspanningtreesrequires


2n 2 edges.AsG hasonly2n 2 edges,itisclearthatitdoesn'thaveanyedgeoutsidethatofthetwospanningtrees.Nowletsseethecases:
LetstakeanysubgraphofG withk vertices.Theremainingsubgraphwillhaven 2vertices.Betweenthesetwosubgraphs(providedbothhasatleastone
vertex)thereshouldbeatleast2edges,aswehave2spanningtreesinG .So,(b)isTRUE.Also,inthesubgraphwithk vertices,wecannothavemorethan
2k 2edgesasthiswouldmeanthatintheothersubgraphwithn k vertices,wewouldhavelessthan2n 2k edges,making2spanningtrees
impossibleinit.So,(a)isalsoTRUE.
Aspanningtreecoversallthevertices.So,2edgedisjointspanningtreesinG means,betweeneverypairofverticesinG wehavetwoedgedisjointpaths
(lengthofpathsmayvary).So,(c)isalsoTRUE.
So,thatleavesoption(d)asanswer.Itisnotquitehardtogiveacounterexamplefor(d).
name

GATE20141_38top
Supposeapolynomialtimealgorithmisdiscoveredthatcorrectlycomputesthelargestcliqueinagivengraph.Inthisscenario,whichoneofthefollowing
representsthecorrectVenndiagramofthecomplexityclassesP,NPandNPComplete(NPC)?

(A)

(B)
http://gateoverflow.in/book

35/400

2/26/2015

GATEOverflow Book

(C)

(D)

CliqueisinNPC.BydefinitionofNPC,allNPproblemscanbereducedtoCliqueinpolynomialtime.So,ifcliquecanbesolvedinpolynomialtime,any
NPproblemcanalsobesolvedinpolynomialtimemakingP=NPandhenceP=NP=NPC.
http://gatecse.in/wiki/NP,_NP_Complete,_NP_Hard
name

GATE20141_41top
ConsiderthefollowingCfunctioninwhichsizeisthenumberofelementsinthearrayE:
int MyX(int *E, unsigned int size)
{
int Y = 0;
int Z;
int i, j, k;
for(i = 0; i< size; i++)
Y = Y + E[i];

for(i=0; i < size; i++)


for(j = i; j < size; j++)
{
Z = 0;
for(k = i; k <= j; k++)
Z = Z + E[k];
if(Z > Y)
Y = Z;
}
return Y;

ThevaluereturnedbythefunctionMyXisthe
(A)maximumpossiblesumofelementsinanysubarrayofarrayE.
(B)maximumelementinanysubarrayofarrayE.
(C)sumofthemaximumelementsinallpossiblesubarraysofarrayE.
(D)thesumofalltheelementsinthearrayE.

answeris(A)maximumpossiblesumofelementsinanysubarrayofarrayE.
intMyX(int*E,unsingedintsize)
{
intY=0
intz
http://gateoverflow.in/book

36/400

2/26/2015

GATEOverflow Book

inti,j,k
fori0i<sizei++)//calculatesumoftheelements
Y=Y+E[i]//ofthearrayEandstoresitinY
for(i=0i<sizei++)//calculatethe
for(j=ij<sizej++)//sumof
{//elementsof
z=0//allpossible
for(k=ik<=jk++)//subarrays
z=z+E[k]//ofE
if(z>Y)//checkswhethersumofelementsofeachsubarrayisgreaterthanthesumofarrayif//so,thatsumisassignedtoY
willbethesumofelementsofcompletearray
Y=z
}
returnY//ultimatelyreturnsthemaximumpossiblesumofelementsinanysubarrayofgivenarrayE
}

name

GATE20141_42top
Considerthefollowingpseudocode.Whatisthetotalnumberofmultiplicationstobeperformed?
D=2
for i = 1 to n do
for j = i to n do
for k = j + 1 to n do
D=D*3

(A)Halfoftheproductofthe3consecutiveintegers.
(B)Onethirdoftheproductofthe3consecutiveintegers.
(C)Onesixthoftheproductofthe3consecutiveintegers.
(D)Noneoftheabove.

Totalnumberofmultiplications

Therefore,correctanswerwouldbe(C).
name

GATE20142_38top
http://gateoverflow.in/book

37/400

2/26/2015

GATEOverflow Book

SupposeP,Q,R,S,Taresortedsequenceshavinglengths20,24,30,35,50respectively.Theyaretobemergedintoasinglesequencebymergingtogethertwo
sequencesatatime.Thenumberofcomparisonsthatwillbeneededintheworstcasebytheoptimalalgorithmfordoingthisis____.

Theoptimalalgorithmalwayschoosesthesmallestsequencesformerging.
202444,43comparisons
303565,64comparisons
445094,93comparisons
6594159,158comparisons

so,totally43+64+93+158=358comparisons.

name

GATE20143_10top
LetA bethesquarematrixofsizen n.Considerthefollowingpseudocode.Whatistheexpectedoutput?
C=100;
for i=1 to n do
for j=1 to n do
{
Temp = A[i][j]+C;
A[i][j] = A[j][i];
A[j][i] = Temp -C;
}
for i=1 to n do
for j=1 to n do
output (A[i][j]);

(A)ThematrixAitself
(B)TransposeofthematrixA
(C)Adding100totheupperdiagonalelementsandsubtracting100fromlowerdiagonalelementsofA
(D)Noneoftheabove

A.
InthecomputationofgivenpseudocodeforeachrowandcolumnofMatrixA,eachupper
triangularelementwillbeinterchangedbyitsmirrorimageinthelowertriangularandafter
thatthesamelowertriangularelementwillbeagainreinterchangedbyitsmirrorimagein
theuppertriangular,resultingthefinalcomputedMatrixAsameasinputMatrixA.
name

GATE20143_12top
ConsiderthefollowingrootedtreewiththevertexlabeledPastheroot:

Theorderinwhichthenodesarevisitedduringaninordertraversalofthetreeis
(A)SQPTRWUV
(B)SQPTUWRV

http://gateoverflow.in/book

38/400

2/26/2015

GATEOverflow Book
(C)SQPTWUVR
(D)SQPTRUWV

A.
theinordertraversalorderofaternarytreeisleft>root>middle>right.
name

GATE20143_13top
Suppose depth first search is executed on the graph below starting at some unknown vertex. Assume that a recursive call to visit a vertex is made only after first
checkingthatthevertexhasnotbeenvisitedearlier.Thenthemaximumpossiblerecursiondepth(includingtheinitialcall)is_________.

19.applyDFS.
name

GATE20143_14top
Youhaveanarrayof n elements.Supposeyouimplementquicksortbyalwayschoosingthecentralelementofthearrayasthepivot.Thenthetightestupperbound
fortheworstcaseperformanceis
(A)O(n

(B)O(n log n)
(C)(n log n)
(D)O(n 3 )

(A)O(n 2 ) istheanswer.Whenwechoosethefirstelementasthepivot,theworstcaseofquicksortcomesiftheinputissortedeitherinascendingor
descendingorder.Now,whenwechoosethemiddleelementaspivot,sortedinputlongergivesworstcasebehaviour.But,therewillbesomepermutationof
theinputnumberswhichwillbegivingthesameworstcasebehaviour.Forexample,
1234567
Thisarraygivesworstcasebehaviourforquicksortwhenthefirstelementispivot.
6421357
ThisarraygivestheworstcasebehaviourofO(n 2 ) ifwetakemiddleelementasthepivoteachsplitwillbe1elementononesideandn1elementson
otherside.Similarly,foranyinput,wecanhaveapermutationwherethebehaviourislikethis.So,whicheverelementwetakeaspivotitgivesworstcase
complexityofO(n 2 ) aslongaspivotisfromafixedposition(notrandompositionasinrandomizedquicksort).
name

GATE20143_37top
Supposeyouwanttomovefrom0 to100onthenumberline.Ineachstep,youeithermoverightbyaunitdistanceoryoutakeashortcut.Ashortcutissimplyapre
specifiedpairofintegersi, j with i < j .Givenashortcut i, j ifyouareatposition i onthenumberline,youmaydirectlymoveto j .Suppose T (k)denotesthe
smallestnumberofstepsneededtomovefrom k to100.Supposefurtherthatthereisatmost1shortcutinvolvinganynumber,andinparticularfrom9thereisa
shortcutto15.Lety andz besuchthatT (9) = 1 + min(T (y), T (z)).Thenthevalueoftheproductyz is_____.

T(9)=Distancefrom9to100
T(9)=1+min(T(y),T(z))=1+min(Distancefromyto100,Distancefromzto100)
Thereareonlytwosuchvalueswherewecanreachfrom9,oneissimplesteptorightonnumberline,i.e10andanotheris15(givenshortcut)
Hence,y=10,z=15
yz=10x15=150
name

http://gateoverflow.in/book

39/400

2/26/2015

GATEOverflow Book

GATE2011_25top
AnalgorithmtofindthelengthofthelongestmonotonicallyincreasingsequenceofnumbersinanarrayA[0

: n 1]

isgivenbelow.

LetLi ,denotethelengthofthelongestmonotonicallyincreasingsequencestartingatindexi inthearray.


InitializeLn1

= 1

Foralli suchthat0
Li = {

i n 2

1 + L i+1
1

if A[i] < A[i+1]


Otherwise

FinallythethelengthofthelongestmonotonicallyincreasingsequenceisMax (L0 , L1 , , Ln1 ).


WhichofthefollowingstatementsisTRUE?
(A)Thealgorithmusesdynamicprogrammingparadigm
(B)Thealgorithmhasalinearcomplexityandusesbranchandboundparadigm
(C)Thealgorithmhasanonlinearpolynomialcomplexityandusesbranchandboundparadigm
(D)Thealgorithmusesdivideandconquerparadigm

(A)istheanswer.
Thealgorithmisstoringtheoptimalsolutionstosubproblemsateachpoint(foreachi),andthenusingittoderivetheoptimalsolutionofabiggerproblem.
Andthatisdynamicprogrammingapproach.Andtheprogramhaslineartimecomplexity.
http://stackoverflow.com/questions/1065433/whatisdynamicprogramming
Now,branchandboundcomeswhenweexploreallpossiblesolutions(branch)andbacktracksassoonaswefindwewon'tgetasolution(inclassical
backtrackingwewillretreatonlywhenwewon'tfindthesolution).So,backtrackinggivesallpossiblesolutionswhilebranchandboundwillgiveonlythe
optimalone.http://www.cs.cornell.edu/~wdtseng/icpc/notes/bt2.pdf
Thegivenalgorithmhereisneitherbacktrackingnorbranchandbound.Becausewearenotbranchinganywhereinthesolutionspace.
Andthealgorithmisalsonotdivideandconqueraswearenotdividingtheproblemandthenmergingthesolutionasinthecaseofmergesort(wheremerge
istheconquerstep).
https://en.wikipedia.org/wiki/Divide_and_conquer_algorithms
name

GATE2011_37top
Whichofthegivenoptionsprovidestheincreasingorderofasymptoticcomplexityoffunctionsf 1 , f 2 , f 3 andf 4 ?
f 1 (n) = 2

f 2 (n) = n

3/2

f 3 (n) = n log 2 n
f 4 (n) = n

log 2 n

(A)f 3 , f 2 , f 4 , f 1
(B)f 3 , f 2 , f 1 , f 4
(C)f 2 , f 3 , f 1 , f 4
(D)f 2 , f 3 , f 4 , f 1

[EDIT]
answerA
nlog2n<n3/2isquitestraightforward
alson3/2<nlog2nandn3/2<2n
nowonlynlog2nand2nneedtobecompared
takinglogofboth(log2n)2andn
n>(log2n)2
http://gateoverflow.in/book

40/400

2/26/2015

GATEOverflow Book

hence2n>nlog2n
name

GATE2010_34top
n1

The weight of a sequence a0 , a1 , , an1 of real numbers is defined as a0 + a1 /2 + + an1 /2


. A subsequence of a sequence is obtained by
deletingsomeelementsfromthesequence,keepingtheorderoftheremainingelementsthesame.LetX denotethemaximumpossibleweightofasubsequenceof
ao , a1 , , an1 andY themaximumpossibleweightofasubsequenceofa1 , a2 , , an1 .ThenX isequalto
(A)max(Y , a0

+ Y)

(B)max(Y , a0

+ Y /2)

(C)max(Y , a0

+ 2Y )

(D)a0

+ Y /2

Twopossiblecasesarise:
1.

isincludedinthemaxweightsubsequenceof :

Inthiscase,

2.

isnotincludedinthemaxweightsubsequenceof :

Inthiscase,

Sincethevalueof canbenegative

,itispossiblethat

Themaximumpossibleweightofasubsequenceof isgivenby:

name

GATE1997_4.6top

answerB
usingmastermethod(case1)
wherea=2,b=2
O(n1/2)<O(nlogba)
O(n1/2)<O(nlog22)

name

GATE1993_7.4top

http://gateoverflow.in/book

41/400

2/26/2015

GATEOverflow Book

AnswerissimplyAi.e.itswapsthevaluesofthetwo..TakeanytwovaluesforAandB.andperformthegivenoperationsoverthem.
name

GATE2010_35top
WhatisthevalueprintedbythefollowingCprogram?
#include<stdio.h>
int f(int *a, int n)
{
if (n <= 0) return 0;
else if (*a % 2 == 0) return *a+f(a+1, n-1);
else return *a - f(a+1, n-1);
}
int main()
{
int a[] = (12, 7, 13, 4, 11, 6);
printf("%d", f(a, 6));
return 0;
}

(A)9
(B)5
(C)15
(D)19

Itwillprint
12+(7(13(4+(11(6+0)))))
=12+(7(13(4+(116)))))
=12+713+9
=15
gatecse

GATE2010_36top
ThefollowingCfunctiontakesasinglylinkedlistasinputargument.Itmodifiesthelistbymovingthelastelementtothefrontofthelistandreturnsthemodifiedlist.
Somepartofthecodeisleftblank.
typedef struct node {
int value;
struct node *next;
} node;
Node *move_to-front(Node *head) {
Node *p, *q;
if ((head == NULL) || (head -> next == NULL)) return head;
q = NULL; p = head;
while (p->next != NULL){
q=p;
p=p->next;
}
_______________
}

return head;

Choosethecorrectalternativetoreplacetheblankline.
(A)q=NULLp>next=headhead=p
(B)q>next=NULLhead=pp>next=head

http://gateoverflow.in/book

42/400

2/26/2015

GATEOverflow Book

(C)head=pp>next=qq>next=NULL
(D)q>next=NULLp>next=headhead=p

aspergivencodeppointstolastnodewhichshouldbeheadinmodified.
qisthepreviousnodeoftailwhichshouldbetailformodified
answerD
name

GATE2010_50,51top
Consideracompleteundirectedgraphwithvertexset{0,1,2,3,4}.EntryW ij inthematrixW belowistheweightoftheedge{i,j}

Q.50WhatistheminimumpossibleweightofaspanningtreeT inthisgraphsuchthatvertex0isaleafnodeinthetreeT ?
(A)7
(B)8
(C)9
(D)10

Q.51WhatistheminimumpossibleweightofapathP fromvertex1tovertex2inthisgraphsuchthatP containsatmost3edges?


(A)7
(B)8
(C)9
(D)10

http://gateoverflow.in/book

43/400

2/26/2015

GATEOverflow Book

Answerfor50is(D)10.Theedgesofthespanningtreeare:01,13,34,42.TotalWeight=10
Answerfor51is(B)8.Thepossiblepathis:10,04,42.
name

GATE1994_1.7top

ItisA.searchingforonlyonehalfofthelist.leadingtoT(n/2)+constanttimeincomparingandfindingmidelement.
name

GATE1994_1.11top

J+(sumofnaturalnumbertilli1)becauseifyouformalowertriangularmatrixitcontainselementsinrows1,2,3,...socisthecorrectanswer
name

GATE1994_1.17top

B.Becauseinbinarysearchweneedtohaveaccesstothemidofthelistinconstanttime.andfindingthemiditselfinalinkedlisttakesO(n)timewhich
makesnosensetoBinarysearchwhichtakesO(logn).
name

GATE1994_1.19top

C.itisoneoftheefficientalgorithmsinDivideandConquerstrategy.
name

GATE1994_1.23top

http://gateoverflow.in/book

44/400

2/26/2015

GATEOverflow Book

Forcomplexity,weassumesufficientlylargen.So,g1(n)=n2andg2(n)=n3.Growthrateofg1islessthanthatofg2.i.e.,g1(n)=O(g2(n))
name

GATE1994_6top

answerxn
name

GATE1994_25top

i=1
j=n
while(i!=j){
if(A[i]+A[j]==M)break
elseif(A[i]+A[j]<M)i++
elsej[EDIT]
}
name

GATE1995_1.5top

http://gateoverflow.in/book

45/400

2/26/2015

GATEOverflow Book

ItisA.
OneofthebestexamplesofDivideandconquerstrategy.
name

GATE1995_1.16top

ItisC.
Thenumberofmovesarehoweveralwaysm+nsothatwecantermitastheta(m+n).Butthenumberofcomparisonsvaryaspertheinput.Inthebestcase
thecomparisonsareMin(m,n)andinworstcasetheyarem+n1.
name

GATE1995_2.9top

C.
concat(a,head(tail(tail(acbc))))
concat(a,head(tail(cbc)))
concat(a,head(bc))
concat(a,b)
ab.
name

GATE1995_2.22top

ItsDaccordingtome.
BinarysearchusinglinkedlistisnotefficientasitwillnotgiveO(logn),becausewewillnotbeabletofindthemidinconstanttime.Findingmidinlinked
listtakesO(n)time.
Recursiveprogramsarenotefficientbecausetheytakealotofspace,RecursivemethodswilloftenthrowStackOverflowExceptionwhileprocessingbigsets.
moreoverithasitsownadvantagestoo.
name

GATE1995_12top

http://gateoverflow.in/book

46/400

2/26/2015

GATEOverflow Book

1stPass:375212112592
2ndPass:371211255292
3rdPass:121125375292
4thPass:111225375292
5thPass:111225375292
name

GATE1995_22top

2only.
{AB,BC,AE,BD}and{AB,BC,AE,CD}.
name

GATE1996_2.13top
Theaveragenumberofkeycomparisonsdoneonasuccessfulsequentialsearchinalistoflengthn is
(a)log n
(b) n1
2
(c) n2
(d)

n+1
2

Expectednumberofcomparisons
=1 Probabilityoffirstelementbex+2 Probabilityofsecondelementbex+....+n Probabilityoflastelementbex.
1

= 1

1
n

+ 2

2
n

3
n

n1
n

+. . . . +

1
n1

+. . . . . +n

n1
n

n2
n1

...

1
2

n
n

n(n+1)

)
2

n+1
2

name

GATE1996_2.15top

C.
botharetheworstcasesofquicksort.
i)issortedinascendingorder.

http://gateoverflow.in/book

47/400

2/26/2015

GATEOverflow Book

ii)issortedindescendingorder.
name

GATE2008IT_11top
ForproblemsXandY,YisNPcompleteandXreducestoYinpolynomialtime.WhichofthefollowingisTRUE?

A)
B)
C)
D)

IfXcanbesolvedinpolynomialtime,thensocanY
XisNPcomplete
XisNPhard
XisinNP,butnotnecessarilyNPcomplete
Wecan'tsayXisNPhardunlessuntilXisalsoaNPcomplete.XcanbeNPcompleteorbelowit..thatmeansitbelongstoNPclass,inthatclass(inNP
class)itmaybeNPcomplete..soXisNPforsurebutmaybeNPcomplete(butnotneccessary)..sooption(D)...
name

GATE2008IT_12top
WhichofthefollowingisTRUE?

1)
2)
3)
4)

ThecostofsearchinganAVLtreeis(logn)butthatofabinarysearchtreeisO(n)
ThecostofsearchinganAVLtreeis(logn)butthatofacompletebinarytreeis(nlogn)
ThecostofsearchingabinarysearchtreeisO(logn)butthatofanAVLtreeis(n)
ThecostofsearchinganAVLtreeis(nlogn)butthatofabinarysearchtreeisO(n)

1)istrueasAVLtreeisabalancedsearchtreethathastimecomplexityofsearching
skewedtree,inwhichsearchisO(n).

,butinbinarysearchtree,wecanhaveacompletelyleft/right

name

GATE2007IT_27top
Thefunctionfisdefinedasfollows:

int f (int n) {
if (n <= 1) return 1;
else if (n % 2 == 0) return f(n/2);
else return f(3n - 1);
}

Assumingthatarbitrarilylargeintegerscanbepassedasaparametertothefunction,considerthefollowingstatements.
i. Thefunctionfterminatesforfinitelymanydifferentvaluesofn1.
ii. Thefunctionfterminatesforinfinitelymanydifferentvaluesofn1.
iii. Thefunctionfdoesnotterminateforfinitelymanydifferentvaluesofn1.
iv. Thefunctionfdoesnotterminateforinfinitelymanydifferentvaluesofn1.
Whichoneofthefollowingoptionsistrueoftheabove?

A)
B)
C)
D)

(i)and(iii)
(i)and(iv)
(ii)and(iii)
(ii)and(iv)

Thefunctionterminatesforallpowersof2(whichisinfinite),hence(i)isfalseand(ii)isTRUE.
Letn=5.
Now,recursivecallswillgolike514720105
Andthisgoesintoinfiniterecursion.Andifwemultiply5withanypowerof2,alsoresultwillbeinfiniterecursion.Since,thereareinfinitepowersof2
possible,thereareinfiniterecursionspossible(evenconsideringthiscaseonly).So,(iv)isTRUEand(iii)isfalse.
So,correctansweris(D)

http://gateoverflow.in/book

48/400

2/26/2015

GATEOverflow Book

name

GATE2006IT_10top
AprobleminNPisNPcompleteif

A)
B)
C)
D)

itcanbereducedtothe3SATprobleminpolynomialtime
the3SATproblemcanbereducedtoitinpolynomialtime
itcanbereducedtoanyotherprobleminNPinpolynomialtime
someprobleminNPcanbereducedtoitinpolynomialtime

(B)AprobleminNPbecomesNPCifallNPproblemscanbereducedtoitinpolynomialtime.ThisissameasreducinganyoftheNPCproblemtoit.3
SATbeinganNPCproblem,reducingittoaNPproblemwouldmeanthatNPproblemisNPC.
http://gatecse.in/wiki/NP,_NP_Complete,_NP_Hard
name

GATE2004IT_13top
LetPbeasinglylinkedlist.LetQbethepointertoanintermediatenodexinthelist.Whatistheworstcasetimecomplexityofthebestknownalgorithmto
deletethenodexfromthelist?

A)

O(n)

B)

O(log2n)
O(logn)
O(1)

C)
D)

Intheworstcasexcouldbelastorsecondlastnode,Inthatcasefulltraversalofthelistisrequired.Thereforeansweris(A).
name

GATE2004IT_52top
Aprogramattemptstogenerateasmanypermutationsaspossibleofthestring,'abcd'bypushingthecharactersa,b,c,dinthesameorderontoastack,butit
maypopoffthetopcharacteratanytime.WhichoneofthefollowingstringsCANNOTbegeneratedusingthisprogram?

A)
abcd
B)
dcba
C)
cbad
D)
cabd
A.pusha&popa,pushb&popb,pushc&popc,andfinallypushdandpopd
sequenceofpoppedelementswillcometoabcd
B.firstpushabcd,andafterthatpoponebyonesequenceofpoppedelementswillcometodcba
C.pushabc,andafterthatpoponebyonesequenceofpoppedelementswillcometocba,nowpushdandpopd,finalsequencecomestocbad
D.thissequenceisnotpossiblebecause'a'cannotbepoopedbefore'b'anyhow
name

GATE2004IT_57top
Consideralistofrecursivealgorithmsandalistofrecurrencerelationsasshownbelow.Eachrecurrencerelationcorrespondstoexactlyonealgorithmandis
usedtoderivethetimecomplexityofthealgorithm.

P.
Q.
R.
S.

RecursiveAlgorithm
Binarysearch
Mergesort
Quicksort
TowerofHanoi

I.
II.
III.
IV.

RecurrenceRelation
T(n)=T(nk)+T(k)+cn
T(n)=2T(n1)+1
T(n)=2T(n/2)+cn
T(n)=T(n/2)+1

Whichofthefollowingisthecorrectmatchbetweenthealgorithmsandtheirrecurrencerelations?
http://gateoverflow.in/book

49/400

2/26/2015

GATEOverflow Book

A)
B)
C)
D)

PII,QIII,RIV,SI
PIV,QIII,RI,SII
PIII,QII,RIV,SI
PIV,QII,RI,SIII
answerB
name

GATE2004IT_58top
ConsiderthefollowingCprogramwhichissupposedtocomputethetransposeofagiven4x4matrixM.Notethat,thereisanXintheprogramwhichindicates
somemissingstatements.ChoosethecorrectoptiontoreplaceXintheprogram.

#include<stdio.h>
#define ROW 4
#define COL 4
int M[ROW][COL] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
main()
{
int i, j, t;
for (i = 0; i < 4; ++i)
{
X
}
for (1 = 0; i < 4; ++i)
for (j = 0; j < 4; ++j)
printf ("%d", M[i][j]);
}

for(j = 0; j < 4; ++j){


t = M[i][j];
M[i][j] = M[j][i];
M[j][i] = t;
}

A)

for(j = 0; j < 4; ++j){


M[i][j] = t;
t = M[j][i];
M[j][i] = M[i][j];
}

B)

for(j = i; j < 4; ++j){


t = M[i][j];
M[i][j] = M[j][i];
M[j][i] = t;
}

C)

for(j = i; j < 4; ++j){


M[i][j] = t;
t = M[j][i];
M[j][i] = M[i][j];
}

D)

optionC:
lookattheinitialvalueofj,ifjstartswith0,thendoubleforloopwillswapM[i][j]withM[j][i]andalsoM[j][i]andM[i][j]sothematrix
Mwillremainunchanged,sotoavoidthisdoubleswappingweneedtoinitializej=iandswaponlyuppertriangularmatrixwithlowertriangularmatrix.

http://gateoverflow.in/book

50/400

2/26/2015

GATEOverflow Book

for(j=ij<4++j){
//codeforswappingM[i][j]withM[j][i]
t=M[i][j]
M[i][j]=M[j][i]
M[j][i]=t
}
name

GATE2005IT_53top
The following C function takes two ASCII strings and determines whether one is an anagram of the other. An anagram of a string s is a string obtained by
permutingthelettersins.
int anagram (char *a, char *b) {
int count [128], j;
for (j = 0; j < 128; j++) count[j] = 0;
j = 0;
while (a[j] && b[j]) {
A;
B;
}
for (j = 0; j < 128; j++) if (count [j]) return 0;
return 1;
}

ChoosethecorrectalternativeforstatementsAandB.

A)
B)
C)
D)

A:count[a[j]]++andB:count[b[j]]
A:count[a[j]]++andB:count[b[j]]++
A:count[a[j++]]++andB:count[b[j]]
A:count[a[j]]++andB:count[b[j++]]

TheanswerisD
#include <stdio.h>
int main(void) {
return 0;
}
int anagram (char *a, char *b) {
/*
ASCII characters are of 7-bits
so we use count array to represent all the ASCII characters
(ranging 0-127)
*/
int count [128], j;
/*
so this loop will initialize count of all the ASCII characters to be
0 (zero)
*/
for (j = 0; j < 128; j++) count[j] = 0;
j = 0;
/*
"a[j] && b[j]" ensures that anagram returns 0 (false) in case both
strings have different length. Because different length strings cannot
be anagram of each other
*/
/*
Logic:
Below while loop increments ASCII equivalent position for its occurence
in array 'a'in count array; and decrements ASCII equivalent position
for its occurence in array 'b'in count array.
Example: a = "ISS" and b = "SIS"
ASCII equivalent of:
I - 73
S - 83
j = 0: Statement A will increment count[ASCII of 'I']==>count[73]
count[73] = 0 --> 1
Statement B will decrement count[ASCII of 'S'] ==> count[83]
count[83] = 0 --> -1 and will increment j
j = 0 --> 1
j = 1: Statement A will increment count[ASCII of 'S'] ==> count[83]
count[83] = -1 --> 0

http://gateoverflow.in/book

51/400

2/26/2015

GATEOverflow Book

Statement B will decrement count[ASCII of 'I'] ==> count[73]


count[73] = 1 --> 0 and will increment j
j = 1 --> 2
j = 2: Statement A will increment count[ASCII of 'S'] ==> count[83]
count[83] = 0 --> 1
Statement B will decrement count[ASCII of 'S'] ==> count[83]
count[83] = 1 --> 0 and will increment j
j = 2 --> 3
*** END OF LOOP ***
*/
while (a[j] && b[j]) {
A;

//count [a[j]]++

/*
Note: j will be increment after count[]-- will execute
Resource: http://www.c4learn.com/c-programming/increment-operator-inside-printf
*/
B;
//count[b[j++]]-}
/*
This loop checks that the number of occurences of the individual ASCII
characters is same or not.
If count[i] = 0 ---> same number of occurences for ASCII chracter i
---> return 1 (true)
if count[i]!= 0 ---> different number of occurences for ASCII chracter i
---> return 0 (false)
*/
for (j = 0; j < 128; j++) if (count [j]) return 0;
return 1;
}

name

GATE2005IT_57top
Whatistheoutputprintedbythefollowingprogram?
#include <stdio.h>
int f(int n, int k) {
if (n == 0) return 0;
else if (n % 2) return f(n/2, 2*k) + k;
else return f(n/2, 2*k) - k;
}
int main () {
printf("%d", f(20, 1));
return 0;
}

A)
B)
C)
D)

5
8
9
20
Thesequencehastobefollowed.
6.)f(20,1)=9.
5.)f(10,2)1=9
4.)f(5,4)2=10
3.)f(2,8)+4=12
2.)f(1,16)8=8
1.)f(0,32)+16=16
name

GATE2005IT_58top
Let a be an array containing n integers in increasing order. The following algorithm determines whether there are two distinct numbers in the array whose
differenceisaspecifiednumberS>0.
i = 0; j = 1;

http://gateoverflow.in/book

52/400

2/26/2015

GATEOverflow Book

while (j < n ){
if (E) j++;
else if (a[j] - a[i] == S) break;
else i++;
}
if (j < n) printf("yes") else printf ("no");

ChoosethecorrectexpressionforE.

A)
B)
C)
D)

a[j]a[i]>S
a[j]a[i]<S
a[i]a[j]<S
a[i]a[j]>S

Answeris(B)
Forsome'i'ifwefindthatdifferenceof(A[j]A[i]<S)weincrement'j'tomakethisdifferencewidersothatitbecomesequaltoS.
IfattimesdifferencebecomesgreaterthanSweknowthatitwontreducefurtherforsame'i'andsoweincrementthe'i'.
Wedoitforeach'i'ifnotfoundinpreviousiteration.untili=n
name

GATE2005IT_59top
Letaandbbetwosortedarrayscontainingnintegerseach,innondecreasingorder.Letcbeasortedarraycontaining2nintegersobtainedbymergingthetwo
arraysaandb.Assumingthearraysareindexedstartingfrom0,considerthefollowingfourstatements
I. a[i]b[i]=>c[2i]a[i]
II. a[i]b[i]=>c[2i]b[i]
III. a[i]b[i]=>c[2i]a[i]
IV. a[i]b[i]=>c[2i]b[i]
WhichofthefollowingisTRUE?

A)
B)
C)
D)

onlyIandII
onlyIandIV
onlyIIandIII
onlyIIIandIV
a[i]b[i]
Sincebothaandbaresortedinthebeginning,thereareielementssmallerthana[i](istartsfrom0),andsimilarlyielementssmallerthanb[i].So,a[i]b[i]
meansthereare2ielementssmallerthana[i],andhenceinthemergedarraya[i]cancomeonlyafterthese2ielements(itsindexwillbe>2i).So,c[2i]a[i]
(equalityonlycomeswhenarraycontainsrepeatedelements)
Similarly,a[i]b[i]saysforbthat,therearenotmorethan2ielementssmallerthanb[i]inthesortedarray(ielementsfromb,andmaximumanotheri
elementsfroma).So,b[i]c[2i]
So,IIandIIIarecorrect>option(C)
name

GATE2005IT_84atop
Asinkinadirectedgraphisavertexisuchthatthereisanedgefromeveryvertexjitoiandthereisnoedgefromitoanyothervertex.AdirectedgraphG
withnverticesisrepresentedbyitsadjacencymatrixA,whereA[i][j]=1ifthereisanedgedirectedfromvertexitojand0otherwise.Thefollowing
algorithmdetermineswhetherthereisasinkinthegraphG.

i = 0;
do {
j = i + 1;
while ((j < n) && E1) j++;
if (j < n) E2;
} while (j < n);
flag = 1;
for (j = 0; j < n; j++)
if ((j! = i) && E3) flag = 0;

http://gateoverflow.in/book

53/400

2/26/2015

GATEOverflow Book

if (flag) printf("Sink exists");


else printf ("Sink does not exist");

ChoosethecorrectexpressionsforE1andE2

A)

E1:A[i][j]andE2:i=j

B)

E1:!A[i][j]andE2:i=j+1

C)

E1:!A[i][j]andE2:i=j

D)

E1:A[i][j]andE2:i=j+1

Ifthereisasinkinthegraph,theadjacencymatrixwillcontainall1's(exceptdiagonal)inonecolumnandall0's(exceptdiagonal)inthecorrespondingrowof
thatvertex.ThegivenalgorithmisasmartwayofdoingthisasitfindsthesinkinO(n) timecomplexity.
Thefirstpartofthecode,isfindingifthereisanyvertexwhichdoesn'thaveanyoutgoingedgetoanyvertexcomingafteritinadjacencymatrix.Thesmart
partofthecodeisE2,whichmakesrowsskipwhenthereisnoedgefromitoit,makingitimpossiblethemtoformasink.Thisisdonethrough
E1:!A[i][j]
and
E2:i=j
E1makessurethatthereisnoedgefromitojandiisapotentialsinktillA[i][j]becomes1.IfA[i][j]becomes1,icannolongerbeasink,similarlyall
previousjcanalsonotbeasink(astherewasnoedgefromitothemandasinkrequiresanedgefromallothervertices).Now,thenextpotentialcandidate
forsinkisj.So,inE2,wemustmakei=j.
So,answeris(C)
ForE3,
http://gateoverflow.in/3857/gate2005it_84b
name

B+TreesProblemtop
ConstructaB+treeforthefollowingsetofkeyvalues:
(2,3,5,7,11,17,19,23,29,31)
Assumethatthetreeisinitiallyemptyandvaluesareaddedinascendingorder.Whatwillbe
therootoftheconstructedB+treeifthenumberofpointersthatwillfitinonenodeissix?
(A)7,11(B)7,19(C)19(D)11

AnsisB...Pleaseexplain.....
http://www.cs.ucla.edu/classes/fall04/cs143/solutions/chap12a.pdf
name

Hashingtop
Considerthefollowing,fivebinarystringsoflength8.
01010010,11011011,10011010,11111011,01110010
AhashtableofsizeM=8(0to7)isusingopenaddressingforhashingthebinarystrings.Assumefindinganemptyslotdirectlywithoutcollisionorafter
collisionisalsoaprobe.Calculatethetotalnumberofprobesthatoccurwhilehashingfivestringsusinglinearprobing.

Assumingmod8functionforhashing
01010010mod8=010=2(1probe,goestoslot2)
11011011mod8=011=3(1probe,goestoslot3)
10011010mod8=010=2(3probes,goestoslot4)
11111011mod8=011=3(3probes,goestoslot5)
01110010mod8=010=2(5probes,goestoslot6)
So,totalnumberofprobes=13
http://webdocs.cs.ualberta.ca/~holte/T26/openaddr.html
http://gateoverflow.in/book

54/400

2/26/2015

GATEOverflow Book

name

TimeComplexitytop
i=0
for(i=1;i<=n;++i)
for(j=1;j<=i*i;++j)
if((j%i)==0)
for(k=1;k<=j;++k)
c=c+1;

findtimecomplexityoftheseprogram?

(Thethirdloopexecutesonlywhenj%i==0,whichwillbetrueforj=i,2i,3i,...i*i.i.e.,italsoexecutesitimes.)
Wehavetocountthenumberoftimesthestatementc=c+1isexecuted.
theouteriloopexecutesfrom1ton.
fori=1,2,3,4,...n
thekloopwillexecutefor
1,2+4,3+6+9,4+8+12+16,...,n+2n+3n+...n2
So,wehavetocounttheiterationsfork,whichwillgive

n
i=1

i
j=1

j i

= 1 + 6 + 18 + 40+. . . +n n
=

n
i=1

i i

n+1
2

i+1
2

= O(n )

(Wecanassumethesumtothecubesoffirstnnaturalnumbers)
name

timecomplexityofaprogramis?top
for(i=1i<=ni++)
for(j=n/3j<=2nj+=n/3)
x=x+1
itshouldbeO(n).innerlooprunsforconstantnumberoftimesforeveryiterationofouterloop,henceweneedtoconsideronlyouterloopcomplexity.
Laxmi

Answerthefollowingquestiontop

http://gateoverflow.in/book

55/400

2/26/2015

GATEOverflow Book

Pleaseshowstepsforthequestion20and14.
Q.20)1stpass[20,47],[8,15],[4,9],[30,40],[12,17]
2ndpass[8,15,20,47],[4,9,30,40],[12,17]So(B)istheanswer
Q.14)http://lcm.csa.iisc.ernet.in/dsa/node112.html
name

Whatisthecomplexityoffinding50thsmallestelementinanalreadyconstructedbinaryminheap?
top

Itisconstant.aslongasnumberisindependentofnitcanbefoundwithkk1/2Comparisons.
name

GATE20151_2top
Whichoneofthefollowingistherecurrenceequationfortheworstcasetimecomplexityofthequicksortalgorithmforsortingn( 2)numbers?Inthe
recurrenceequationsgivenintheoptionsbelow,cisaconstant.
A.
B.
C.
D.

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

B.
Worstcaseforquicksorthappenswhen1elementisononelistandn1elementsonanotherlist.
name

GATE20152_2top
ConsidertwodecisionproblemsQ1 , Q2 suchthatQ1 reducesinpolynomialtimeto3SATand3SATreducesinpolynomialtimetoQ2 .Thenwhichoneof
thefollowingisconsistentwiththeabovestatement?

A. Q1 isinNP,Q2 isNPhard.
B. Q2 isinNP,Q1 isNPhard.
C. BothQ1 andQ2 areinNP.
D. BothQ1 andQ2 areinNPhard.
3SATisNPCompleteandhenceinNPaswellasNPhard.
http://gateoverflow.in/book

56/400

2/26/2015

GATEOverflow Book

Now,anylessorequallyhardproblemcanbereduced(inpolynomialtime)to3SAT.So,Q1reducingto3SATmeansQ1islessharderthan3SATcanbe
PorNP.SincePNP.Q1isinNP,neednotbeNPHard.
3SATreducing(inpolynomialtime)toQ2meansQ2isharderorashardas3SATmeaningQ2isalsoNPHard.Q2,neednotbeinNP.
So,Aoptiononlyisalwayscorrect.
name

GATE20152_11top
ConsiderthefollowingCfunction.
int fun(int n) {
int x=1, k;
if (n==1) return x;
for (k=1; k<n; ++k)
x = x + fun(k) * fun (n-k);
return x;
}

Thereturnvalueoffun(5)is______.
fun(1)=1
fun(2)=1+fun(1)*fun(1)=1+1=2
fun(3)=1+fun(1)*fun(2)+fun(2)*fun(1)=5
fun(4)=1+fun(1)*fun(3)+fun(2)*fun(2)+fun(3)*fun(1)=1+5+4+5=15
fun(5)=1+fun(1)*fun(4)+fun(2)*fun(3)+fun(3)*fun(2)+fun(4)*fun(1)=1+15+10+10+15=51
name

GATE20151_6top
Matchthefollowing:
(P)Prim'salgorithmforminimumspanningtree

(i)Backtracking

(Q)FloydWarshallalgorithmforallpairsshortestpaths

(ii)Greedymethod

(R)Mergesort

(iii)Dynamicprogramming

(S)Hamiltoniancircuit

(iv)Divideandconquer

A.
B.
C.
D.

Piii,Qii,Riv,Si
Pi,Qii,Riv,Siii
Pii,Qiii,Riv,Si
Pii,Qi,Riii,Siv

optionciscorrect..
name

GATE20152_22top
Anunorderedlistcontainsn distinctelements.Thenumberofcomparisonstofindanelementinthislistthatisneithermaximumnorminimumis

A.
B.
C.
D.

(n log n)
(n)
(log n)
(1)

AnsO(1),becauseallelementsaredistinct,selectanythreenumbersandoutput2ndlargestfromthem.
name

GATE20152_36top
Givenbelowaresomealgorithms,andsomealgorithmdesignparadigms.
http://gateoverflow.in/book

57/400

2/26/2015

GATEOverflow Book

1.Dijkstra'sShortestPath
2.FloydWarshallalgorithmtocomputeallpairs
shortestpath
3.Binarysearchonasortedarray
4.Backtrackingsearchonagraph

i.DivideandConquer
ii.DynamicProgramming
iii.Greedydesign
iv.Depthfirstsearch
v.Breadthfirstsearch

Matchtheabovealgorithmsonthelefttothecorrespondingdesignparadigmtheyfollow.

A.
B.
C.
D.

1i,2iii,3i,4v
1iii,2iii,3i,4v
1iii,2ii,3i,4iv
1iii,2ii,3i,4v

Answer:C
name

GATE20151_31top
ConsiderthefollowingCfunction.
int fun1 (int n) {
int i, j, k, p, q = 0;
for (i = 1; i < n; ++i) {
p = 0;
for (j = n; j > 1; j = j/2)
++p;
for (k = 1; k < p; k = k * 2)
++q;
}
return q;
}

Whichoneofthefollowingmostcloselyapproximatesthereturnvalueofthefunctionfun1?
A.
B.
C.
D.

n3
n(logn)2
nlogn
nlog(logn)

iloopisexecutingntimes.jloopisexecutinglogntimesforeachi,andsovalueofpislogn.kloopisexecutinglogptimes,whichisloglogntimesfor
eachiterationofi.Ineachoftheseqisincremented.So,overalliterationsofi,qwillbeincrementednloglogntimes.So,Dchoice.
name

GATE20151_43top
Thegraphshownbelowhas8edgeswithdistinctintegeredgeweights.Theminimumspanningtree(MST)isofweight36andcontainstheedges:{(A,C),(B,
C),(B,E),(E,F),(D,F)}.TheedgeweightsofonlythoseedgeswhichareintheMSTaregiveninthefigureshownbelow.Theminimumpossiblesumof
weightsofall8edgesofthisgraphis_______________.

ConsiderthecycleABC.ACandABarepartofminimumspanningtree.So,ABshouldbegreaterthanmax(AC,BC)(greaterandnotequalasedgeweights
aregiventobedistinct),asotherwisewecouldaddABtotheminimumspanningtreeandremovedthegreaterofAC,BCandwecouldhavegotanother
minimumspanningtree.So,AB>9.
Similarly,forthecycleDEF,ED>6.
http://gateoverflow.in/book

58/400

2/26/2015

GATEOverflow Book

AndforthecycleBCDE,CD>15.
So,minimumpossiblesumofthesewillbe10+7+16=33.Addingtheweightofspanningtree,wegetthetotalsumofedgeweights
=33+36=69
name

GATE20151_45top
LetG=(V,E)beasimpleundirectedgraph,andsbeaparticularvertexinitcalledthesource.ForxV,letd(x)denotetheshortestdistanceinGfromstox.
Abreadthfirstsearch(BFS)isperformedstartingats.LetTbetheresultantBFStree.If(u,v)isanedgeofGthatisnotinT,thenwhichoneofthefollowing
CANNOTbethevalueofd(u)d(v)?
A.
B.
C.
D.

1
0
1
2

2istheanswer.
d(u)d(v)=0ispossiblewhenbothuandvhaveanedgefromtandtisintheshortestpathfromstouorv.
d(u)d(v)=1ispossiblewhenuisintheshortestpathfromstov,andtisalsointheshortestpathfromstovandbothtandsaresiblingssamedistance
fromstobothtanducausingtvedgetobeinBFStreeandnotuv.
d(u)d(v)=1ispossibleasexplainedabovebyinterchanginguandv.
d(u)d(v)=2isnotpossible.ThisisbecauseonBFStraversalweeithervisitufirstorv.Let'stakeufirst.Now,weputallneighborsofuonqueue.Sincev
isaneighbourandvisnotvisitedbeforeasassumed,d(v)willbecomed(u)+1.Similarly,forvbeingvisitedfirst.
name

GATE20151_49top
Letan representthenumberofbitstringsoflengthncontainingtwoconsecutive1s.Whatistherecurrencerelationforan ?
A.
B.
C.
D.

an2 + an1 + 2

n2

an2 + 2an1 + 2
2an2 + an1 + 2

n2
n2

2an2 + 2an1 + 2

n2

Countingthenumberofbitstringsnotcontainingtwoconsecutive1's.
01
0001103
0000010101001015(allstringsendingin0givetwostringsandthoseendingin1give1string)
000000010010010001011000100110108
....

an'=an1'+an2'
2nan=(2n1an1)+(2n2an2)
an=2n2(421)+an1+an2
an=an1+an2+2n2
Achoice.

name

GATE20153_4top
n

Considertheequality(i=0) i 3
4

(
)
http://gateoverflow.in/book

= X

andthefollowingchoicesforX

59/400

2/26/2015

GATEOverflow Book

I. (n )
II. (n 5 )
III. O(n 5 )
IV. (n 3 )
4

TheequalityaboveremainscorrectifX isreplacedby

A.
B.
C.
D.

OnlyI
OnlyII
IorIIIorIVbutnotII
IIorIIIorIVbutnotI

Sumofthecubesofthefirstnnaturalnumbersisgivenby(n(n+1)/2)2whichis(n4).So,I,IIIandIVarecorrect.IIiswrong.Cchoice.
name

GATE20153_27top
Assumethatamergesortalgorithmintheworstcasetakes30secondsforaninputofsize64.Whichofthefollowingmostcloselyapproximatesthemaximum
inputsizeofaproblemthatcanbesolvedin6minutes?

A.
B.
C.
D.

256
512
1024
2018

TheworstcasetimecomplexityofMergesortisk n log n foraninputofsizen .


Foraninputofsize64,thealgorithmtakes30s .Therefore,
k 64 log 2 64 = 30s

k 384 = 30s

k = 0.078125s

Letthesizeoftheproblemthatcanbesolvedin6 minutesbex .Then,


k x log 2 x = 360s

Fromthis,weget:
360s
x log 2 x =

0.078125s

x = 512

name

GATE20153_30top
ConsiderthefollowingtwoCcodesegments.Y andX areoneandtwodimensionalarraysofsizen andn nrespectively,where2 n 10.Assume
thatinbothcodesegments,elementsofY areinitializedto0andeachelementX[i][j] ofarrayX isinitializedtoi + j .Furtherassumethatwhenstoredin
mainmemoryallelementsofX areinsamemainmemorypageframe.
Codesegment1:
// initialize elements of Y to 0
// initialize elements of X[i][j] of X to i+j
for (i=0; i<n; i++)
Y[i] += X[0][i];

Codesegment2:
// initialize elements of Y to 0
// initialize elements of X[i][j] of X to i+j

http://gateoverflow.in/book

60/400

2/26/2015

GATEOverflow Book

for (i=0; i<n; i++)


Y[i] += X[i][0];

Whichofthefollowingstatementsis/arecorrect?
S1:FinalcontentsofarrayY willbesameinbothcodesegments
S2:ElementsofarrayX accessedinsidetheforloopshownincodesegment1arecontiguousinmainmemory
S3:ElementsofarrayX accessedinsidetheforloopshownincodesegment2arecontiguousinmainmemory

A.
B.
C.
D.

OnlyS2iscorrect
OnlyS3iscorrect
OnlyS1andS2arecorrect
OnlyS1andS3arecorrect

optionC.OnlyS1andS2arecorrectbecauseYhavesameelementinbothcodeandincode1

Y[i]+=X[0][i]
thisrowmajororder(InC,arraysarestoredinrowmajororder)whichgivesaddressofeachelementinsequentialorder(1,2,3,....,n)meanswecrosssingle
elementeachtimetomovenextshowscontiguousinmainmemorybutincode2for

Y[i]+=X[i][0]
we are crossing n element (row crossing with n element )to move next

name

GATE20153_39top
ConsiderthefollowingrecursiveCfunction.
void get(int n)
{
if (n<1) return;
get (n-1);
get (n-3);
printf("%d", n);
}

Ifget(6)functionisbeingcalledinmain()thenhowmanytimeswilltheget()functionbeinvokedbeforereturningtothemain()?

A.
B.
C.
D.

15
25
35
45

T(n)=T(n1)+T(n3)+2
T(n<=0)=0
T(1)=2
T(2)=4
T(3)=6
T(4)=10
T(5)=16
T(6)=24
So,answeris24+1callfrommain=25.
name

GATE20153_40top
LetG beaconnectedundirectedgraphof100verticesand300edges.TheweightofaminimumspanningtreeofG is500.WhentheweightofeachedgeofG
isincreasedbyfive,theweightofaminimumspanningtreebecomes______.
firstfindnoofedgesinmst...
msthasn1edgeswherenisnoofvertices.1001=99edges
each99edgesinmstincreasesby5soweightinmstincreased99*5=495
nowtotalweightofmst=500+495=995
name
http://gateoverflow.in/book

61/400

2/26/2015

GATEOverflow Book

GATE20153_42top
Letf (n)

= n

I. f (n)
II. f (n)

andg(n)

= n

(1+sin n)

wheren isapositiveinteger.Whichofthefollowingstatementsis/arecorrect?

= O(g(n))
= (g(n))

A.
B.
C.
D.

OnlyI
OnlyII
BothIandII
NeitherInorII

TheanswerisoptionD.
Sincethevalueofsin(n)willalwaysrangefrom1to+1,henceg(n)cantakevalues1,n,n^2.
Hence,ifg(n)=1,StatementIisincorrect.
And,ifg(n)=n^2,thenStatementIIisincorrect.
saurabhrk

GATE20153_49top
Supposec = c[0], , c[k 1] isanarrayoflengthk ,wherealltheentriesarefromtheset{0,1}.Foranypositiveintegersaandn ,considerthe
followingpseudocode.
DOSOMETHING(c,a,n)
z 1

fori 0tok 1
doz z modn
ifc[i]=1
thenz (z a)modn
returnz
2

Ifk

= 4, c =

1, 0, 1, 1, a

= 2, andn = 8

,thentheoutputofDOSOMETHING(c,a,n)is_______.

Answeris0.Bymanuallyiteratingthroughthestepsbypencilandpaperwecangetthisanswer
ppm

GATE20153_53top
LanguageL1 ispolynomialtimereducibletolanguageL2 .LanguageL3 ispolynomialtimereducibletolanguageL2 ,whichinturnpolynomialtime
reducibletolanguageL4 .Whichofthefollowingis/aretrue?
I. ifL4 P , thenL2 P
II. ifL1 P orL3 P , thenL2
III. L1 P , if and only ifL3 P
IV. ifL4 P , thenL3 P

A.
B.
C.
D.

IIonly
IIIonly
IandIVonly
Ionly

L1ispolynomialtimereducibletoL2.So,L2isatleastashardasL1.
L2ispolynomialtimereducibletoL3.So,L3isatleastashardasL2.
L3ispolynomialtimereducibletoL4.So,L4isatleastashardasL3.

IfL4isinP,L3,L2andL1mustalsobeinP.So,IandIVaretrue.
IfL3isinP,thenL2mustbeinP.ButifL1isinP,L2neednotbeinP.So,IIisfalse.
http://gateoverflow.in/book

62/400

2/26/2015

GATEOverflow Book

IfL3isinP,L1willbeinP.ButifL1isinP,L3neednotbeinP.i.e.,ifisTRUEbutifandonlyfisFALSE.So,IIIisfalse.
HenceCchoice.
MoreInfo:http://gatecse.in/wiki/Some_Reduction_Inferences

name

http://gateoverflow.in/book

63/400

2/26/2015

GATEOverflow Book

CO&Architecturetop
GATE2012_20top
Registerrenamingisdoneinpipelinedprocessors
(A)asanalternativetoregisterallocationatcompiletime
(B)forefficientaccesstofunctionparametersandlocalvariables
(C)tohandlecertainkindsofhazards
(D)aspartofaddresstranslation
RegisterrenamingisdonetoeliminateWAR(WriteafterRead)andWAW(WriteafterWrite)dependencybetweeninstructionswhichcouldhavecaused
pipielinestalls.Hence(C)istheanswer.
name

Whynotd?top
Whynotoptiondiscorrect?
Becausemicroprocessorcanalsohavehardwiredcontrolunit.Microprogrammedcontrolunitisjustadesignoptionforcontrolunitinamicroprocessor.This
"micro"isnotrelatedtothe"micro"inmicroprocessor.
name

GATE2004_47top
Considerasystemwithatwolevelpagingschemeinwhicharegularmemoryaccesstakes150nanoseconds,andservicingapagefaulttakes8milliseconds.An
averageinstructiontakes100nanosecondsofCPUtime,andtwomemoryaccesses.TheTLBhitratiois90%,andthepagefaultrateisoneinevery10,000
instructions.Whatistheeffectiveaverageinstructionexecutiontime?
(A)645nanoseconds
(B)1050nanoseconds
(C)1215nanoseconds
(D)1230nanoseconds
AverageInstructionexecutiontime
=AverageCPUexecutiontime+Averagetimeforgettingdata/instructionfrommemoryforeachinstruction
=AverageCPUexecutiontime+Averageaddresstranslationtimeforeachinstruction+Averagememoryfetchtimeforeachinstruction+Averagepage
faulttimeforeachinstruction
=100+2*((0.9*0)+0.1*(2*150))+2*150+(1/10,000)*8*1,000,000(pagefaultrateper10,000instructionisdirectlygiveninquestion.Two
memoryaccessesperinstructionandhenceweneed2*addresstranslationtimeforaverageinstructionexecutiontime)
[TLBaccesstimeassumedas0and2pagetablesneedtobeaccessedincaseofTLBmissasthesystemusestwolevelpaging]
=100+60+300+800
=1260ns
name

GATE2013_45top
Consideraninstructionpipelinewithfivestageswithoutanybranchprediction:FetchInstruction(FI),DecodeInstruction(DI),FetchOperand(FO),Execute
Instruction(EI)andWriteOperand(WO).ThestagedelaysforFI,DI,FO,EIandWOare5ns,7ns,10ns,8nsand6ns,respectively.Thereareintermediate
storagebuffersaftereachstageandthedelayofeachbufferis1ns.Aprogramconsistingof12instructionsI1,I2,I3,,I12isexecutedinthispipelined
processor.InstructionI4istheonlybranchinstructionanditsbranchtargetisI9.Ifthebranchistakenduringtheexecutionofthisprogram,thetime(inns)
neededtocompletetheprogramis
(A)132(B)165(C)176(D)328

clockcycletimeis11ns
2nopinstructionsreq
clk1clk2cl3clk4clk5clk6clk7clk8clk9clk10clk11clk12
11111
22222
33333
44444

http://gateoverflow.in/book

64/400

2/26/2015

GATEOverflow Book

nopnopnopnopnop
nopnopnopnopnop
99999
1010101010
1111111111
1212121212
totalnoofclkcyclesis14
hence14*11=154nsplzexplain

Youjustneed1morestallcycleastheFIofI9canstartonlyaftertheEIofI4.So,thetotalexecutiontimewillbe
15 11 = 165ns.

I1
I2
I3
I4

I9
I10
I11
I12

Clk
1
FI

Clk
2
DI
FI

Clk
3
FO
DI
FI

Clk
4
EI
FO
DI
FI

Clk
5
WO
EI
FO
DI
stall

Clk
6

WO
EI
FO

stall

Clk
7

WO
EI

stall

Clk
8

WO

FI

Clk
9

DI
FI

Clk
10

FO
DI
FI

Clk
11

EI
FO
DI
FI

Clk
12

WO
EI
FO
DI

Clk
13

WO
EI
FO

Clk
14

WO
EI

Clk
15

WO

gatecse

GATE2008_38top

CasonlyafterthecalculationofVirtualaddressyoucanlookupintheTLB
name

GATE2008_71,72,73top
Consideramachinewitha2waysetassociativedatacacheofsize64Kbytesandblocksize16bytes.Thecacheismanagedusing32bitvirtualaddressesand
thepagesizeis4Kbytes.Aprogramtoberunonthismachinebeginsasfollows:
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;

Thesizeofdoubleis8bytes.ArrayARRislocatedinmemorystartingatthebeginningofvirtualpage0xFF000andstoredinrowmajororder.Thecacheis
initiallyemptyandnoprefetchingisdone.TheonlydatamemoryreferencesmadebytheprogramarethosetoarrayARR.
71)Thetotalsizeofthetagsinthecachedirectoryis
(A)32Kbits(B)34Kbits(C)64Kbits(D)68Kbits

http://gateoverflow.in/book

65/400

2/26/2015

GATEOverflow Book

72)WhichofthefollowingarrayelementshavethesamecacheindexasARR[0][0]?
(A)ARR[0][4](B)ARR[4][0](C)ARR[0][5](D)ARR[5][0]

73)Thecachehitratioforthisinitializationloopis
(A)0%(B)25%(C)50%(D)75%

Numberofsets=cachesize/sizeofaset
=64KB/(16B*2)(twoblocksperset)
=2K=211
So,weneed11bitsforsetindexing.
NumberofWORDbitsrequired=4asacacheblockconsistsof16bytesandweneed4bitstoaddresseachofthem.
So,numberoftagbits=32114=17
Totalsizeofthetag=17*Numberofcacheblocks
=17*211*2(sinceeachsethas2blocks)
=68KB
Weusethetop17bitsfortagandthenext11bitsforindexingandnext4foroffset.So,fortwoaddressestohavethesamecacheindex,their11addressbits
afterthe4offsetbitsfromrightmustbesame.
ARR[0][0]islocatedatvirtualaddress0xFF000000.(FF000ispageaddressand000ispageoffset).So,indexbitsare00000000000
AddressofARR[0][4]=0xFF000+4*sizeof(double)=0xFF000000+4*8=0xFF000020(32=20inhex)(indexbitsdiffer)
AddressofARR[4][0]=0xFF000+4*1024*sizeof(double)[sinceweuserowmajorstorage]=0xFF000000+4096*8=0xFF000000+0x8000=
0xFF008000(indexbitsmatchesthatofARR[0][0]asbothread00000000000)

AddressofARR[0][5]=0xFF000+5*sizeof(double)=0xFF000000+5*8=0xFF000028(40=28inhex)(indexbitsdiffer)
AddressofARR[5][0]=0xFF000+5*1024*sizeof(double)[sinceweuserowmajorstorage]=0xFF000000+5120*8=0xFF000000+0xA000=
0xFF00A000(indexbitsdiffer)
So,onlyARR[4][0]andARR[0][0]havethesamecacheindex.
The inner loop is iterating from 0 to 1023, so consecutive memory locations are accessed in sequence. Since cache block size is only 16 bytes and our
elementbeingdoubleisofsize8bytes,duringamemoryaccessonlythenextelementgetsfilledinthecache.i.e.everyalternativememoryaccessisa
cachemissgivingahitratioof50%.(Ifloopsiandjarereversed,allaccesseswillbemissesandhitratiowillbecome0).

name

GATE2008_76,77top

76. Answer is A. In order to avoid the pipeline delay due to conditional branch instruction, a suitable instruction is placed below the conditional branch
instructionsuchthattheinstructionwillbeexecutedirrespectiveofwhetherbranchistakenornotandwon'taffecttheprogrambehaviour.
77.AnswerisD)I4.TheSTOREinstructioncanbemovedbelowtheconditionalbranchinstruction.Whetherthebranchistakenornot,STOREwillbe
executedasthenextinstructionafterconditionalbranchinstructionduetodelayedbranching.
http://gateoverflow.in/book

66/400

2/26/2015

GATEOverflow Book

Here,I3isnottheanswerbecausethebranchconditionalvariableR1isdependentonit.SameforI1.Similarly,I4hasadependencyonI2andhenceI2must
beexecutedbeforeI4.
name

GATE2000_1.8top
ComparingthetimeT1takenforasingleinstructiononapipelinedCPUwithtimeT2takenonanonpipelinedbutidenticalCPU,wecansaythat

a. T1T2
b. T1T2
c. T1<T2
d. T1andT2plusthetimetakenforoneinstructionfetchcycle

Herewearecomparingtheexecutiontimeofonlyasingleinstruction.Pipelininginnowayincreasestheexecutiontimeofasingleinstruction(thetime
fromitsstarttoend).Itincreasestheoverallperformancebysplittingtheexecutiontomultiplepipelinestagessothatthefollowinginstructionscanusethe
finishedstagesofthepreviousinstructions.Butindoingsopipeliningcausessomeproblemsalsoasgiveninthebelowlink,whichmightslowsome
instructions.So,(B)istheanswer.
http://www.cs.wvu.edu/~jdm/classes/cs455/notes/tech/instrpipe.html
name

GATE2000_1.10top
Themostappropriatematchingforthefollowingpairs
X: Indirect addressing
Y: Immediate addressing
Z: Auto decrement addressing

1: Loops
2: Pointers
3: Constants

is

a. X3Y2Z1
b. X1Y3Z2
c. X2Y3Z1
d. X3Y1Z2

Cisthemostappropriateone
name

GATE2000_12top
Aninstructionpipelinehasfivestageswhereeachstagetake2nanosecondsandallinstructionuseallfivestages.Branchinstructionsarenotoverlapped.i.e.,
theinstructionafterthebranchisnotfetchedtillthebranchinstructioniscompleted.Underidealconditions,
a. Calculatetheaverageinstructionexecutiontimeassumingthat20%ofallinstructionsexecutedarebranchinstruction.Ignorethefactthatsomebranch
instructionsmaybeconditional.
b. If a branch instruction is a conditional branch instruction, the branch need not be taken. If the branch is not taken, the following instructions can
be overlapped. When 80% of all branch instructions are conditional branch instructions, and 50% of the conditional branch instructions are such that
thebranchistaken,calculatetheaverageinstructionexecutiontime.

Eachstageis2ns.So,after5timeunitseachof2ns,thefirstinstructionfinishes(i.e.,after10ns),inevery2nsafterthatanewinstructiongetsfinished.This
is assuming no branch instructions. Now, once the pipeline is full, we can assume that the initial fill time doesn't matter our calculations and average
executiontimeforeachinstructionis2nsassumingnobranchinstructions.
(a)Now,wearegiventhat20%ofinstructionsarebranch(likeJMP)andwhenabranchinstructionisexecuted,nofurtherinstructionentersthepipeline.So,
wecanassumeevery5thinstructionisabranchinstruction.So,withthisassumption,totaltimetofinish5instructionwillbe5*2+8=18ns(aswhena
branchinstructionentersthepipelineandbeforeitfinishes,4pipelinestageswillbeemptytotaling4*2=8ns).Andthisisthesameforeverysetof5
instructions,andhencetheaverageinstructionexecutiontime=18/5=3.6ns
(b)Thisisjustacomplexstatement.Butwhatweneedistoidentifythe%ofbranchinstructionswhichcauseabranchtobetakenasotherswillhaveno
effectonthepipelineflow.
20%ofbranchinstructionsarebranchinstructions.80%ofbranchinstructionsareconditional.
Thatmeans.2*.8=16%ofinstructionsareconditionalbranchinstructionsanditisgiventhat50%ofthoseresultinabranchbeingtaken.
So,8%ofinstructionsareconditionalbranchesbeingtakenandwealsohave20%of20%=4%ofunconditionalbranchinstructionswhicharealwaystaken.
So,percentageofinstructionswhereabranchistakenis8+4=12%insteadof20%in(a)part.
So,in100instructionstherewillbe12branchinstructions.Wecandoadifferentcalculationhereascomparedto(a)as12isnotadivisorof100.Each
http://gateoverflow.in/book

67/400

2/26/2015

GATEOverflow Book

branchinstructioncausesapipelinedelayof4*2=8ns.So,12instructionswillcauseadelayof12*8=96ns.For100instructions,weneed100*2=200
nswithoutanydelayandwithdelaywerequire200+96=296nsfor100instructions.
So,averageinstructionexecutiontime=296/100=2.96ns
(Wecanalsousethismethodforpart(a)whichwillgive100*2+20*8=360nsfor100instructions)

name

GATE2001_2.9top
Whichisthemostappropriatematchfortheitemsinthefirstcolumnwiththeitemsinthesecondcolumn
X.IndirectAddressing
Y.Indexedaddressing

I.Arrayimplementation
II.Writingrelocatablecode

Z.BaseRegisterAddressing

III.Passingarrayasparameter

(A)(X,III)(Y,I)(Z,II)
(B)(X,II)(Y,III)(Z,I)
(C)(X,III)(Y,II)(Z,I)
(D)(X,I)(Y,III)(Z,II)

(A)istheanswer.
ArrayimplementationcanuseIndexedaddressing
Whilepassingarrayasparameterwecanmakeuseofapointer(asinC)andhencecanuseIndirectaddressing
BaseRegisteraddressingcanbeusedtowriterelocatablecodebychangingthecontentofBaseRegister.
name

GATE2001_9top
ACPUhas32bitmemoryaddressanda256KBcachememory.Thecacheisorganizedasa4waysetassociativecachewithcacheblocksizeof16bytes.
A.
B.
C.
D.
E.

Whatisthenumberofsetsinthecache?
Whatisthesize(inbits)ofthetagfieldpercacheblock?
Whatisthenumberandsizeofcomparatorsrequiredfortagmatching?
Howmanyaddressbitsarerequiredtofindthebyteoffsetwithinacacheblock?
Whatisthetotalamountofextramemory(inbytes)requiredforthetagbits?

Whatisthenumberofsetsinthecache?
Numberofsets=Cachememory/(setassociativity*cacheblocksize)
=256KB/(4*16B)
=4096

Whatisthesize(inbits)ofthetagfieldpercacheblock?
Memoryaddresssize=32bit
Numberofbitsrequiredtoidentifyaparticularset=12(Numberofsets=4096)
Numberofbitsrequiredtoidentifyapaticularlocationincacheline=4(cacheblocksize=16)
sizeoftagfield=32124=16bit

Whatisthenumberandsizeofcomparatorsrequiredfortagmatching?
Weuse4waysetassociatecache.So,weneed4comparatorseachofsize16bits
http://gateoverflow.in/book

68/400

2/26/2015

GATEOverflow Book

http://ecee.colorado.edu/~ecen2120/Manual/caches/cache.html

Howmanyaddressbitsarerequiredtofindthebyteoffsetwithinacacheblock?
Cacheblocksizeis16byte.so4bitsarerequiredtofindthebyteoffsetwithinacacheblock.

Whatisthetotalamountofextramemory(inbytes)requiredforthetagbits?
sizeoftag=16bits
Numberofsets=4096
Setassociativity=4
Extramemoryrequiredtostorethetagbits=16*4096*4bits=215bytes
name

GATE2002_1.13top
Whichofthefollowingisnotaformofmemory
A.
B.
C.
D.

instructioncache
instructionregister
instructionopcode
translationlookasidebuffer

Theinstructionopcodeisapartoftheinstructionwhichtellstheprocessorwhatoperationistobeperformedsoitisnotaformofmemorywhiletheothers
are
name

GATE2002_1.24top
Intheabsoluteaddressingmode

A.
B.
C.
D.

theoperandisinsidetheinstruction
theaddressoftheoperandininsidetheinstruction
theregistercontainingtheaddressoftheoperandisspecifiedinsidetheinstruction
thelocationoftheoperandisimplicit

(b)istheanswer.Absoluteaddressingmodemeansaddressofoperandisgivenintheinstruction.
(a)operandisinsidetheinstruction>immediateaddressing
(c)>registeraddressing
(d)>implicitaddressing
gatecse

GATE2002_10top
InaCprogram,anarrayisdeclaredasfloatA[2048].Eacharrayelementis4Bytesinsize,andthestartingaddressofthearrayis0x00000000.Thisprogramis
runonacomputerthathasadirectmappeddatacacheofsize8Kbytes,withblock(line)sizeof16Bytes.
a. WhichelementsofthearrayconflictwithelementA[0]inthedatacache?Justifyyouranswerbriefly.
b. Iftheprogramaccessestheelementsofthisarrayonebyoneinreverseorderi.e.,startingwiththelastelementandendingwiththefirstelement,how
many data cache misses would occur? Justify your answer briefly. Assume that the data cache is initially empty and that no other data or instruction
accessesaretobeconsidered.

(a)
Datacachesize=8KB.
Blocklinesize=16B.
Sinceeacharrayelementoccupies4B,fourconsecutivearrayelementsoccupyablockline(elementsarealignedasstartingaddressis0)
http://gateoverflow.in/book

69/400

2/26/2015

GATEOverflow Book

Numberofcacheblocks=8KB/16B=512.Numberofcacheblocksneededforthearray=2048/4=512.So,allthearrayelementshasitsowncacheblock
andthereisnocollision.
We can also explain this with respect to array address. Starting address is 0x00000000 = 0b0000..0 (32 0's). Ending address is 0x00001000 =
0b0000..01000000000000.
Here,thelast4bitsareusedasOFFSETbitsandthenext9bitsareusedasSETbits.So,sincetheendingaddressisnotextendingbeyondthese9bits,all
cacheaccessesaretodiffsets.
(b)Ifthelastelementisaccessedfirst,itscacheblockisfetched.(whichshouldcontaintheprevious3elementsofthearrayalsosinceeachcacheblockhold
4elementsofarrayand2048isandexactmultipleof4).Thus,forevery4accesses,wewillhaveacachemiss=>for2048accesseswewillhave512cache
misses.(Thiswouldbesameevenifweaccessarrayinforwardorder).
name

GATE2004_39top

Discorrect
Heretimecomplexityisasked,foreachaccessofarrayelementitwillbeconstant,
Sothetimecomplexitywillnotdependuponstorage.Ifatallprogramexecutiontimeisasked
aistrue
name

GATE2007_80,81top
Consideramachinewithabyteaddressablemainmemoryof216bytes.Assumethatadirectmappeddatacacheconsistingof32linesof64byteseachisused
inthesystem.A50x50twodimensionalarrayofbytesisstoredinthemainmemorystartingfrommemorylocation1100H.Assumethatthedatacacheis
initiallyempty.Thecompletearrayisaccessedtwice.Assumethatthecontentsofthedatacachedonotchangeinbetweenthetwoaccesses.
80.Howmanydatamisseswilloccurintotal?
A.
B.
C.
D.

48
50
56
59

81.Whichofthefollowinglinesofthedatacachewillbereplacedbynewblocksinaccessingthearrayforthesecondtime?
A.
B.
C.
D.

line4toline11
line4toline12
line0toline7
line0toline8

16KBmainmemoryismappedto32linesof64bytes.So,numberofoffsetbits=6andnumberofindexingbits=5.
Sizeofarray=50*50=2500B.Forthefirst64Bofthearraytherewillbeonly1cachemiss.So,ifarrayisstoredinrowmajororder(firstrow,second
row..),andifelementsarealsoaccessedinrowmajororder,forthefirst64accesses,therewillbeonly1cachemiss,andfor2500accesses,therewillbe
2500/64=40cachemissesduringthefirstiteration.
Wehave5indexbitsand6tagbits.So,for211continuousaccessestherewontbeanycacheconflicts.
So,numberofarrayelementsthatcanbeaccessedwithoutcacheconflict=2048.Thenext452elementsconflictwiththefirst452elements.Thismeans
452/64=8cacheblocksarereplaced.(Weusedceil,asevenifoneelementfromanewblockisaccessed,thewholeblockmustbefetched).
So,duringseconditerationweincurmissesforthefirst8cacheblocksaswellasforthelast8cacheblocks.So,totaldatacachemissesacross2iterations=
40+8+8=56.

For81.answerislines4to11aswestartfrom
1100H=(0001000100000000)bexcludinglower6bitsforoffset,weget0001000100bitsforcacheblockwhichisthe4thblock.
http://gateoverflow.in/book

70/400

2/26/2015

GATEOverflow Book

name

GATE2005_65top

1memoryreadgetfirstoperandfrommemoryaddressA+R0(Aisgivenaspartofinstruction)
1memoryreadgetaddressofsecondoperand(sincesecondusesindirectaddressing)
1memoryreadtogetsecondoperandfromtheaddressgivenbythepreviousmemoryread
1memorywritetostoretofirstoperand(whichisthedestination)
So,totally4memorycyclesoncetheinstructionisfetched.
name

GATE2005_66top

(c)istheanswer.
A[i]=B[j]Indexedaddressing
while(*A++)Autoincrement
temp=*xIndirectaddressing
name

GATE2013_20top
Ina k waysetassociativecache,thecacheisdividedinto vsets,eachofwhichconsistsof k lines.Thelinesofasetareplacedinsequenceoneafteranother.
Thelinesinsets aresequencedbeforethelinesinset(s + 1).Themainmemoryblocksarenumbered0onwards.Themainmemoryblocknumbered j must
bemappedtoanyoneofthecachelinesfrom
(A)(jmodv) kto(jmodv) k + (k 1)
(B)(jmodv)to(jmodv) + (k 1)
(C)(jmodk)to(jmodk) + (v 1)
(D)(jmodk) vto(jmodk) v + (v 1)
Numberofsetsincache=v.So,mainmemoryblockjwillbemappedtoset(jmodv),whichwillbeanyoneofthecachelinesfrom(jmodv)*kto(jmod
v)*k+(k1).
(Associativityplaysnoroleinmappingkwayassociativitymeanstherearekspacesforablockandhencereducesthechancesofreplacement.)
name

GATE1999_13top
http://gateoverflow.in/book

71/400

2/26/2015

GATEOverflow Book

1
F

2
D

3
D

4
E

5 6
W

10

11

12 13 14 15

D
F

D E E W
D E E
F D D D
F

W
E
D


W

E W
E W W

therefore15clockcyclesneeded.
CORRECTMEIFIAMWRONG
name

GATE2013_48,49top
Thefollowingcodesegmentisexecutedonaprocessorwhichallowsonlyregisteroperandsinitsinstructions.Eachinstructioncanhaveatmosttwosource
operandsandonedestinationoperand.Assumethatallvariablesaredeadafterthiscodesegment.
c = a + b;
d = c * a;
e = c + a;
x = c * c;
if (x > a) {
y = a * a;
}
else {
d = d * d;
e = e * e;
}

Q.48Supposetheinstructionsetarchitectureoftheprocessorhasonlytworegisters.Theonlyallowedcompileroptimizationiscodemotion,whichmoves
statementsfromoneplacetoanotherwhilepreservingcorrectness.Whatistheminimumnumberofspillstomemoryinthecompiledcode?
(A)0(B)1(C)2(D)3

Q.49Whatistheminimumnumberofregistersneededintheinstructionsetarchitectureoftheprocessortocompilethiscodesegmentwithoutanyspillto
memory?Donotapplyanyoptimizationotherthanoptimizingregisterallocation.
(A)3(B)4(C)5(D)6

We can do code motion as follows:


c = a + b; //a and b in register and b replaced by the result c after the instruction
x = c * c; //x replaces c in register and c is spilled (moved to memory)
if (x > a) { //x and a in memory
y = a * a;
d = c * a; //spilled c taken from memory and replaces x in register.
e = c + a;
}
else {
d = c * a; //spilled c taken from memory and replaces x in register. d replaces a in register
d = d * d; //c and d in register
e = c + a; //a taken from memory and e replaces c in register (a taken from memory is not a spill, it is a fill)
e = e * e;
}

So,weneedminimum1spillinthecompiledcode.
https://en.wikipedia.org/wiki/Register_allocation

http://gateoverflow.in/book

72/400

2/26/2015

GATEOverflow Book

49)Here,wearetoldnottodocodemotion.So,westartwith3registers
c = a + b; //a, c in register
d = c * a; //a, c, d in register
e = c + a; //a, c, e in register, d spilled.

So,nowwetrywith4registers
c = a + b; //a, c in register
d = c * a; //a, c, d in register
e = c + a; //a, c, d, e in register
x = c * c; //a, x, d, e in register
if (x > a) {
y = a * a;
}
else {
d = d * d;
e = e * e;
}

Nospilling.So,4istheminimumnumberofregistersneededforavoidingspilling.(Ifcodemotionwasallowed,weneedonly3registersforavoiding
spilling).
name

GATE1998_1.19top

CBaseregisteraddressing
name

GATE1998_2.18top

ansa)
name

GATE20141_9top
Amachinehasa32bitarchitecture,with1wordlonginstructions.Ithas64registers,eachofwhichis32bitslong.Itneedstosupport45instructions,whichhavean
immediateoperandinadditiontotworegisteroperands.Assumingthattheimmediateoperandisanunsignedinteger,themaximumvalueoftheimmediateoperandis
____________

64registersmeans6bitsforaregisteroperand.So,2registeroperandrequires12bits.Now,45instructionsrequireanother6bitsforopcode.So,totally18
bits.So,wehave3218=14bitsleftfortheimmediateoperand.So,themaxvaluewillbe2141=16383(astheoperandisunsignedwedon'tneedasign
bitandwith14bitswecanrepresentfrom0to2141)
name

GATE2006_42top
A CPU has a fivestage pipeline and runs at 1 GHz frequency. Instruction fetch happens in the first stage of the pipeline. A conditional branch
instructioncomputesthetargetaddressandevaluatestheconditioninthethirdstageofthepipeline.Theprocessorstopsfetchingnewinstructionsfollowinga
conditionalbranchuntilthebranchoutcomeisknown.Aprogramexecutes109instructionsoutofwhich20%areconditionalbranches.Ifeachinstructiontakes
onecycletocompleteonaverage,thetotalexecutiontimeoftheprogramis:
(A)1.0second
(B)1.2seconds
(C)1.4seconds
(D)1.6seconds

http://gateoverflow.in/book

73/400

2/26/2015

GATEOverflow Book

noofnonbranchinstn=8*108
noofbranchinstn=2*108
noofbubblebycontrolhazard(branchinstrn)=3*2*108=6*108
then,totalnoofcycleforexecution=8*108+6*108ns=14*108=1.4sec
name

GATE2006_74,75top
CommonDataforQuestions74,75:
Considertwocacheorganizations.Firstoneis32kb2waysetassociativewith32byteblocksize,thesecondisofsamesizebutdirectmapped.Thesizeofan
k
addressis32bitsinbothcases.A2to1multiplexerhaslatencyof0.6nswhileak bitcomparatorhaslatencyof 10
ns.Thehitlatencyoftheset
associativeorganizationish1 whilethatofdirectmappedish2 .
74.Thevalueofh1 is:
(A)2.4ns
(B)2.3ns
(C)1.8ns
(D)1.7ns
75.Thevalueofh2 is:
(A)2.4ns
(B)2.3ns
(C)1.8ns
(D)1.7ns

Case1:
Cachesizeis32KBandcacheblocksizeis32B.So,
number of sets =

32K B
232B

cache size
no. of blocks in a setblock size

= 512

So,numberofindexbitsneeded=9(since29=512).Numberofoffsetbits=5(since25=32Bistheblocksizeandassumingbyteaddressing).So,number
oftagbits=3295=18(asmemoryaddressifof32bits).
So,timeforcomparingthedata=Timetocomparethedata+Timetoselecttheblockinset=0.6+18/10ns=2.4ns.(Twocomparisonsoftagbitsneedto
bedoneforeachblockinaset,buttheycanbecarriedoutinparallelandthesucceedingonemultiplexedastheoutput)
Case2:
number of sets =

32K B
132B

cache size
no. of blocks in a setblock size

= 1024

So,numberofindexbits=10,andnumberoftagbits=32105=17.So,h2
=17/10=1.7ns
name

GATE2006_80,81top
ACPUhasa32KBdirectmappedcachewith128byteblocksize.SupposeAistwodimensionalarrayofsize512 512 withelementsthatoccupy8bytes
each.ConsiderthefollowingtwoCcodesegments,P1andP2.
P1:
for (i=0; i<512; i++)
{
for (j=0; j<512; j++)
{
x +=A[i] [j];
}
}

http://gateoverflow.in/book

74/400

2/26/2015

GATEOverflow Book

P2:
for (i=0; i<512; i++)
{
for (j=0; j<512; j++)
{
x +=A[j] [i];
}
}

P1andP2areexecutedindependentlywiththesameinitialstate,namely,thearrayAisnotinthecacheandi,j,xareinregisters.Letthenumberofcache
missesexperiencedbyP1beM1andthatforP2beM2.
80.ThevalueofM1is:
(A)0
(B)2048
(C)16384
(D)262144
M1

81.Thevalueoftheratio M

(A)0
1
(B) 16

(C) 18
(D)16

CodebeingCimpliesarraylayoutisrowmajor.
http://en.wikipedia.org/wiki/Rowmajor_order
When A[0][0] is fetched, 128 consecutive bytes are moved to cache. So, for the next 128/8 1= 15 memory references there won't be a cache miss. So,
numberofcachemissesforP1
=

512
16

512

= 32 512

= 2

14

= 16384

InthecaseofP2,thememoryreferencesarenotconsecutive.AfterA[0][0],thenextaccessisA[1][0]whichisafter512*8memorylocations.Sinceour
cacheblockcanholdonly128contiguousmemorylocations,A[1][0]won'tbeincacheaftera[0][0]isaccessed.Now,thenextlocationafterA[0][0]isA[0]
[1]whichwillbeaccessedonlyafter512iterationsoftheinnerloopafter512distinctmemoryblockaccesses.Inourcachewehaveonlyspacefor32
KB/128B=256memoryblocks.So,bythetimeA[0][1]isaccessed,itscacheblockwouldbereplaced.So,eachofthememoryaccessinP2resultsina
cachemiss.Totalnumberofcachemiss
= 512 512
M1

So, M

32512
512512

1
16

name

GATE20141_43top
Considera6stageinstructionpipeline,whereallstagesareperfectlybalanced.Assumethatthereisnocycletimeoverheadofpipelining.Whenanapplication
isexecutingonthis6stagepipeline,thespeedupachievedwithrespecttononpipelinedexecutionif25%oftheinstructionsincur2pipelinestallcyclesis
____________
Timewithoutpipeline=6stages=6cycles
Timewithpipeline=1+stallfreqency*stallcycle
=1+.25*2
=1.5
Speedup=6/1.5
http://gateoverflow.in/book

75/400

2/26/2015

GATEOverflow Book

=4
aravind90

GATE20141_44top
An access sequence of cache block addresses is of length N and contains n unique block addresses. The number of unique block addresses between two
consecutiveaccessestothesameblockaddressisboundedaboveby k .Whatisthemissratioiftheaccesssequenceispassedthroughacacheofassociativity
A k exercisingleastrecentlyusedreplacementpolicy?
(A)n/N
(B)1/N
(C)1/A
(D)k/n

ThereareNaccessestocache.
Outofthesenareuniqueblockaddresses.
Now,weneedtofindthenumberofmisses.(min.nmissesareguaranteed)
Wearegiventhatbetweentwoconsecutiveaccessestothesameblock,therecanbeonlyk1uniqueblockaddresses.So,forablocktogetreplacedwecan
assumethatallthenextk1blockaddressesgoestothesameset(givencacheissetassociative)whichwillbetheworstcasescenario.Now,ifassociativity
sizeis>=k,andifweuseLRU(LeastRecentlyUsed)replacementpolicy,wecanguaranteethatthesekaccesseswontthrowoutourpreviouslyaccessed
cacheentry(forthatweneedatleastkaccesses).So,thismeansweareatthebestcachescenarioforcachereplacementoutofNaccesseswemissonlyn
(whichareuniqueandcannotbehelpedfromgettingmissed).So,missratioisn/N.
name

GATE20141_55top
ConsidertwoprocessorsP1 andP2 executingthesameinstructionset.Assumethatunderidenticalconditions,forthesameinput,aprogramrunningonP2 takes
25%lesstimebutincurs20%moreCPI(clockcyclesperinstruction)ascomparedtotheprogramrunningonP1 .IftheclockfrequencyofP1 is1GHZ,thentheclock
frequencyofP2 (inGHz)is______.

CPUTIME(T)=No.ofInstructions(I)xNo.ofCyclesPerInstruction(c)xCycleTime(t)
OR
CPUTIME(T)=No.ofInstructions(I)xNo.ofCyclesPerInstruction(c)x[Clockfrequency(f)]1
===>T=Ixcxf1===>f=(Ixc)/T

P1&P2executingsameinstructionset>No.ofInstructionssameforboth=I1=I2=I
IfP1takesT1time>T2=0.75xT1>T2/T1=0.75
IfP1incursc1clockcyclesperinstruction>c2=1.2xc1>c2/c1=1.2
SinceIissameforboth>(f1xT1)/c1=(f2xT2)/c2andf1=1GHz
>f2=(c2/c1)x(T1/T2)xf1=1.2/0.75x1GHz=1.6GHz
Hence,theclockfrequencyofP2is=1.6GHz.

name

GATE20142_9top
A4waysetassociativecachememoryunitwithacapacityof16KBisbuiltusingablocksizeof8words.Thewordlengthis32bits.Thesizeofthephysical
addressspaceis4GB.ThenumberofbitsfortheTAGfieldis____

Numberofsets=cachesize/sizeofaset
Sizeofaset=blocksize*no.ofblocksinaset
=8words*4(4waysetassociative)
=8*4*4(sinceawordis32bits=4bytes)
=128bytes.
So,numberofsets=16KB/(128B)=128
http://gateoverflow.in/book

76/400

2/26/2015

GATEOverflow Book

Now,wecandividethephysicaladdressspaceequallybetweenthese128sets.So,thenumberofbyteseachsetcanaccess
=4GB/128
=32MB
=32/4=8Mwords=1Mblocks.(220blocks)
So,weneed20tagbitstoidentifythese220blocks.
name

GATE20142_43top
Indesigningacomputer'scachesystem,thecacheblock(orcacheline)sizeisanimportantparameter.Whichoneofthefollowingstatementsiscorrectinthis
context?
(A)Asmallerblocksizeimpliesbetterspatiallocality
(B)Asmallerblocksizeimpliesasmallercachetagandhencelowercachetagoverhead
(C)Asmallerblocksizeimpliesalargercachetagandhencelowercachehittime
(D)Asmallerblocksizeincursalowercachemisspenalty
(A)Asmallerblocksizemeansduringamemoryaccessonlyasmallerpartofnearbyaddressesarebroughttocachemeaningspatiallocalityisreduced.
(B)Asmallerblocksizemeansmorenumberofblocks(assumingcachesizeconstant)andhenceweneedmorecachetagbitstoidentifythecorrectblock.
So,cachetagbecomesbigger.
(C)Asmallerblocksizeimplyinglargercachetagistrue,butthiscan'tlowercachehittimeinanyway.
(D)Asmallerblocksizeincursalowercachemisspenalty.Thisisbecauseduringacachemiss,anentirecacheblockisfetchedfromnextlowerlevelof
memory.So,asmallerblocksizemeansonlyasmalleramountofdataneedstobefetchedandhencereducesthemisspenalty(Cacheblocksizecangotil
thesizeofdatabustothenextlevelofmemory,andbeyondthisonlyincreasingthecacheblocksizeincreasesthecachemisspenalty).
name

GATE20142_44top
Iftheassociativityofaprocessorcacheisdoubledwhilekeepingthecapacityandblocksizeunchanged,whichoneofthefollowingisguaranteedtobeNOT
affected?
(A)Widthoftagcomparator
(B)Widthofsetindexdecoder
(C)Widthofwayselectionmultiplexor
(D)Widthofprocessortomainmemorydatabus
Ifassociativityisdoubled,keepingthecapacityandblocksizeconstant,thenthenumberofsetsgetshalved.So,widthofsetindexdecodercansurely
decrease(B)isfalse.
Widthofwayselectionmuntiplexermustbeincreasedaswehavetodoublethewaystochoosefrom(C)isfalse
Asthenumberofsetsgetsdecreased,thenumberofpossiblecacheblockentriesthatasetmapstogetsincreased.So,weneedmoretagbitstoidentifythe
correctentry.So,(A)isalsofalse.
(D)isthecorrectanswermainmemorydatabushasnothingtodowithcacheassociativitythiscanbeansweredwithoutevenlookingatotheroptions.
name

GATE20143_9top
Considerthefollowingprocessors(nsstandsfornanoseconds).Assumethatthepipelineregistershavezerolatency.
P1:Fourstagepipelinewithstagelatencies1ns,2ns,2ns,1ns.
P2:Fourstagepipelinewithstagelatencies1ns,1.5ns,1.5ns,1.5ns.
P3:Fivestagepipelinewithstagelatencies0.5ns,1ns,1ns,0.6ns,1ns.
P4:Fivestagepipelinewithstagelatencies0.5ns,0.5ns,1ns,1ns,1.1ns.
Whichprocessorhasthehighestpeakclockfrequency?
(A)P1
(B)P2
(C)P3

http://gateoverflow.in/book

77/400

2/26/2015

GATEOverflow Book

(D)P4

frequency=1/max(timeinstages)
forP3itis1/1GHz
forP1itis1/2=0.5GHz
forP2,itis1/1.5=0.67GHz
forP4,itis1/1.1GHz
name

GATE20143_43top
Aninstructionpipelinehasfivestages,namely,instructionfetch(IF),instructiondecodeandregisterfetch(ID/RF),instructionexecution(EX),memoryaccess
(MEM),andregisterwriteback(WB)withstagelatencies1ns,2.2ns,2ns,1ns,and0.75ns,respectively(nsstandsfornanoseconds).Togainintermsof
frequency,thedesignershavedecidedtosplittheID/RFstageintothreestages(ID,RF1,RF2)eachoflatency2.2/3ns.Also,theEXstageissplitintotwo
stages(EX1,EX2)eachoflatency1ns.Thenewdesignhasatotalofeightpipelinestages.Aprogramhas20%branchinstructionswhichexecuteintheEX
stageandproducethenextinstructionpointerattheendoftheEXstageintheolddesignandattheendoftheEX2stageinthenewdesign.TheIFstagestalls
afterfetchingabranchinstructionuntilthenextinstructionpointeriscomputed.AllinstructionsotherthanthebranchinstructionhaveanaverageCPIofonein
both the designs. The execution times of this program on the old and the new design are P and Q nanoseconds, respectively. The value of P /Q is
__________.
cpiforfirstcase=2.2(1+2*.2)asthestallrequiredis2and2.2isthemaximumstagedelay.
cpiforsecondstate=1*(1+5*.2)asnowstallincreaseto5astherearefivestagesbeforetheaddressiscalculatedandthemaximumstagedelaynowis1.
cpu_time1/cpu_time2=3.08/2=1.54
name

GATE20143_44top
Thememoryaccesstimeis1nanosecondforareadoperationwithahitincache,5nanosecondsforareadoperationwithamissincache,2nanosecondsforawrite
operationwithahitincacheand10nanosecondsforawriteoperationwithamissincache.Executionofasequenceofinstructionsinvolves100instructionfetch
operations, 60 memory operand read operations and 40 memory operand write operations. The cache hitratio is 0.9. The average memory access time (in
nanoseconds)inexecutingthesequenceofinstructionsis______.

Fetchisalsoamemoryreadoperation.....

avgaccesstime=[160(.9*1+.1*5)+.40(.9*2+.1*10)]/200
=[160*1.4+40*2.8]/200
=336/200
=1.68
aravind90

GATE2011_28top
Onanonpipelinedsequentialprocessor,aprogramsegment,whichisthepartoftheinterruptserviceroutine,isgiventotransfer500bytesfromanI/Odevice
tomemory.

LOOP:

Initialize the address register


Initialize the count to 500
Load a byte from device
Store in memory at address given by address register
Increment the address register
Decrement the count
If count !=0 go to LOOP

Assumethateachstatementinthisprogramisequivalenttoamachineinstructionwhichtakesoneclockcycletoexecuteifitisanonload/storeinstruction.The
loadstoreinstructionstaketwoclockcyclestoexecute.
ThedesignerofthesystemalsohasanalternateapproachofusingtheDMAcontrollertoimplementthesametransfer.TheDMAcontrollerrequires20clock
cyclesforinitializationandotheroverheads.EachDMAtransfercycletakestwoclockcyclestotransferonebyteofdatafromthedevicetothememory.
WhatistheapproximatespeedupwhentheDMAcontrollerbaseddesignisusedinaplaceoftheinterruptdrivenprogrambasedinputoutput?
(A)3.4
(B)4.4

http://gateoverflow.in/book

78/400

2/26/2015

GATEOverflow Book

(C)5.1
(D)6.7

STATEMENT
Initialize the address register
Initialize the count to 500
LOOP: Load a byte from device
Store in memory at address given by address register
Increment the address register
Decrement the count
If count != 0 go to LOOP

CLOCK CYCLE(S) NEEDED


1
1
2
2
1
1
1

Interrrupt driven transfer time = 1+1+500(2+2+1+1+1) = 3502


DMA based transfer time = 20+500*2 = 1020
Speedup = 3502/1020 = 3.4

name

GATE2011_41top
Consideraninstructionpipelinewithfourstages(S1,S2,S3andS4)eachwithcombinationalcircuitonly.Thepipelineregistersarerequiredbetweeneachstageand
attheendofthelaststage.Delaysforthestagesandforthepipelineregistersareasgiveninthefigure.

Whatistheapproximatespeedupofthepipelineinsteadystateunderidealconditionswhencomparedtothecorrespondingnonpipelineimplementation?
(A)4.0
(B)2.5
(C)1.1
(D)3.0

IthinktheanswerisB.2.5
InpipelinesystemTimetakenisdeterminedbythemaxdelayatanystageie,11nsplusthedelayincurredbypipelinestagesie1ns=12ns.Innonpipeline
systemDelay=5ns+6ns+11ns+8ns=30ns.

name

GATE2012_54,55top
StatementforLinkedAnswerQuestions54and55:
A computer has a 256 KByte, 4way set associative, write back data cache with block size of 32 Bytes. The processor sends 32 bit addresses to the cache
controller.Eachcachetagdirectoryentrycontains,inadditiontoaddresstag,2validbits,1modifiedbitand1replacementbit.
Q.54Thenumberofbitsinthetagfieldofanaddressis
(A)11
(B)14
(C)16
(D)27
http://gateoverflow.in/book

79/400

2/26/2015

GATEOverflow Book

Q.55Thesizeofthecachetagdirectoryis
(A)160Kbits
(B)136Kbits
(C)40Kbits
(D)32Kbits

Totalcachesize=256KB
Cacheblocksize=32Bytes
So,numberofcacheentries=256K/32=8K
Numberofsetsincache=8K/4=2Kascacheis4wayassociative.
So,log(2048)=11bitsareneededforaccessingaset.Insideasetweneedtoidentifythecacheentry.
Totalnumberofdistinctcacheentries=232/cacheentrysize=232/32=227
Outofthis227,eachsetwillbegettingonly227/211=216possibledistinctcacheentriesasweusethefirst11bitstoidentifyaset.So,weneed16bitsto
identifyacacheentryinaset,whichisthenumberofbitsinthetagfield.
Sizeofcachetagdirectory=Sizeoftagentry*Numberoftagentries
=16+(2+1+1)bits(2valid,1modified,1replacementasgiveninquestion)*8K
=20*8=160Kbits
Notneededforthisquestion,still:
Validbit:Tellsifthememoryreferencedbythecacheentryisvalid.Initially,whenaprocessisloadedallentriesareinvalid.Onlywhenapageisloaded,its
entrybecomesvalid.
Modifiedbit:Whenprocessorwritestoacachelocationitsmodifiedbitismade1.Thisinformationisusedwhenacacheentryisreplacedentry0meansno
updatetomainmemoryneeded.Entry1meansanupdateisneeded.
Replacementbit:Thisisneededforthecachereplacementpolicy.Explainedinthebelowlink:
https://www.seas.upenn.edu/~cit595/cit595s10/handouts/LRUreplacementpolicy.pdf
name

GATE2010_33top
A 5stage pipelined processor has Instruction Fetch (IF), Instruction Decode (ID), Opearnd Fetch (OF), Perform Operation (PO) and Write Operand (WO)
stages.TheIF,ID,OFandWOstagestake1clockcycleeachforanyinstruction.ThePOstagetakes1clockcycleforADDandSUBinstructions,3clock
cyclesforMULinstructionand6clockcyclesforDIVinstructionrespectively.Operandforwardingisusedinthepipeline.Whatisthenumberofclockcycles
neededtoexecutethefollowingsequenceofinstructions?
Instruction

Meaningofinstruction

t 0 : MUL R 2 , R 0 , R 1

R2 R0 R1

t 1 : DIV R 5 , R 3 , R 4

R 5 R 3 /R 4

t 2 : ADD R 2 , R 5 , R 2
t 3 : SUB R 5 , R 2 , R 6

R2 R5 + R2

R5 R2 R6

(A)13
(B)15
(C)17
(D)19

t1 t2 t3 t4 t5 t6 t7
t8
IF ID OF PO PO PO WO

IF ID OF

PO
IF ID OF


IF ID OF

t9

t10 t11 t12 t13 t14

t15

PO PO PO PO PO

PO WO

PO WO

Operandforwardingallowsanoutputtobepassedforthenextinstruction.HerefromtheoutputofPOstageofDIVinstructionoperandisforwardedtothe
POstageofADDinstructionandsimilarlybetweenADDandSUBinstructions.
http://www.cs.iastate.edu/~prabhu/Tutorial/PIPELINE/forward.html
name

http://gateoverflow.in/book

80/400

2/26/2015

GATEOverflow Book

GATE2010_48,49top
AcomputersystemhasanL1cache,anL2cache,andamainmemoryunitconnectedasshownbelow.TheblocksizeinL1cacheis4words.TheblocksizeinL2
cacheis16words.Thememoryaccesstimesare2nanoseconds,20nanosecondsand200nanosecondsforL1cache,L2cacheandthemainmemoryunit
respectively.

Q.48WhenthereisamissinL1cacheandahitinL2cache,ablockistransferredfromL2cachetoL1cache.Whatisthetimetakenforthistransfer?

(A)2nanoseconds
(B)20nanoseconds
(C)22nanoseconds
(D)88nanoseconds

Q.49WhenthereisamissinbothL1cacheandL2cache,firstablockistransferredfrommainmemorytoL2cache,andthenablockistransferredfromL2cacheto
L1cache.Whatisthetotaltimetakenforthesetransfers?
(A)222nanoseconds
(B)888nanoseconds
(C)902nanoseconds
(D)968nanoseconds

AblockistransferredfromL2toL1.AndL1blocksizebeing4words(sinceL1isrequestingweneedtoconsiderL1blocksizeandnotL2blocksize)and
datawidthbeing4bytes,itrequiresoneL2access(forread)andoneL1access(forstore).So,time=20+2=22ns.
Forthesecondquestion,L2blocksizebeing16wordsanddatawidthbetweenmemoryandL2being4words,werequire4memoryaccesses(forread)and4
L2accesses(forstore).Now,weneedtosendtherequestedblocktoL1whichwouldrequireonemoreL2access(forread)andoneL1access(forstore).So,
totaltime
=4*(200+20)+(20+2)
=880+22
=902ns
name

GATE1995_1.6top
Theprincipleoflocalityjustifiestheuseof
(a)Interrupts
(b)DMA
(c)Polling
(d)CacheMemory
ItisD.
Localityofreferenceisactuallythefrequentaccessingofanystoragelocationorsomevalue.Wecansayinsimplelanguagethatwhateverthingsareused
morefrequently,theyarestoredinthelocalityofreference.Sowehavecachememoryforthepurpose.
name

GATE1996_26top

http://gateoverflow.in/book

81/400

2/26/2015

GATEOverflow Book

Theequationforaccesstimecanbewrittenasfollows(assuminga,barethehitratiosoflevel1andlevel2respectively).
T=T1+(1ab)T2+(1a)*(1b)T3
HereT<=100,T1=50ns,T2=200nsandT3=5000ns.Onsubstitutingthea,bforthefirstcaseweget

T=95.8fora=.8andb=.995.i.eL1=8MandL2=64M.

kireeti

GATE2008IT_38top
Assume that EA = (X)+ is the effective address equal to the contents of location X, with X incremented by one word length after the effective address is
calculated EA = (X) is the effective address equal to the contents of location X, with X decremented by one word length before the effective address is
calculated EA = (X) is the effective address equal to the contents of location X, with X decremented by one word length after the effective address is
calculated.Theformatoftheinstructionis(opcode,source,destination),whichmeans(destinationsourceopdestination).UsingXasastackpointer,which
ofthefollowinginstructionscanpopthetoptwoelementsfromthestack,performtheadditionoperationandpushtheresultbacktothestack.

A)
B)
C)
D)

ADD(X),(X)
ADD(X),(X)
ADD(X),(X)+
ADD(X),(X)

IthinkitshouldbeAas998<1000+998.(iamwritingonlymemorylocationsforsakeofbrevity).letssayspis1000initiallythenafteritcalculatestheEAofsource(whichis1000asit
decrementsaftertheEA)thedestinationbecomes998andthatiswherewewanttostoretheresultasstackisdecrementing...incaseofCandDitbecomes998<998+998

name

GATE2008IT_80top
Consideracomputerwitha4wayssetassociativemappedcacheofthefollowingcharacter
istics:atotalof1MBofmainmemory,awordsizeof1byte,a
blocksizeof128wordsandacachesizeof8KB.
ThenumberofbitsintheTAG,SETandWORDfields,respectivelyare:

A.
B.
C.
D.

7,6,7
8,5,7
8,6,6
9,4,7

Numberofcacheblocks=8KB/(128*1)=64

Numberofsetsincache=Numberofcacheblocks/4(4wayset)
=64/4=16

http://gateoverflow.in/book

82/400

2/26/2015

GATEOverflow Book

So,numberofSETbitsrequired=4(as24=16,andwith4bitswecanget16possibleoutputs)
Wecannowstraightawaychoose(D)asanswerbutforconfirmationcanproceedfurther.
Since, only physical memory information is given we can assume cache is physically tagged (which is anyway the common case even in case of virtual
memory).So,wecandividethephysicalmemoryinto16regionssothat,eachsetmapsintoonlyitsassignedregion.So,sizeofaregionasetcanaddress=
1MB/16=216Bytes=216/128=29cacheblocks(ascacheblocksizeis128words=128bytes).So,whenanaccesscomestoancacheentry,itmustbeable
todeterminewhichoutofthe29possiblephysicalblockitis.Inshortitneeds9bitsforTAG.
Now,cacheblocksizeis128wordsandsotoidentifyawordweneed7bitsforWORD.

name

GATE2008IT_81top
Consideracomputerwitha4wayssetassociativemappedcacheofthefollowingcharacter
istics:atotalof1MBofmainmemory,awordsizeof1byte,a
blocksizeof128wordsandacachesizeof8KB.
Whileaccessingthememorylocation0C795HbytheCPU,thecontentsoftheTAGfieldofthecorrespondingcachelineis

A.
B.
C.
D.

000011000
110001111
00011000
110010101
Asshowninhttps://gateoverflow.in/3403/gate2008it_80wehave16setsincacheandcorrespondingly16regionsinphysicalmemorytowhicheachsetis
mapped.Now,WORDbitsizeis7asweneed7bitstoaddress128possiblewordsinacacheblock.So,thelowest7bitsof0C795Hwillbeusedforthis
givingustheremainingbitsas
0000110001111
Ofthesebits,thelower4areusedforaddressingthe16possiblesets,givingusthetagbits:000011000in(A)choice.
name

GATE2007IT_37top
ConsideraDirectMappedCachewith8cacheblocks(numbered07).Ifthememoryblockrequestsareinthefollowingorder
3,5,2,8,0,63,9,16,20,17,25,18,30,24,2,63,5,82,17,24.
Whichofthefollowingmemoryblockswillnotbeinthecacheattheendofthesequence?

A)
B)
C)
D)

3
18
20
30
ansisB
cachelocation(memoryblock)=blockreqmodnumberofcacheblocks.Sinceeachblockhasonlyonelocation(associativityis1)thelastmod8request
willbeincacheassumingLRUreplacement
0block8,0,16,atendcontains24
1atendscontains17
2atendcontains82
33
420
55
630
763
name

http://gateoverflow.in/book

83/400

2/26/2015

GATEOverflow Book

GATE2006IT_39top
WhichofthefollowingstatementsaboutrelativeaddressingmodeisFALSE?

A)
B)
C)
D)

Itenablesreducedinstructionsize
Itallowsindexingofarrayelementswithsameinstruction
Itenableseasyrelocationofdata
Itenablesfasteraddresscalculationsthanabsoluteaddressing
(D)isfalse.Relativeaddressingcannotbefasterthanabsoluteaddressingasabsoluteaddressmustbecalculatedfromrelativeaddress.
(A)istrueasinsteadofabsoluteaddresswecanuseamuchsmallerrelativeaddressininstructionswhichresultsinsmallerinstructionsize.
(B)Byusingthebaseaddressofarraywecanindexarrayelementsusingrelativeaddressing.
(C)istrueasweonlyneedtochangethebaseaddressincaseofrelocationinstructionsremainthesame.
name

GATE2006IT_40top
Thememorylocations1000,1001and1020havedatavalues18,1and16respectivelybeforethefollowingprogramisexecuted.
MOVI
Rs,1
Moveimmediate
LOAD
Rd,1000(Rs)
Loadfrommemory
ADDI
Rd,1000
Addimmediate
STOREI 0(Rd),20
Storeimmediate
WhichofthestatementsbelowisTRUEaftertheprogramisexecuted?

A)
B)
C)
D)

Memorylocation1000hasvalue20
Memorylocation1020hasvalue20
Memorylocation1021hasvalue20
Memorylocation1001hasvalue20

D)Memorylocation1001hasvalue20.

Rs<1
Rd<1
Rd<1001
storeinaddress1001<20
name

GATE2006IT_42top
Acachelineis64bytes.Themainmemoryhaslatency32nsandbandwidth1G.Bytes/s.Thetimerequiredtofetchtheentirecachelinefromthemainmemory
is

A)
B)
C)
D)

32ns
64ns
96ns
128ns

ans:c
for1secitis10^9bytes
sofor64bytes?
itis64*1/10^9soitis64nsbutmmlatencyis32sototaltimerequiredtoplacecachelineis
64+32=96ns
name

http://gateoverflow.in/book

84/400

2/26/2015

GATEOverflow Book

GATE2006IT_79top
Apipelinedprocessorusesa4stageinstructionpipelinewiththefollowingstages:Instructionfetch(IF),Instructiondecode(ID),Execute(EX)andWriteback
(WB). The arithmetic operations as well as the load and store operations are carried out in the EX stage. The sequence of instructions corresponding to the
statementX=(SR*(P+Q))/Tisgivenbelow.ThevaluesofvariablesP,Q,R,SandTareavailableintheregistersR0,R1,R2,R3andR4respectively,
beforetheexecutionoftheinstructionsequence.
ADD
R5,R0,R1
R5R0+R1
MUL
R6,R2,R5
R6R2*R5
SUB
R5,R3,R6
R5R3R6
DIV
R6,R5,R4
R6R5/R4
STORE
R6,X
XR6

TheIF,IDandWBstagestake1clockcycleeach.TheEXstagetakes1clockcycleeachfortheADD,SUBandSTOREoperations,and3clockcycleseach
forMULandDIVoperations.OperandforwardingfromtheEXstagetotheIDstageisused.Thenumberofclockcyclesrequiredtocompletethesequenceof
instructionsis

A)
B)
C)
D)

10
12
14
16

Thisiswhatihavesolved.soansweris12
name

GATE2004IT_12top
Considerasystemwith2levelcache.AccesstimesofLevel1cache,Level2cacheandmainmemoryare1ns,10ns,and500ns,respectively.Thehitratesof
Level1andLevel2cachesare0.8and0.9,respectively.Whatistheaverageaccesstimeofthesystemignoringthesearchtimewithinthecache?

A)
13.0ns
B)
12.8ns
C)
12.6ns
D)
12.4ns
optionC
t1*h1+(1h1)h2t2+(1h1)(1h2)tm
tmmainmemoryaccesstime
name

GATE2004IT_49top
ACPUhasonlythreeinstructionsI1,I2andI3,whichusethefollowingsignalsintimestepsT1T5:
I1:T1:Ain,Bout,Cin
T2:PCout,Bin
T3:Zout,Ain
http://gateoverflow.in/book

85/400

2/26/2015

GATEOverflow Book

T4:Bin,Cout
T5:End
I2:T1:Cin,Bout,Din
T2:Aout,Bin
T3:Zout,Ain
T4:Bin,Cout
T5:End
I3:T1:Din,Aout
T2:Ain,Bout
T3:Zout,Ain
T4:Dout,Ain
T5:End
WhichofthefollowinglogicfunctionswillgeneratethehardwiredcontrolforthesignalAin?

A)
B)
C)
D)

T1.I1+T2.I3+T4.I3+T3
(T1+T2+T3).I3+T1.I1
(T1+T2).I1+(T2+T4).I3+T3
(T1+T2).I2+(T1+T3).I1+T3

Wejusthavetoseewhichalloptionsgive1wheneverAinis1and0otherwise.
So,Ainis1inT3ofI1,I2andI3.AlsoduringT1ofI1,andT2andT4ofI3.So,answerwillbe
T1.I1+T2.I3+T4.I3+T3.I1+T3.I2+T3.I3
SinceCPUishavingonly3instructions,T3.I1+T3.I2+T3.I3canbereplacedwithT3(wedon'tneedtoseewhichinstructionandAinwillbeactivatedin
timestep3ofalltheinstructions).
So,T1.I1+T2.I3+T4.I3+T3
istheanswer.OptionA.
name

GATE2005IT_49top
Aninstructionsetofaprocessorhas125signalswhichcanbedividedinto5groupsofmutuallyexclusivesignalsasfollows:
Group1:20signals,Group2:70signals,Group3:2signals,Group4:10signals,Group5:23signals.

Howmanybitsofthecontrolwordscanbesavedbyusingverticalmicroprogrammingoverhorizontalmicroprogramming?

A)
0
B)
103
C)
22
D)
55

Inhorizontalmicroprogrammingweneed1bitforeverycontrolword,thereforetotalbitsin
HorizontalMicroprogramming=20+70+2+10+23=125
Nowletsconsiderverticalmicroprogramming,InverticalmicroprogrammingweuseDecoder(nto2n)andoutputlinesareequaltonumberofcontrol
words.Ainputisgivenaccordingtowhatcontrolwordwehavetoselect.
Nowinthisquestionthese5groupscontainsmutuallyexclusivesignals,i.e,theycanbeactivatedoneatatimeforagivengroup,wecansafelyusedecoder.
group1=log220=5(Numberofinputbitsfordecoder,givenoutputisnumberofcontrolwordingivengroup)
group2=log270=7
group3=log22=1
group4=log210=4
group5=og223=5
Totalbitsrequiredinverticalmicroprogramming=5+7+1+4+5=22
Sonumberofcontrolwordssaved=12522=103hence(B)isanswer
http://gateoverflow.in/book

86/400

2/26/2015

GATEOverflow Book

name

GATE2005IT_61top
Considera2waysetassociativecachememorywith4setsandtotal8cacheblocks(07)andamainmemorywith128blocks(0127).Whatmemoryblocks
willbepresentinthecacheafterthefollowingsequenceofmemoryblockreferencesifLRUpolicyisusedforcacheblockreplacement.Assumingthatinitially
thecachedidnothaveanymemoryblockfromthecurrentjob?
0539701655

A)
B)
C)
D)

03571655
035791655
05791655
35791655

128mainmemoryblocksaremappedto4setsincache.So,eachsetmaps32blockseach.Andineachsetthereisplacefortwoblocks(2wayset).
Now,wehave4setsmeaning2indexbits.Also,32blocksgoingtoonesetmeans5tagbits.
Now,these7bitsidentifyamemoryblockandtagbitsareplacedbeforeindexbits.(otherwiseadjacentmemoryreferencesspatiallocalitywillhamper
cacheperformance)
So,basedonthetwoindexbits(lower2bits)blockswillbegoingtosetsasfollows:
SetNumber
0
1
2
3

BlockNumbers
0,16
5,9

3,7,55

Since,eachsethasonly2places,3willbethrowoutasitstheleastrecentlyusedblock.So,finalcontentofcachewillbe
05791655
(C)choice.

name

GATE20152_24top
Assumethatforacertainprocessor,areadrequesttakes50nanosecondsonacachemissand5nanosecondsonacachehit.Supposewhilerunningaprogram,it
wasobservedthat80%oftheprocessor'sreadrequestsresultinacachehit.Theaveragereadaccesstimeinnanosecondsis_____.
Ans14ns=0.8(5)+0.2(50)
name

GATE20152_42top
Consideraprocessorwithbyteaddressablememory.Assumethatallregisters,includingprogramcounter(PC)andProgramStatusWord(PSW),aresizeof
twobytes.Astackinthemainmemoryisimplementedfrommemorylocation(0100) 16 anditgrowsupward.Thestackpointer(SP)pointstothetopelement
ofthestack.ThecurrentvalueofSPis (016E) 16 .TheCALLinstructionisoftwowords,thefirstwordistheopcodeandthesecondwordisthestarting
addressofthesubroutine(oneword=2bytes).TheCALLinstructionisimplementedasfollows:
StorethecurrentvalueofPCinthestack
StorethevalueofPSWregisterinthestack
LoadthestatringaddressofthesubroutineinPC
ThecontentofPCjustbeforethefetchofaCALLinstructionis(5F A0) 16 .AfterexecutionoftheCALLinstruction,thevalueofthestackpointeris

A.
B.

(016A)
(016C )

(0170)

16
16

16
http://gateoverflow.in/book

87/400

2/26/2015

C.
D.

GATEOverflow Book
(0170)
(0172)

16
16

firstwehavetoconsiderherememoryisbyteaddressable

TheCALLinstructionisimplementedasfollows:
StorethecurrentvalueofPCinthestack
pcis2byteitmeanswhenwestorepcinstackitwillincreaseby2
socurrentvalueofSPis(016E)16 +2

StorethevalueofPSWregisterinthestack
pswis2byteitmeanswhenwestorepswinstackitwillincreaseby2
socurrentvalueofSPis(016E)16 +2+2=(0172)

16

name

GATE20151_38top
Consideranonpipelinedprocessorwithaclockrateof2.5gigahertzandaveragecyclesperinstructionoffour.Thesameprocessorisupgradedtoapipelined
processorwithfivestagesbutduetotheinternalpipelinedelay,theclockspeedisreducedto2gigahertz.Assumethattherearenostallsinthepipeline.The
speedupachievedinthispipelinedprocessoris_______________.

Speedup=Oldexecutiontime/Newexecutiontime
Oldexecutiontime=CPI/2.5=4/2.5=1.6ns
Withpipelining,eachinstructionneeds1.6*2.5/2=2ns
Thereare5stagesandwhenthereisnopipelinestall,thiscangiveaspeedupofupto5(happenswhenallstagestakesamenumberofcycles).So,average
executiontime=2/5=0.4ns
So,speedupcomparedtononpipelinedversion=1.6/0.4=4
Ref:Q:12.10http://faculty.washington.edu/lcrum/Archives/TCSS372AF06/HW8.doc
name

GATE20153_14top
Consideramachinewithabyteaddressablemainmemoryof2 20 bytes,blocksizeof16bytesandadirectmappedcachehaving2 12 cachelines.Letthe
addressesoftwoconsecutivebytesinmainmemorybe(E201F ) 16 and(E2020) 16 .Whatarethetagandcachelineaddresses(inhex)formainmemory
address(E201F ) 16 ?

A.
B.
C.
D.

E,201
F,201
E,E20
2,01F

Blocksizeof16bytesmeansweneed4offsetbits.(Thelowest4digitsofmemoryaddressareoffsetbits)
Numberofsetsincache(cachelines)=212sothenextlower12bitsareusedforsetindexing.
Thetop4bits(outof20)aretagbits.
So,AnswerA.
name

GATE20153_47top
ConsiderthefollowingcodesequencehavingfiveinstructionsfromI 1 toI 5 .Eachoftheseinstructionshasthefollowingformat.
http://gateoverflow.in/book

88/400

2/26/2015

GATEOverflow Book

OPRi,Rj,Rk
WhereoperationOPisperformedoncontentsofregistersRjandRkandtheresultisstoredinregisterRi.
I1

:ADDR1,R2,R3

I2

:MULR7,R1,R3

I3

:SUBR4,R1,R5

I4

:ADDR3,R2,R4

I5

:MULR7,R8,R9

Considerthefollowingthreestatements.
S1:ThereisanantidependencebetweeninstructionsI 2 andI 5
S2:ThereisanantidependencebetweeninstructionsI 2 andI 4
S3:Withinaninstructionpipelineanantidependencealwayscreatesoneormorestalls
Whichoneoftheabovestatementsis/arecorrect?

A.
B.
C.
D.

OnlyS1istrue
OnlyS2istrue
OnlyS1andS3aretrue
OnlyS2andS3aretrue

AnswershouldbeB.
Antidependencecanbeovercomeinpipelineusingregisterrenaming.So,"always"inS3makesitfalse.Also,ifI2iscompletedbeforeI4(executionstage
ofMUL),thenalsotherewon'tbeanystall.
ppm

http://gateoverflow.in/book

89/400

2/26/2015

GATEOverflow Book

OperatingSystemtop
GATE2012_8top
Aprocessexecutesthecode

fork();
fork();
fork();

Thetotalnumberofchildprocessescreatedis
(A)3
(B)4
(C)7
(D)8
Ateachfork()theno.ofprocessesbecomesdoubled.So,after3forkcalls,thetotalno.ofprocesseswillbe8.Outofthis1istheparentprocessand7are
childprocesses.So,totalnumberofchildprocessescreatedis7.
name

Cananyonepleasehelp(orprovidesomelinkstatedclearly)inMultilevelPagetableandPaging
withSegmentation?top
NeedtheclearconceptofhierarchyofPagetable.
Thesetwolinksareverygoodforpaging.
https://courses.cs.washington.edu/courses/cse451/08wi/ospaging.ppt
http://www.cs.columbia.edu/~junfeng/10spw4118/lectures/l21page.pdf
name

Pagereplacementtop
Amemorypagecontainingaheavilyusedvariablethatwasinitializedveryearlyandisinconstantuseisremovedwhen
(a)LRUpagereplacementalgorithmisused
(b)FIFOpagereplacementalgorithmisused
(c)LFUpagereplacementalgorithmisused
(d)Noneoftheabove

LRU can't be used as the page is still is in use , so it will be in most high priority.
LFU can't be used as it has been accessed several time , it's frequency value will be larger.
FIFOcan do it as it only considers the time the page came in RAM. So the page can be deleted by FIFO .also from that statement we
can assume FIFO wasn't in use till now.
name

GATE2013_52,53top
Acomputeruses46bitvirtualaddress,32bitphysicaladdress,andathreelevelpagedpagetableorganization.Thepagetablebaseregisterstoresthebase
addressofthefirstleveltable(T1),whichoccupiesexactlyonepage.EachentryofT1storesthebaseaddressofapageofthesecondleveltable(T2).Each
entryofT2storesthebaseaddressofapageofthethirdleveltable(T3).EachentryofT3storesapagetableentry(PTE).ThePTEis32bitsinsize.The
processorusedinthecomputerhasa1MB16waysetassociativevirtuallyindexedphysicallytaggedcache.Thecacheblocksizeis64bytes.
WhatisthesizeofapageinKBinthiscomputer?
(A)2(B)4(C)8(D)16
Whatistheminimumnumberofpagecoloursneededtoguaranteethatnotwosynonymsmaptodifferentsetsintheprocessorcacheofthiscomputer?
(A)2(B)4(C)8(D)16

Letthepagesizebex .

http://gateoverflow.in/book

46

90/400

2/26/2015

GATEOverflow Book

Sincevirtualaddressis46bits,wehavetotalnumberofpages=

46

WeshouldhaveanentryforeachpageinlastlevelpagetablewhichhereisT3.So,
numberofentriesinT3=

46

Eachentrytakes32bits=4bytes.So,sizeofT3=

46

4 =

48

bytes

Now,T3mustoccupy(sizeofT3/pagesize)pagesandforeachofthesepagewemusthaveanT2entry.So,no.ofentriesinT2
2

48
x

48

Now,sizeofT2= 2

48

bytes=

50

50

pages

Now,foreachofthesepagewemusthaveanentryinT1.So,numberofentriesinT1
=

50

AndsizeofT1=

50

4 =

52

Giveninquestion,sizeofT1ispagesizewhichwetookasx .So,
x =

52

= 2

x = 2

52

13

= 8K B

Min.no.ofpagecolorbits=No.ofsetindexbits+no.ofoffsetbitsno.ofpageindexbits(Thisensuresnosynonymmapstodifferentsetsinthecache)
Wehave1MBcacheand64Bcacheblocksize.So,
numberofsets=1MB/(64B*Numberofblocksineachset)=16K/16(16waysetassociative)=1K=210.
So,weneed10indexbits.Now,eachblockbeing64(26)bytesmeansweneed6offsetbits.
Andwealreadyfoundpagesize=8KB=213,so13bitstoindexapage
Thus,no.ofpagecolorbits=10+613=3.
With3pagecolorbitsweneedtohave23=8differentpagecolors

Explanationfor53:
Asynonymisaphysicalpagehavingmultiplevirtualaddressesreferringtoit.So,whatwewantisnotwosynonymvirtualaddressestomaptotwodifferent
sets,whichwouldmeanaphysicalpagecouldbeintwodifferentcachesets.Thisproblemneveroccursinaphysicallyindexedcacheasindexinghappens
via physical address bits and so one physical page can never go to two different sets in cache. In virtually indexed cache, we can avoid this problem by
ensuringthatthebitsusedforlocatingacacheblock(index+offset)ofthevirtualandphysicaladdressesarethesame.
Inourcasewehave6offsetbits+10bitsforindexing.So,wewanttomakethese16bitssameforbothphysicalandvirtualaddress.Onethingisthatthe
pageoffsetbits13bitsfor8KBpage,isalwaysthesameforphysicalandvirtualaddressesastheyarenevertranslated.So,wedon'tneedtomakethese13
bitssame.Wehavetoonlymaketheremaining19+613=3bitssame.Pagecoloringisawaytodothis.Here,allthephysicalpagesarecoloredanda
physicalpageofonecolorismappedtoavirtualaddressbyOSinsuchawaythatasetincachealwaysgetspagesofthesamecolor.So,inordertomake
the3bitssame,wetakeallcombinationsofit(23=8)andcolorsthephysicalpageswith8colorsandacachesetalwaysgetsapageofonecoloronly.(In
pagecoloring,itisthejobofOStoensurethatthe3bitsarethesame).
http://ece.umd.edu/courses/enee646.F2007/Cekleov1.pdf
name

GATE2008_67top
Aprocessoruses36bitphysicaladdressand32bitvirtualaddresses,withapageframesizeof4Kbytes.Eachpagetableentryisofsize4bytes.Athreelevel
pagetableisusedforvirtualtophysicaladdresstranslation,wherethevirtualaddressisusedasfollows:
Bits3031areusedtoindexintothefirstlevelpagetable.
Bits2129areusedtoindexintothe2ndlevelpagetable.
Bits1220areusedtoindexintothe3rdlevelpagetable.
Bits011areusedasoffsetwithinthepage.
http://gateoverflow.in/book

91/400

2/26/2015

GATEOverflow Book

Thenumberofbitsrequiredforaddressingthenextlevelpagetable(orpageframe)inthepagetableentryofthefirst,secondandthirdlevelpagetablesare
respectively
a)20,20,20
b)24,24,24
c)24,24,20
d)25,25,24

Physicaladdressis36bits.So,numberofpageframe'spossible=36/12=24(12offsetbitsasgiveninquestion).So,thethirdlevelpagetablemusthave24
bitsforaddressingthepageframes.
Physical memory size

Numberofthirdlevelpagetablespossible= Size of a third level page table


=236/(Numberofentriesinthirdlevelpagetable*Sizeofanentry)
=236/(29*4)(bits1220gives9bits)
=236/211
=225

http://www.cs.utexas.edu/~lorenzo/corsi/cs372/06F/hw/3sol.htmlSeeProblem3,secondpartsolutionItclearlysaysthatweshouldnotassumethatpage
tablesarepagealigned.
So,weneed25bitsinsecondlevelpagetableforaddressingthethirdlevelpagetables.
Physical memory size

Now,numberofsecondlevelpagetablespossible= Size of a second level page table


=236/(Numberofentriesinsecondlevelpagetable*Sizeofanentry)
=236/(29*4)(bits2129gives9bits)
=236/211
=225

So,weneed25bitsforaddressingthesecondlevelpagetablesaswell.
So,answeris(D).
name

GATE1991_02,iiitop
02.Matchthepairsinthefollowingquestionsbywritingthecorrespondinglettersonly.

AR
BP
CS
DQ
name

GATE1992_02,xtop
02.Choosethecorrectalternatives(morethanonemaybecorrect)andwritethecorrespondinglettersonly:

Ans=optionB
currentlysemaphoreis7soafter20P(wait)operationitwillcometo12thenfor15V(signal)operationthevaluecomesto2.
sanjeev_zerocode

http://gateoverflow.in/book

92/400

2/26/2015

GATEOverflow Book

GATE2001_1.7top
Morethanonewordareputinonecacheblockto
(a)exploitthetemporallocalityofreferenceinaprogram
(b)exploitthespatiallocalityofreferenceinaprogram
(c)reducethemisspenalty
(d)noneoftheabove
exploitthespatiallocalityofreferenceinaprogramas,ifthenextlocalityisaddressedimmediately,itwillalreadybeinthecache.
name

GATE2003_78,79top
Aprocessoruses2levelpagetablesforvirtualtophysicaladdresstranslation.Pagetablesforbothlevelsarestoredinthemainmemory.Virtualandphysical
addressesareboth32bitswide.Thememoryisbyteaddressable.Forvirtualtophysicaladdresstranslation,the10mostsignificantbitsofthevirtualaddressare
usedasindexintothefirstlevelpagetablewhilethenext10bitsareusedasindexintothesecondlevelpagetable.The12leastsignificantbitsofthevirtual
addressareusedasoffsetwithinthepage.Assumethatthepagetableentriesinbothlevelsofpagetablesare4byteswide.Further,theprocessorhasa
translationlookasidebuffer(TLB),withahitrateof96%.TheTLBcachesrecentlyusedvirtualpagenumbersandthecorrespondingphysicalpagenumbers.
Theprocessoralsohasaphysicallyaddressedcachewithahitrateof90%.Mainmemoryaccesstimeis10ns,cacheaccesstimeis1ns,andTLBaccesstimeis
also1ns.
78.Assumingthatnopagefaultsoccur,theaveragetimetakentoaccessavirtualaddressisapproximately(tothenearest0.5ns)
(A)1.5ns(B)2ns(C)3ns(D)4ns
79.Supposeaprocesshasonlythefollowingpagesinitsvirtualaddressspace:twocontiguouscodepagesstartingatvirtualaddress0x00000000,two
contiguousdatapagesstartingatvirtualaddress0x00400000,andastackpagestartingatvirtualaddress0xFFFFF000.Theamountofmemoryrequiredfor
storingthepagetablesofthisprocessis
(A)8KB(B)12KB(C)16KB(D)20KB

78.It'sgivencacheisphysicallyaddressed.So,addresstranslationisneededforallmemoryaccesses.

Average access time = Average address translation time + Average memory access time
= 1ns (TLB is accessed for all accesses) + 2*10*0.04 (2 page tables accessed from main memory in case of TLB miss) + Average memory access ti
= 1.8ns + Cache access time + Average main memory access time
= 1.8ns + 1 * 0.9 (90% cache hit) + 0.1 * 10 (main memory is accessed for cache misses only)
= 1.8ns + 0.9 + 1
= 3.7ns

79.Firstlevelpagetableisaddressedusing10bitsandhencecontains210entries.Eachentryis4bytesandhencethistablerequires4KB.Now,theprocess
usesonly3uniqueentriesfromthis1024possibleentries(twocodepagesstartingfrom0x00000000andtwodatapagesstartingfrom0x00400000have
samefirst10bits).Hence,thereareonly3secondlevelpagetables.Eachofthesesecondlevelpagetablesarealsoaddressedusing10bitsandhenceofsize
4KB.So,
total page table size of the process
= 4 KB + 3 * 4 KB
= 16 KB

gatecse

GATE2002_1.23top
Theoptimalpagereplacementalgorithmwillselectthepagethat

A.
B.
C.
D.

Hasnotbeenusedforthelongesttimeinthepast
Willnotbeusedforthelongesttimeinthefuture
Hasbeenusedleastnumberoftimes
Hasbeenusedmostnumberoftimes

Optimalpagereplacementalgorithmwillalwaysselectthepagethatwillnotbeusedforthelongesttimeinthefutureforreplacement,andthatiswhytheit
iscalledoptimalpagereplacementalgorithm.Hence,(B)choice.
name

GATE2003_76top
WhichofthefollowingisNOTanadvantageofusingshared,dynamicallylinkedlibrariesasopposedtousingstatisticallylinkedlibraries?
http://gateoverflow.in/book

93/400

2/26/2015

GATEOverflow Book

A. Smallersizesofexecutablefiles
B. Lesseroverallpagefaultrateinthesystem
C. Fasterprogramstartup
D. Existingprogramsneednotberelinkedtotakeadvantageofnewerversionsoflibraries
optionc)DLLtakesmoretimeinprogramsetup(inloadingandlinkingphase)
SinceDLLsareseparatedfromexecutable,thesizeofexecutablebecomessmaller.
SinceDLLsaresharedamongmultipleexecutables,thetotalmemoryusageofthesystemgoesdownandhenceoverallpagefaultratedecreases.
Dynamiclinkingtakesplaceduringprogramruntime.So,ifaDLLisreplacedtoanewversion,itwillautomaticallygetlinkedduringruntime.Thereisno
explicitrelinkingrequiredasinthecaseofstaticlinking.(ThisworksbylinkingtheDLLcallstoGlobalOffsetTableandthecontentsofthistableisfilled
duringprogramrun.So,asimplejumpinstaticlinkingbecomesanindirectjumpindynamiclinking).
name

GATE2004_12top

Questionsays"singlesequentialuserprocess".So,alltherequeststodiskschedulerwillbeinsequenceandhencethereisnouseofanydiskscheduling
algorithm.Anyonewillgivethesamesequenceandhencetheimprovementwillbe0%.
name

GATE2004_21top
Theminimumnumberofpageframesthatmustbeallocatedtoarunningprocessinavirtualmemoryenvironmentisdeterminedby
(a)theinstructionsetarchitecture
(b)pagesize
(c)physicalmemorysize
(d)numberofprocessesinmemory
Aistheanswerofthisquestion,b,c,doptionsdon'tmakeasense
name

GATE2007_55top

http://gateoverflow.in/book

94/400

2/26/2015

GATEOverflow Book

TheanswerisB.
P1

TheGanttchartofexecutionofprocesses
P2
P3
P2

P4

02030405570
WaitingtimeforprocessP2=CompletiontimeArrivaltimebursttime=551525=15
name

GATE2009_31top

AnswerisB.

name

GATE2005_21top

Answerisb.
anshu

GATE1999_2.11top
Whichofthefollowingis/areadvantage(s)ofvirtualmemory?
(a)Fasteraccesstomemoryonanaverage.
(b)Processescanbegivenprotectedaddressspaces.
(c)Linkercanassignaddressesindependentofwheretheprogramwillbeloadedinphysicalmemory.
(d)Programlargerthanthephysicalmemorysizecanberun.
Virtualmemoryprovidesaninterfacethroughwhichprocessesaccessthephysicalmemory.So,
(a)Isfalseasdirectaccesscanneverbeslower.
(b)Istrueaswithoutvirtualmemoryitisdifficulttogiveprotectedaddressspacetoprocessesastheywillbeaccessingphysicalmemorydirectly.No
protectionmechanismcanbedoneinsidethephysicalmemoryasprocessesaredynamicandnumberofprocesseschangesfromtimetotime.
(c)Positionindependentcanbeproducedevenwithoutvirtualmemorysupport.
(d)Thisisoneprimaryuseofvirtualmemory.Virtualmemoryallowsaprocesstorunusingavirtualaddressspaceandasandwhenmemoryspaceis
required,pagesareswappedin/outfromthediskifphysicalmemorygetsfull.
name

GATE1999_19top
http://gateoverflow.in/book

95/400

2/26/2015

GATEOverflow Book

A)SIzeofeachsegment=216/8=213
letthesizeofpagebe2kbytes
Weneedapagetableentryforeachpage.Forasegmentofsize213,numberofpagesrequiredwillbe
213kandsoweneed213kpagetableentries.Now,
213k*2=2k(Asapagetableentrysizeis2bytesandweassumedpagesizeis2kandthatpagetablefitsinapage)
k=7bits
sopagesize=128bytes

B)Eachsegmentwillhave213/29=24pagetableentries
soallpagetableentriesofasegmentwillresideinthecache.
Segmentnumberwilldifferentiatebetweenpagetableentryofeachsegmentinthecache
totalsegments=8
Therefore3bitsofTagisrequired

C)NumberofPages=216/29=27
Bitsoccupiedbypagenumber=7bits
+1validbit
+3pageprotectionbits
+1dirtybit
=12bits
sizeofeachpagetableentry=2bytes=16bits
bitsleftforaging=1612=4bits

CORRECTMEIFIAMWRONG!!!
name

GATE2013_39top
Acertaincomputationgeneratestwoarraysaandbsuchthata[i]=f(i)for0i<nandb[i]=g(a[i])for0i<n.Supposethiscomputationisdecomposedinto
twoconcurrentprocessesXandYsuchthatXcomputesthearrayaandYcomputesthearrayb.TheprocessesemploytwobinarysemaphoresRandS,both
initializedtozero.Thearrayaissharedbythetwoprocesses.Thestructuresoftheprocessesareshownbelow.
ProcessX:
private i;

http://gateoverflow.in/book

96/400

2/26/2015

GATEOverflow Book

for (i=0; i< n; i++) {


a[i] = f(i);
ExitX(R, S);
}

ProcessY:
private i;
for (i=0; i< n; i++) {
EntryY(R, S);
b[i] = g(a[i]);
}

WhichoneofthefollowingrepresentstheCORRECTimplementationsofExitXandEntryY?
(A)
ExitX(R, S) {
P(R);
V(S);
}
EntryY(R, S) {
P(S);
V(R);
}
(B) ExitX(R, S) {
V(R);
V(S);
}
EntryY(R, S) {
P(R);
P(S);
}
(C) ExitX(R, S) {
P(S);
V(R);
}
EntryY(R, S) {
V(S);
P(R);
}
(D) ExitX(R, S) {
V(R);
P(S);
}
EntryY(R, S) {
V(S);
P(R);
}

Achoice:
XiswaitingonRandYiswaitingonX.So,bothcannotproceed.
http://gateoverflow.in/book

97/400

2/26/2015

GATEOverflow Book

Bchoice:
ProcessXisdoingSignaloperationonRandSwithoutanywaitandhencemultiplesignaloperationscanhappenonthebinarysemaphoresoProcessY
won'tbeabletogetexactlynsuccessfulwaitoperations.i.e.,ProcessYmaynotbeabletocompletealltheiterations.
Cchoice:
ProcessXdoesWait(S)followedbySignal(R)whileProcessYdoesSignal(S)followedbyWait(R).So,thisensuresthatnotwoiterationsofeitherXorY
canproceedwithoutaniterationoftheotherbeingexecutedinbetween.i.e.,thisensuresthatallniterationsofXandYsucceedsandhencetheanswer.
Dchoice:
ProcessXdoesSignal(R)followedbyWait(S)whileProcessYdoesSignal(S)followedbyWait(R).ThereisaproblemherethatXcandotwoSignal(R)
operationwithoutaWait(R)beingdoneinbetweenbyY.Thishappensinthefollowingscenario:
ProcessY:DoesSignal(S)Wait(R)failsgoestosleep.
ProcessX:DoesSignal(R)Wait(S)succeedsInnextiterationSignal(R)againhappens
So,thiscanresultinsomeSignaloperationsgettinglostasthesemaphoreisabinaryoneandthusProcessYmaynotbeabletocompletealltheiterations.If
wechangetheorderofSignal(S)andWait(R)inEntryY,thenDoptionalsocanwork.
name

GATE1998_1.29top

AnsB
http://en.wikipedia.org/wiki/Spooling
name

GATE1998_1.31top

answerisoption(b)
Initiallysemaphoreis10,then6downoperationsareperformedmeans(106=4)and4upoperationsmeans(4+4=8)
so,atlastoption(b)8iscorrect.
name

GATE1998_1.32top

Forasystemtobedeadlockfree,Sumofmaxneedofprocesses<No.ofprocesses+No.ofresources
2n<n+6
AnsA
name

GATE1998_2.9top

http://gateoverflow.in/book

98/400

2/26/2015

GATEOverflow Book

AnsisC
http://en.wikipedia.org/wiki/Disk_formatting
name

GATE20141_31top
AnoperatingsystemusestheBanker'salgorithmfordeadlockavoidancewhenmanagingtheallocationofthreeresourcetypesX,Y,andZtothreeprocesses
P0,P1,andP2.Thetablegivenbelowpresentsthecurrentsystemstate.Here,theAllocationmatrixshowsthecurrentnumberofresourcesofeachtype
allocatedtoeachprocessandtheMaxmatrixshowsthemaximumnumberofresourcesofeachtyperequiredbyeachprocessduringitsexecution.

P0

X
0

Allocation
Y
Z
0
1

X
8

Max
Y
4

Z
3

P1
P2

3
2

2
1

6
3

2
3

0
3

0
1

Thereare3unitsoftypeX,2unitsoftypeYand2unitsoftypeZstillavailable.Thesystemiscurrentlyinasafestate.Considerthefollowingindependent
requestsforadditionalresourcesinthecurrentstate:
REQ1:P0requests0unitsofX,0unitsofYand2unitsofZ
REQ2:P1requests2unitsofX,0unitsofYand0unitsofZ
WhichoneofthefollowingisTRUE?
(A)OnlyREQ1canbepermitted.
(B)OnlyREQ2canbepermitted.
(C)BothREQ1andREQ2canbepermitted.
(D)NeitherREQ1norREQ2canbepermitted.

OptionB
Request1ifpermitteddoesnotleadtoasafestate.
AfterallowingReq1,
Allocated:Max:Requirement:
P0003843840
P1320620300
P2211333122
Available:X=3Y=2Z=0

NowwecansatisfyP1'srequirementcompletely.SoAvailabebecomes:X=6,Y=4,Z=0.
SinceZisnotavailablenow,neitherP0norP2'srequirementcanbesatisfied.Soitsanunsafestate.
name

GATE20141_32top
ConsiderthefollowingsetofprocessesthatneedtobescheduledonasingleCPU.Allthetimesaregiveninmilliseconds.

ProcessName
A
B
C
http://gateoverflow.in/book

ArrivalTime
0
3
5

ExecutionTime
6
2
4
99/400

2/26/2015

D
E

GATEOverflow Book

7
10

6
3

Usingtheshortestremainingtimefirstschedulingalgorithm,theaverageprocessturnaroundtime(inmsec)is____________________.

So,answeris7.2msec..
name

GATE20141_33top
Assumethatthereare3pageframeswhichareinitiallyempty.Ifthepagereferencestringis1,2,3,4,2,1,5,3,2,4,6,thenumberofpagefaultsusingthe
optimalreplacementpolicyis__________.

Ans:initiallyallemptyframesfillby1,2,3soalltimepagefaultwhichis3.
thennext4wasnotavailableinframesetsowelookataheadofrequestwhichwascominglastwereplace4withthatso3willbereplaceby4andlike
wisenext2and1ispresentalreadysonopagefaultandthennext5isnotpresentsoreplacewith1andthen3wasnotpresentandreplacewith5andthen2
and4arepresentalreadysonopagefaultandthenlast6thwasnotalreadytheresopagefault.
Sototalpagefaultat:1,2,3,4,5,3,6.so,total7pagefaultoccur...
name

Gate2006_62top
ACPUgenerates32bitvirtualaddresses.Thepagesizeis4KB.Theprocessorhasatranslationlookasidebuffer(TLB)whichcanholdatotalof128page
tableentriesandis4waysetassociative.TheminimumsizeoftheTLBtagis:
(A)11bits
(B)13bits
(C)15bits
(D)20bits
pagesizeof4KB..sooffsetbitsare12bits..
soremainingbitsofvirtualaddress3212=20bitswillbeusedforindexing...
numberofsets=128/4=32(4wayset)=>5bits..
sotagbits=205=15bits..
sooption(C)
name

GATE2006_64top
Considerthreeprocesses(processid0,1,2respectively)withcomputetimebursts2,4and8timeunits.Allprocessesarriveattimezero.Considerthelongest
remainingtimefirst(LRTF)schedulingalgorithm.InLRTFtiesarebrokenbygivingprioritytotheprocesswiththelowestprocessid.Theaverageturnaround
timeis:
(A)13units
(B)14units
(C)15units
(D)16units

A.
http://gateoverflow.in/book

100/400

2/26/2015

GATEOverflow Book

GanttChartisasfollows.
GanttChart
P2 P2 P2 P2 P1 P2 P1 P2 P0 P1 P2 P0 P1 P2
P.ID
P0
P1
P2
TOTAL

A.T
0
0
0

SchedulingTable
B.T
C.T
2
12
4
13
8
14

T.A.T.
12
13
14
39

W.T.
10
9
6
25

A.T.=ArrivalTime
B.T.=BurstTime
C.T=CompletionTime.
T.A.T.=TurnAroundTime
W.T=WaitingTime.
AverageTAT=39/3=13units.
name

GATE20142_55top
Consideramainmemorysystemthatconsistsof8memorymodulesattachedtothesystembus,whichisonewordwide.Whenawriterequestismade,thebus
isoccupiedfor100nanoseconds(ns)bythedata,address,andcontrolsignals.Duringthesame100ns,andfor500nsthereafter,theaddressedmemorymodule
executesonecycleacceptingandstoringthedata.The(internal)operationofdifferentmemorymodulesmayoverlapintime,butonlyonerequestcanbeonthe
busatanytime.Themaximumnumberofstores(ofonewordeach)thatcanbeinitiatedin1millisecondis________

Whenawriterequestismade,thebusisoccupiedfor100ns.So,between2writesatleast100nsintervalmustbethere.
Now,afterawriterequest,for100+500=600ns,thecorrespondingmemorymoduleisbusystoringthedata.But,assumingthenextstoresaretoadifferent
memorymodule(wehavetotally8modulesinquestion),wecanhaveconsecutivestoresatintervalsof100ns.So,maximumnumberofstoresin1ms
=103*1/(100*109)=10,000
name

GATE20143_31top
A system contains three programs and each requires three tape units for its operation. The minimum number of tape units which the system must have such that
deadlocksneverariseis_________.

forthistypesofproblemsinwhicheveryprocessismakingsamenumberofrequest,usetheformulan.(m1)+1<=r
wheren=no.ofprocesses
m=resourcerequestmadebyprocesses
r=no.ofresources
soaboveproblemcanbesolvedas3.(31)+1<=ri.e.7<=r
minnumberofresourcerequiredare7
nehapawar

GATE20143_33top
ConsiderapaginghardwarewithaTLB.Assumethattheentirepagetableandallthepagesareinthephysicalmemory.Ittakes10millisecondstosearchthe
TLBand80millisecondstoaccessthephysicalmemory.IftheTLBhitratiois0.6,theeffectivememoryaccesstime(inmilliseconds)is_________.
EMAT=TLBhit*(TLBaccesstime+memoryaccesstime)+TLBmiss(TLBaccesstime+pagetableaccesstime+memoryaccesstime)
=0.6(10+80)+0.4(10+80+80)
=54+68
=122msec
nehapawar
http://gateoverflow.in/book

101/400

2/26/2015

GATEOverflow Book

GATE2011_20top
Letthepagefaultservicetimebe 10msinacomputerwithaveragememoryaccesstimebeing 20ns.Ifonepagefaultisgeneratedforevery 106 memory
accesses,whatistheeffectiveaccesstimeforthememory?
(A)21ns
(B)30ns
(C)23ns
(D)35ns

effectivememoryaccesstime=pagefault*pagefaultservicetime+nopagefault*memoryaccesstime
sohere
EMAT=1/106*10*103+(11/106)*20*109
=10*109+20*109(11/106valuecanbeneglected)
=30nsec
ansisb
nehapawar

GATE2011_35top
ConsiderthefollowingtableofarrivaltimeandbursttimeforthreeprocessesP0,P1andP2.

Process
P0
P1
P2

ArrivalTime
0ms
1ms
2ms

BurstTime
9ms
4ms
9ms

Thepreemptiveshortestjobfirstschedulingalgorithmisused.Schedulingiscarriedoutonlyatarrivalorcompletionofprocesses.Whatistheaveragewaitingtime
forthethreeprocesses?
(A)5.0ms
(B)4.33ms
(C)6.33ms
(D)7.33ms

AnswerisA.5ms
P0

P1

GanttChart
P1

P0

P2

01251322

name

GATE2011_44top
Anapplicationloads100librariesatstartup.Loadingeachlibraryrequiresexactlyonediskaccess.Theseektimeofthedisktoarandomlocationisgivenas10ms.
Rotationalspeedofdiskis6000rpm.Ifall100librariesareloadedfromrandomlocationsonthedisk,howlongdoesittaketoloadalllibraries?(Thetimetotransfer
datafromthediskblockoncetheheadhasbeenpositionedatthestartoftheblockmaybeneglected.)

(A)0.50s
(B)1.50s

http://gateoverflow.in/book

102/400

2/26/2015

GATEOverflow Book

(C)1.25s
(D)1.00s

diskaccesstime=seektime+rotationallatency+transfertime(giventhattransfertimeisneglected)
hereseektime=10msec
rotationalspeed=6000rpm
60sec6000rotation
1rotation60/6000sec
rotationallatency1/2*60/6000sec=5msec
totaltimetotransferonelibrary=10+5=15msec
totaltimetotransfer100libraries=100*15msec=1.5sec
nehapawar

GATE2012_42top
Considerthevirtualpagereferencestring
1,2,3,2,4,1,3,2,4,1
onademandpagedvirtualmemorysystemrunningonacomputersystemthathasmainmemorysizeof3pageframeswhichareinitiallyempty.LetLRU ,
F I F O andOP T I M AL denotethenumberofpagefaultsunderthecorrespondingpagereplacementpolicy.Then
(A)OP T I M AL < LRU < F I F O
(B)OP T I M AL < F I F O < LRU
(C)OP T I M AL = LRU
(D)OP T I M AL = F I F O
PagefaultforLRU=9,FIFO=6,OPTIMAL=5
Ans(B)
name

GATE2010_23top
ConsiderthemethodsusedbyprocessesP1andP2foraccessingtheircriticalsectionswheneverneeded,asgivenbelow.Theinitialvaluesofsharedboolean
variablesS1andS2arerandomlyassigned.

MethodusedbyP1
while (S1==S2);
Critical Section
S1=S2;

MethodusedbyP2
while (S1!=S2);
Critical Section
S2 = not(S1)

Whichoneofthefollowingstatementsdescribesthepropertiesachieved?
(A)Mutualexcusionbutnotprogress
(B)Progressbutnotmutualexclusion
(C)Neithermutualexclusionnorprogress
(D)Bothmutualexclusionandprogress

ansisA..inthismutualexclusionissatisfied,onlyoneprocesscanaccessthecriticalsectionatparticulartimebuthereprogresswillnotsatisfiedbecause
supposewhens1=1ands2=0andprocessp1isnotinterestedtoenterintocriticalsectionbutp2wanttoentercriticalsection.P2isnotabletoentercritical
sectioninthisasonlywhenp1finishesexecution,thenonlyp2canenter(thenonlys1=s2conditionbesatisfied).Progresswillnotbesatisfiedwhenany
processwhichisnotinterestedtoenterintothecriticalsectionwillnotallowotherinterestedprocesstoenterintothecriticalsection.
nehapawar

GATE2010_24top
AsystemusesFIFOpolicyforsystemreplacement.Ithas4pageframeswithnopagesloadedtobeginwith.Thesystemfirstaccesses100distinctpagesin
someorderandthenaccessesthesame100pagesbutnowinthereverseorder.Howmanypagefaultswilloccur?
http://gateoverflow.in/book

103/400

2/26/2015

GATEOverflow Book

(A)196
(B)192
(C)197
(D)195
ansisA
whenweaccessthe100distinctpageinsomeorder(supposeorderis123....100)thentotalpagefaultoccursare100.andinlast,framecontainthepages
100999897.whenwereversethestring(100,99,98....1)thenfirstfourpagewillnotcausethepagefaultbcztheyalreadypresentinframebuttheremaining
96pagewillcause96pagefault,sototalpagefaultare100+96=196
nehapawar

GATE2010_25top
Whichofthefollowingstatementsaretrue?
I. Shortestremainingtimefirstschedulingmaycausestarvation
II. Preemptiveschedulingmaycausestarvation
III. RoundrobinisbetterthanFCFSintermsofresponsetime
(A)Ionly
(B)IandIIIonly
(C)IIandIIIonly
(D)I,IIandIII
ansisD
i)InSRTF,jobwiththeshorestCPUburstwillbescheduledfirstbczofthisprocesswithlargeCPUburstmaysufferfromstarvation
ii)Inpreemptivescheduling,supposeprocessP1isexecutinginCPUandaftersometimeprocessP2withhighprioritythenP1willarriveinreadyqueue
thenp1isprremptedandp2willbroughtintoCPUforexecution.inthiswayifprocesswhichisarrivinginreadyqueueisofhigherprioiritythenp1,thenp1
isalwayspreemptedanditmaypossiblethatitsufferfromstarvation.
iii)roundrobinwillgivebetterresponsetimethenFCFS,inFCFSwhenprocessisexecuting,itexecuteduptoitscompletebursttime,butinroundrobinit
willexecuteuptotimequantum.
nehapawar

GATE1997_3.9top
Thrashing
A.
B.
C.
D.

reducespageI/O
decreasesthedegreeofmultiprogramming
impliesexcessivepageI/O
improvethesystemperformance

C.impliesexcessivepagei/o
http://en.wikipedia.org/wiki/Thrashing_%28computer_science%29
name

GATE1997_3.10top

Thedirtybitallowsforaperformanceoptimization.Apageondiskthatispagedintophysicalmemory,thenreadfrom,andsubsequentlypagedoutagain
doesnotneedtobewrittenbacktodisk,sincethepagehasn'tchanged.However,ifthepagewaswrittentoafterit'spagedin,itsdirtybitwillbeset,
indicatingthatthepagemustbewrittenbacktothebackingstoreanswer:a
name
http://gateoverflow.in/book

104/400

2/26/2015

GATEOverflow Book

GATE2010_46top
Asystemhasn resourcesR 0 , , R n1 ,andk processesP0 , , Pk1 .TheimplementationoftheresourcerequestlogicofeachprocessPi isasfollows:

if(i%2==0){
if(i<n)requestRi
if(i+2<n)requestRi+2
}
else{
if(i<n)requestRni
if(i+2<n)requestR_ni2
}
Inwhichofthefollowingsituationsisadeadlockpossible?
(A)n

= 40, k = 26

(B)n

= 21, k = 12

(C)n

= 20, k = 10

(D)n

= 41, k = 19

Fromtheresourceallocationlogic,it'sclearthatevennumberedprocessesaretakingevennumberedresourcesandallevennumberedprocessesshareno
morethan1resource.Now,ifwemakesurethatalloddnumberedprocessestakeoddnumberedresourceswithoutacycle,thendeadlockcannotoccur.The
"else"caseoftheresourceallocationlogic,istryingtodothat.But,ifnisodd,R ni andR ni2 willbeevenandthereispossibilityofdeadlock,when
twoprocessesrequeststhesameR i andR j .So,onlyB andD arethepossibleanswers.
Now,inD ,wecanseethatP0 requestsR 0 andR 2 ,P2 requestsR 2 andR 4 ,soonuntil,P18 requestsR 18 andR 20 .AtthesametimeP1 requestsR 40
andR 38 ,P3 requestsR 38 andR 36 ,soonuntil,P17 requestsR 24 andR 22 .i.e.therearenotwoprocessesrequestingthesametworesourcesandhence
therecan'tbeacycleofdependencieswhichmeans,nodeadlockispossible.
ButforB ,P8 requestsR 8 andR 10 andP11 alsorequestsR 10 andR 8 .Hence,adeadlockispossible.(SupposeP8 comesfirstandoccupiesR 8 .Then
P11 comesandoccupiesR 10 .Now,ifP8 requestsR 10 andP11 requestsR 8 ,therewillbedeadlock)
name

Diskschedulingtop
Diskrequestscometoadiskdriverforcylindersintheorder10,22,20,2,40,6and38atagiventimewhenthegivendiskdriveisreadingfromcylinder20.
Theseektimeis6mspercylinder.
1.Whatisthetotalseektime,ifthediskarmschedulingalgorithmFCFSisused?
A)360msB)850msC)900msD)None
2.Whatisthetotalseektime,iftheclosestcylindernextschedulingisused?
A)360msB)876msC)850msD)900ms
1.FCFS
Totalseektime
=10*6+12*6+2*6+18*6+38*6+34*6+32*6
=146*6
=876ms
2.Closestcylindernext:
Heretheserviceorderwillbe
202210623840
So,totalseektime
=(0+2+12+4+4+36+2)*6
=60*6
=360
name

GATE1994_1.13top

http://gateoverflow.in/book

105/400

2/26/2015

GATEOverflow Book

FIFOreplacesapagewhichwasbroughtintomemoryfirstwillberemovedfirstsosincevariablewasinitializedveryearly.itisinthesetoffirstinpages.so
itwillberemovedanswer:bifyouuseLRUsinceitisusedconstantlyitisarecentlyuseditemalways.socannotberemoved.IfyouuseLFUthe
frequencyofthepageismoresinceitisinconstantuse.Socannotbereplaced
name

GATE1994_1.24top

Infirstfit,blockrequestwillbesatisfiedfromthefirstfreeblockthatfitsit.
So,requestfor300willbesatisfiedby350sizeblockreducingthefreesizeto50.
Requestfor25,satisfiedby125sizeblock,reducingitto125.
Requestfor125satisfiedby125sizeblock.
Andrequestfor50satisfiedbythe50sizeblock.
So,allrequestscanbesatisfied.
Inbestfitstrategy,ablockrequestissatisfiedbythesmallestblockinthatcanfitit.
So,requestfor200willbesatisfiedby350sizeblockreducingthefreesizeto50.
Requestfor25,satisfiedby50sizeblockasitsthesmallestsizethatfits25,reducingitto25.
Requestfor125,satisfiedby150sizeblock,reducingitto25.
Now,requestfor50cannotbesatisfiedasthetwo25sizeblocksarenotcontiguous.
So,answer(b)
name

GATE1994_28top

a)Thesystemisnotindeadlockstateasthereexistsasafesequence.
b)P2P0P1P3isasafesequence.
Hunaif

GATE1995_1.15top
Whichschedulingpolicyismostsuitableforatimesharedoperatingsystem?
http://gateoverflow.in/book

106/400

2/26/2015

A.
B.
C.
D.

GATEOverflow Book

ShortestJobFirst
RoundRobin
FirstComeFirstServe
Elevator

B.RoundRobin.
name

GATE1995_19top
ConsiderthefollowingprogramsegmentforconcurrentprocessingusingsemaphoreoperatorsP andV forsynchronization.Drawtheprecedencegraphforthe
statementsS1toS9.

var
a,b,c,d,e,f,g,h,i,j,k : semaphore;
begin
cobegin
begin S1; V(a); V(b) end;
begin P(a); S2; V(c); V(d) end;
begin P(c); S4; V(e) end;
begin P(d); S5; V(f) end;
begin P(e); P(f); S7; V(k) end
begin P(b); S3; V(g); V(h) end;
begin P(g); S6; V(i) end;
begin P(h); P(i); S8; V(j) end;
begin P(j); P(k); S9 end;
coend
end;

Precedencegraphwillbeformedas

nehapawar

GATE1995_20top
Theheadofamovingheaddiskwith100tracksnumbered0to99iscurrentlyservingarequestattrack55.IfthequeueofrequestskeptinFIFOorderis
10,70,75,23,65
whichofthetwodiskschedulingalgorithmsFCFS(FirstComeFirstServed)andSSTF(ShortestSeekTimeFirst)willrequirelessheadmovement?Findthe
headmovementforeachofthealgorithms.

FCS:55>10>70>75>23>65=>45+60+5+52+42=204.
SSTF:55>65>70>75>23>10=>10+5+5+52+13=85
HenceSSTF.

kireeti

GATE1996_1.18top

http://gateoverflow.in/book

107/400

2/26/2015

GATEOverflow Book

AnswerisB.Thetransitionfromrunningtoreadyindicatesthattheprocessintherunningstatecanbepreemptedandboughtbacktoreadystate.
kireeti

GATE1996_1.19top
Acriticalsectionisaprogramsegment
A.
B.
C.
D.

whichshouldruninacertainamountoftime
whichavoidsdeadlocks
wheresharedresourcesareaccessed
whichmustbeenclosedbyapairofsemaphoreoperations,P andV

C.
http://en.wikipedia.org/wiki/Critical_section
name

GATE1996_1.20top

ansisA
spooling(simultaneousperipheraloperationsonline)isatechniqueinwhichanintermediatedevicesuchasdiskisinterposedbetweenprocessandlowspeed
i/odevice.forex.inprinterifaprocessattempttoprintadocumentbutprinterisbusyprintinganotherdocument,theprocess,insteadofwaitingforprinterto
becomeavailable,writeitsoutputtodisk.whentheprinterbecomeavailablethedataondiskisprinted.spoolingallowsprocesstorequestoperationfrom
peripheraldevicewithoutrequiringthatthedevicebereadytoservicetherequest.
nehapawar

GATE1996_2.17top

ansisd
nehapawar

GATE1996_2.18top
A1000Kbytememoryismanagedusingvariablepartitionsbutnocompaction.Itcurrentlyhastwopartitionsofsizes200Kbytesand260Kbytesrespectively.
ThesmallestallocationrequestinKbytesthatcouldbedeniedisfor
(a)151
http://gateoverflow.in/book

108/400

2/26/2015

GATEOverflow Book

(b)181
(c)231
(d)541

AnswerisB.Sincethetotalsizeofthememoryis1000KB,letsassumethatthepartitioningforthecurrentallocationisdoneinsuchawaythatitwillleave
minimumfreespace.
Partitioningthe1000kBasbelowwillallowgapsof180KBeachandhencearequestof181kBwillnotbemet.
[180Kb200kb180kb260kb180kb].Thereasoningismoreofanintutionratherthananyformula.
kireeti

GATE1996_2.19top

acc.tomeitshouldbec)because..accordingtocondition..outofall,onephilosopherwillgetboththeforks..sodeadlockshouldnotbethere.
name

GATE1996_2.20top

hereallprocessarriveattime0.sothereorderofexecutionwillbeABCD,inthismannercompletiontimeforAis9
nehapawar

GATE1996_22top

ThesystemisinsafestateandhenceallowedbyBanker'salgorithm.P1cannowfinishwiththeavailableresourceandthenP2'srequestcanbesatisfiedand
thenP0's.
IfP0requestoneunitofR1,wecannotgiveit.Thatwouldmakeonly1moreR1availableandhenceP1cannotfinishitsexecutionwiththeremaining
availableR1.Also,P2doesn'thaveenoughR2leftandP0doesn'thaveenoughR0lefttocompletetheirexecution.So,systemgoestodeadstate.
name

GATE2008IT_16top
ApagingschemeusesaTranslationLookasideBuffer(TLB).ATLBaccesstakes10nsandamainmemoryaccesstakes50ns.Whatistheeffectiveaccess
time(inns)iftheTLBhitratiois90%andthereisnopagefault?

A)
http://gateoverflow.in/book

54
109/400

2/26/2015

GATEOverflow Book

B)
C)
D)

60
65
75
Effectiveaccesstime=hitratio*timeduringhit+missratio*timeduringmiss
InbothcasesTLBisaccessedandassumingpagetableisaccessedfrommemoryonlywhenTLBmisses.
=0.9*(10+50)+0.1*(60+50)
=54+11
=65
name

GATE2008IT_41top
Assumethatamainmemorywithonly4pages,eachof16bytes,isinitiallyempty.TheCPUgeneratesthefollowingsequenceofvirtualaddressesandusesthe
LeastRecentlyUsed(LRU)pagereplacementpolicy.
0,4,8,20,24,36,44,12,68,72,80,84,28,32,88,92
Howmanypagefaultsdoesthissequencecause?Whatarethepagenumbersofthepagespresentinthemainmemoryattheendofthesequence?

A)
B)
C)
D)

6and1,2,3,4
7and1,2,4,5
8and1,2,4,5
9and1,2,3,5
0:Pagefault1,Pagesinmemory0
4:Pagefaults1,Pagesinmemory0
8:Pagefaults1,Pagesinmemory0
20:Pagefaults2,Pagesinmemory0,1
24:Pagefaults2,Pagesinmemory0,1
36:Pagefaults3,Pagesinmemory0,1,2
44:Pagefaults3,Pagesinmemory0,1,2
12:Pagefaults3,Pagesinmemory1,2,0
68:Pagefaults4,Pagesinmemory1,2,0,4
72:Pagefaults4,Pagesinmemory1,2,0,4
80:Pagefaults5,Pagesinmemory2,0,4,5
84:Pagefaults5,Pagesinmemory2,0,4,5
28:Pagefaults6,Pagesinmemory0,4,5,1
32:Pagefaults7,Pagesinmemory4,5,1,2
88:Pagefaults7,Pagesinmemory4,1,2,5
92:Pagefaults7,Pagesinmemory4,1,2,5
So,(B)choice.
name

GATE2008IT_53top
Thefollowingisacodewithtwothreads,producerandconsumer,thatcanruninparallel.Further,SandQarebinarysemaphoresequippedwiththestandardP
andVoperations.

semaphore S = 1, Q = 0;
integer x;
producer:
while (true) do

http://gateoverflow.in/book

consumer:
while (true) do

110/400

2/26/2015

GATEOverflow Book

P(S);
x = produce ();
V(Q);
done

P(Q);
consume (x);
V(S);
done

WhichofthefollowingisTRUEabouttheprogramabove?

A)
B)
C)
D)

Theprocesscandeadlock
Oneofthethreadscanstarve
Someoftheitemsproducedbytheproducermaybelost
Valuesgeneratedandstoredin'x'bytheproducerwillalwaysbeconsumedbeforetheproducercangenerateanewvalue
DConsumercanconsumeonlyoncetheproducerhasproducedtheitem,andproducercanproduce(exceptthefirsttime)onlyoncetheconsumerhas
consumedtheitem.
name

GATE2008IT_55top
Ifthetimesliceusedintheroundrobinschedulingpolicyismorethanthemaximumtimerequiredtoexecuteanyprocess,thenthepolicywill

A)
B)
C)
D)

degeneratetoshortestjobfirst
degeneratetopriorityscheduling
degeneratetofirstcomefirstserve
noneoftheabove
ansisc
name

howmanyprocesscreated?top

Atthecalloffork,achildprocessiscreatedwhichexecutesthesamecodeoftheparentfromthatpoint.thereturnvalueorforkis0forthechildandischild
pid(not0)fortheparentandthisvalueisusedtodistinguishbetweenchildparentwhilewritingcodeusingfork.

http://gateoverflow.in/book

111/400

2/26/2015

GATEOverflow Book

Thus5childprocessesarecreated.Sincethequestionasksfor"totalnumberofprocessescreated"wemustincludeparentalsomakingthis6processesin
total,
name

GATE2004IT_14top
WhichoneofthefollowingisNOTsharedbythethreadsofthesameprocess?

A)
B)
C)
D)

Stack
AddressSpace
FileDescriptorTable
MessageQueue
Stackisnotshared
name

GATE2004IT_63top
Inacertainoperatingsystem,deadlockpreventionisattempedusingthefollowingscheme.Eachprocessisassignedauniquetimestamp,andisrestartedwith
the same timestamp if killed. Let Ph be the process holding a resource R, Pr be a process requesting for the same resource R, and T(Ph)andT(Pr) be their
timestampsrespectively.Thedecisiontowaitorpreemptoneoftheprocessesisbasedonthefollowingalgorithm.

if T(Pr) < T(Ph) then


kill Pr
else wait

WhichoneofthefollowingisTRUE?

A.
B.
C.
D.

Theschemeisdeadlockfree,butnotstarvationfree
Theschemeisnotdeadlockfree,butstarvationfree
Theschemeisneitherdeadlockfreenorstarvationfree
Theschemeisbothdeadlockfreeandstarvationfree

AprocessphisholdingaresourceR,andPrisrequestingforthissameresourceR,meansPriswaitingforit.
ifT(Pr)<T(Ph)
thenkillPr
elsewait
ifthetimestampofthewaitingprocessislesserthantheprocesswhichiscurrentlyholdingresourcethenProcessPrwillbekilled,elsewillwaitforitsturn.
butwhenProcessPrisagaincreatedwillbecreatedwithSAMEtimestamp.soTheschemeisbothdeadlockfreeandstarvationfree,becausenexttimeit
won'tbekilledit'llwait.assoonasresourceisfree,resourcewillbeallocatedtoPr.butifPriscreatedagainwithsomeothertimestampthenthissystem
willnotbestarvationfree.
http://gateoverflow.in/book

112/400

2/26/2015

GATEOverflow Book

name

GATE2004IT_64top
Aprocessexecutesthefollowingsegmentofcode:
for(i = 1; i < = n; i++)
fork ();

Thenumberofnewprocessescreatedis

1)
2)
3)

n
((n(n+1))/2)

4)

3n1

2n1

option3
prakash

GATE2004IT_66top
Inavirtualmemorysystem,sizeofvirtualaddressis32bit,sizeofphysicaladdressis30bit,pagesizeis4Kbyteandsizeofeachpagetableentryis32bit.
Themainmemoryisbyteaddressable.Whichoneofthefollowingisthemaximumnumberofbitsthatcanbeusedforstoringprotectionandotherinformation
ineachpagetableentry?

A)
B)
C)
D)

2
10
12
14

ansisD
pagetableentrymustcontainbitsforrepresentingframesandotherbitsforstoringinformationlikedirtybit,referencebitetc
no.offrames(no.ofpossiblepages)=Physicalmemorysize/Pagesize=230/212=218
18+x=32(PTentrysize=32bit)
x=14bits
nehapawar

GATE2005IT_17top
AstudentwishestocreatesymboliclinksinacomputersystemrunningUnix.Threetextfilesnamed"file1","file2"and"file3"existinhercurrentworking
directory,andthestudenthasreadandwritepermissionsforallthreefiles.Assumethatfile1containsinformationaboutherhobbies,file2containsinformation
about her friends and file 3 contains information about her courses. The student executes the following sequence of commands from her current working
directory
ln -s file 1 file 2
ln -s file 2 file 3

Whichofthefollowingtypesofinformationwouldbelostfromherfilesystem?
(I)Hobbies(II)Friends(III)Courses

A)
(I)and(II)only
B)
(II)and(III)only
C)
(II)only
D)
(I)and(III)only
optionB
Aslnsissymboliclink.Inthiscase
File3File2File1Hobbies(actualdata).
SoFile2andFile3contentarelost.
http://gateoverflow.in/book

113/400

2/26/2015

GATEOverflow Book

Laxmi

GATE2005IT_62top
TwosharedresourcesR1andR2areusedbyprocessesP1andP2.Eachprocesshasacertainpriorityforaccessingeachresource.LetTijdenotethepriorityofPi
foraccessingRj.AprocessPicansnatcharesourceRhfromprocessPjifTikisgreaterthanTjk.
Giventhefollowing:
I. T11>T21
II. T12>T22
III. T11<T21
IV. T12<T22
WhichofthefollowingconditionsensuresthatP1andP2canneverdeadlock?

A)
B)
C)
D)

(I)and(IV)
(II)and(III)
(I)and(II)
Noneoftheabove

Theansweris(c)
IfR1andR2areallocatedtotheProcessP1,thenitwillcompleteit'sjobandreleaseit.AfterthatprocessP2willgetboththeresourcesandcompleteit's
Job.
name

CPUSchedulingtop
Q1)
AnOScontains10identicalprocessesthatwereinitiatedatthesametime.Eachprocesscontains15identicalrequests,andeachrequestconsumes20msecofCPU
time.ArequestisfollowedbyanI/Ooperationthatconsumes10msec.Thesystemconsumes2msecinCPUscheduling.Fortimequantumof20msec,the
responsetimesofthefirstrequestofthelastprocessis
A)26msecB)220msecC)200msecD)none
Ans:A
Q2)
Intheaboveproblem,theschedulerlengthis
A)3300msecB)3600msecC)6300msecD)6600msec
Ans:A
Pleaseexplain.

Takethelastprocess>itwillgetitsfirstrequestprocessedafter10schedules.Becauseafterthefirsttimequantum,thefirstprocessdoesanI/Ooperation
(asitwouldhavefinisheditsrequestwhichalsotakes20msandhenceCPUgiventonextprocess)andhencethesecondprocessgetsitschance.Thus,after9
timequantum,thefinalprocessgetsitsrequestserved(assumingapreviouslygivenprocessisnevergivenCPUtimeagainuntilallotherprocessesinwait
aregiven).So,thismeansweneed10schedules(includingoneatthebeginning)andgiveninquestionthateachschedulingtakes2ms.So,responsetimefor
thefirstrequestofthelastprocess
= 9 20ms + 10 2
= 180 + 20 = 200ms

(2)Theschedulinggoeslikethis:
P1P2P3...P10P1P2P3...P10....P10P1P2...P10(P1P10repeated15times)
Aftereverytimequantumandatthebeginningweneed2msforschedulingthenextprocess.So,totalschedulinglength
= (20ms + 2ms) 10 15
= 220 15 = 3300ms

http://gateoverflow.in/book

114/400

2/26/2015

GATEOverflow Book

gatecse

whatisthedifferencebetweenlivelockanddeadlocktop
whatisthedifferencebetweenlivelockanddeadlock?howwillyouexplainlivelocktolayman?askedataninterview@iitb
Deadlockmeanstwoormoreprocessesarewaitingforalockwithoutdoinganything(inactive).
Livelockmeansprocessesareactivebutnotabletoprogressduetointerdependence.Itsliketwopeopletryingtocrossaonemanbridge,bothbackingoff
togetherandthenbothtryingtomoveatthesametimeanddoingthisindefinitely.
http://www.cs.sfu.ca/CourseCentral/300/oneill/Resources/Segment7.pdf
name

AddressTranslationtop
Acpugenerates32bitvirtualaddress.Thepagesizeis4kb.Theprocessorhasatlbwhichcanhold128entriesandis4waysetassociative.Theminimumsize
oftlbtagis???

Answeris11whereisthatfound?
Yourapproachiscorrect.
128entriesandeachsethas4entries=>32sets
5setbitsarerequired.12offsetbitsforindexingapage
Now,32512=15bitsarethereandweneedallofthemtobeusedastagbitsasotherwisewecannotidentifyapagefromthetag.(215possiblepagecan
cometoasetandminimum15bitsareneededtoidentifythepage).

name

Deadlocktop
Considerasystemconsistingofnresourcesofsametypebeingsharedby4processes,2ofwhichneedatmost2resourceseachandotherneedatmost3
resourceseach.Theminvalueofnsothatthesystemisdeadlockfreeis___________?

Totalresourcesrequired=2*2+2*3=10.
Now,withn=10,therewon'tbeadeadlock.
Now,assumetheworstcase.Allprocessesareallottedallresourcesexcept1.So,2*1+2*2=6.Here,deadlockispossiblewithn=6.
Whenn=7,atleastoneprocessmustfinishandweget7resourcesfor3processeswhichrequiremaximum8resourcesbetweenthem.So,againatleastone
ofthemwillfinishandtherewon'tbeadeadlock.
So,n=6+1=7istheanswer.
name

Acertaincomputersystemhasthesegmentedpagingarchitectureforvirtualmemory.top
Acertaincomputersystemhasthesegmentedpagingarchitectureforvirtual
memory.Thememoryisbyteaddressable.Bothvirtualandphysicaladdress
spacescontain162byteseach.Thevirtualaddressspaceisdivi8dedinto8nonoverlapping
equalsizesegments.Thememorymanagementunit(MMU)hasa
hardwaresegmenttable,eachentryofwhichcontainsthephysicaladdressofthe
pagetableforthesegment.Pagetablearestoredinthemainmemoryand
consistsof2bytepagetableentries.
(a)Whatistheminimumpagesizeinbytessothatthepagetableforasegment
requiresatmostonepagetostoreit?Assumethatthepagesizecanonlybe
apowerof2
(b)Nowsupposethatthepagessizeis512bytes.Itisproposedtoprovidea
TLB(Translationlookasidebuffer)forspeedingupaddresstranslation.The
proposedTLBwillbecapableofstoringpagetableentriesfor16recently
referencedvirtualpages,inafastcachethatwillusethedirectmapping
scheme.Whatisthenumberotagbitsthatwillneedtobeassociatedwith
eachcacheentry
(c)Assumethateachpagetableentrycontains(besidesotherinformation)1
http://gateoverflow.in/book

115/400

2/26/2015

GATEOverflow Book

validbit,3bitsforpageprotectionand1dirtybit.Howmanybitsare
availableinpagetableentryforstoringtheaginginformationforthepage?
Assumethatthepagesizeis512bytes.

SoArchitecture has Segmented paging

SegNo.

Pageno.WithintheSeg.

Offset

So 1stGiven Virtual Space = Physical Space = 16 bit and There are 8 Segment in the memory So for 8 segment there are 3 bit to
represent the 8 segment
VirtualAddressSpace
Pageno.WithintheSeg.+Offset=13bit

SegNo.=3bit
eachPagetableContains=2bytes=16bit
SO
(a)LetpageSize=2n
Weknowthatoffset(d)=n(powerof2inpagesizeheren)
p+d=13p+n=13,soNo.ofpage=213n
AndSizeOfpagetable=213nx2bytes(giveninques)=214n

AndSizeofpagetable=PageSize(DuetoStatementgiveninQue=pagetableforasegmentrequiresatmostonepagetostoreit)
214n=2nson=7
SopageSize=128byte
(b)ActuallyiamnotunderstandwhattheQues.isasked
(c)eachPagetableContains=2bytes=16bit
frameSize=PhysicalAddressSpace/pageSize=216/29=27
7bitframeSize

framebit= Valid
7
Bit=1

PP=3

Dirty
bit=1

remaining=167131=4
bit

SoAnsweris4Bit....
name

MysteriousFork()call?top

Thegivenansweriswrong.Theoutputmaybe"HiHi"or"Hi".Atthetimeoffork,printfmightnothavebeenexecutedandhencethecodeofprintingmight
http://gateoverflow.in/book

116/400

2/26/2015

GATEOverflow Book

becopiedtochildaswell.(printfisanonblockingcall).Toavoidthisbehaviour,eitherwehavetousefflushorusethereturnvalueofprintfbeforecalling
fork.
name

consideramachinewith64Mbytephysicalmemoryanda32bitvirtualaddress.ifthepagesizeis4
kByte,whatistheapproximatesizeofthepagetable?a)16Mbyteb)8Mbytec)2Mbyted)24Mbyte
top

VirtualAddressSpace=32Bit,Pagesize=4kb=22x210=212
PTE=V.A.S./PageSize=220....................eq.1
Physicalmemorysize=64MB=26x210x210
=226
ThenNo.ofFramesinPhysicalMemory=226/212=214
Andpagetableneedstostoretheaddressofallthese214pageframes.Therefore,eachpagetableentrywillcontain14bitsaddressofthepageframeand1
bitforvalidinvalidbit.wesuppose16bitrequireitmeans2bytes(approx.)
soSizeofPagetable=TotalPTE(fromeq1)xSizeofpagetableentry=220x2=2Mb

name

GATE20152_23top
Asystemhas6identicalresourcesandN processescompetingforthem.Eachprocesscanrequestatmost2requests.WhichoneofthefollowingvaluesofN
couldleadtoadeadlock?

A.
B.
C.
D.

1
2
3
4

3*2=6
4*2=8.
Iguessaquestioncan'tgeteasierthanthisDchoice.(Also,wecansimplytakethegreatestvalueamongchoiceforthisquestion)
name

GATE20152_25top
Acomputersystemimplementsa40bitvirtualaddress,pagesizeof8kilobytes,anda128entrytranslationlookasidebuffer(TLB)organizedinto32setseach
having4ways.AssumethattheTLBtagdoesnotstoreanyprocessid.TheminimumlengthoftheTLBtaginbitsis____.
Ans40(5+13)=22bits
TLBmapsavirtualaddresstothephysicaladdressofthepage.(ThelowerbitsofpageaddressoffsetbitsarenotusedinTLBastheyarethesamefor
virtualaswellasphysicaladdresses).Here,for8kBpagesizewerequire13offsetbits.
InTLBwehave32setsandsovirtualaddressspaceisdividedinto32using5setbits.(Associativitydoesn'taffectthesetbitsastheyjustaddsextraslotsin
eachset).
So,numberoftagbits=40513=22
name

GATE20151_9top
ThefollowingtwofunctionsP1andP2thatshareavariableBwithaninitialvalueof2executeconcurrently.
P1() {
C = B - 1;
B = 2 * C;
}

P2(){
D = 2 * B;
B = D - 1;
}

http://gateoverflow.in/book

117/400

2/26/2015

GATEOverflow Book

ThenumberofdistinctvaluesthatBcanpossiblytakeaftertheexecutionis______________________.

3distinctvalue(2,3,4)
P1P2:B=3
P2P1:B=4
P1P2P1:B=2
name

GATE20152_30top
Consider6memorypartitionsofsizes200KB,400KB,600KB,500KB,300KBand250KB,whereKBreferstokilobyte.Thesepartitionsneedtobeallotted
tofourprocessesofsizes357KB,210KB,468KB,491KBinthatorder.Ifthebestfitalgorithmisused,whichpartitionsareNOTallottedtoanyprocess?

A.
B.
C.
D.

200KBand300KB
200KBand250KB
250KBand300KB
300KBand400KB

optionAiscorrectbecausewehave6memorypartitionsofsizes200KB,400KB,600KB,500KB,300KBand250KBandthepartitionallotted
totheprocessusingbestfitisgivenbelow
357KBprocessallottedatpartition400KB.
210KBprocessallottedatpartition250KB
468KBprocessallottedatpartition500KB
491KBprocessallottedatpartition600KB
sowehaveleftonlytwopartitions200KBand300KB

name

GATE20151_12
top
Considerasystemwithbyteaddressablememory,32bitlogicaladdresses,4kilobytepagesizeandpagetableentriesof4byteseach.Thesizeofthepagetable
inthesysteminmegabytesis_________________.
totalnoofpages=2^32/2^12=2^20
WeneedaPTEforeachpageandanentryis4bytes.So,
pagetablesize=4*2^20=2^22=4MB
name

GATE20151_30top
Supposethefollowingdiskrequestsequence(tracknumbers)foradiskwith100tracksisgiven:
45,20,90,10,50,60,80,25,70.
AssumethattheinitialpositionoftheR/Wheadisontrack50.TheadditionaldistancethatwillbetraversedbytheR/WheadwhentheShortestSeekTime
First (SSTF) algorithm is used compared to the SCAN (Elevator) algorithm (assuming that SCAN algorithm moves towards 100 when it starts execution)
is________________tracks.

SSTF:
Initialposition50.So,shortestsequencewillbe
504560708090252010
andthecorrespondingdistanceswillbe
051510101065510
givingtotaldistanceof130.
SCAN:
Hererequestsfrom50areservicedinascendingorderoftheirtracknumber(asthemovementisfrom50to100)andattheendofthesequence,the
remainingrequestsareservicedinthedescendingorder.So,theserviceorderwillbe
http://gateoverflow.in/book

118/400

2/26/2015

GATEOverflow Book

506070809045252010
andthecorrespondingdistances
0101010104520510
givingatotaldistanceof120
So,extradistanceofSSTF=130120=10
Ref:http://courses.cs.vt.edu/cs2506/Fall2014/Notes/L17.IOScheduling.pdf
name

GATE20152_47top
Acomputersystemimplements8kilobytepagesanda32bitphysicaladdressspace.Eachpagetableentrycontainsavalidbit,adirtybit,threepermissionbits,
andthetranslation.Ifthemaximumsizeofthepagetableofaprocessis24megabytes,thelengthofthevirtualaddresssupportedbythesystemis_______bits.

8KBpagesmeans13offsetbits.
For32,bitphysicaladdress,3213=19pageframebitsmustbethereineachPTE(PageTableEntry).
Wealsohave1validbit,1dirtybitand3permissionbits.
So,totalsizeofaPTE=19+5=24bits=3bytes.
iveninquestion,maximumpagetablesize=24MB
G
Pagetablesize=No.ofPTEs*sizeofanentry
So,no.ofPTE=24MB/3B=8M
Virtualaddresssupported=No.ofPTEs*Pagesize(AsweneedaPTEforeachpage)
=8M*8KB
=64GB=236Bytes
So,lengthofvirtualaddresssupported=36bits(assumingbyteaddressing)

name

GATE20152_49top
Consideratypicaldiskthatrotatesat15000rotationsperminute(RPM)andhasatransferrateof50 106 bytes/sec.Iftheaverageseektimeofthediskis
twicetheaveragerotationaldelayandthecontroller'stransfertimeis10timesthedisktransfertime,theaveragetime(inmilliseconds)toreadorwritea512
bytesectorofthediskis_____.

Averagetimetoread/write=Avg.seektime+Avg.rotationaldelay+Effectivetransfertime
Rotationaldelay=60/15=4ms
Avg.rotationaldelay=1/2*4=2ms
Avg.seektime=2*2=4ms
Disktransfertime=512/(50*103)=0.0102ms
Effectivetransfertime=10*disktransfertime=0.102ms
So,avg.timetoread/write=4+2+0.1=6.1ms
Ref:http://www.csc.villanova.edu/~japaridz/8400/sld012.htm

name

GATE20151_46top
Considerauniprocessorsystemexecutingthreetasks T1 , T2 and T3 each of whichiscomposed of an infinite sequence of jobs (or instances) which arrive
periodicallyatintervalsof3,7and20milliseconds,respectively.Thepriorityofeachtaskistheinverseofitsperiod,andtheavailabletasksarescheduledin
order of priority, which is the highest priority task scheduled first. Each instance of T1 , T2 and T3 requires an execution time of 1, 2 and 4 milliseconds,
respectively.Giventhatalltasksinitiallyarriveatthebeginningofthe1stmillisecondandtaskpreemptionsareallowed,thefirstinstanceof T3 completesits
executionattheendof_____________________milliseconds.
1:T1
2:T2
http://gateoverflow.in/book

119/400

2/26/2015

GATEOverflow Book

3:T2
4:T1
5:T3
6:T3
7:T1
8:T2
9:T2
10:T1
11:T3
12:T3(FirstinstanceofT3completes4msandfinishedexecution).
So,answeris12.
name

GATE20151_47top
Consideramainmemorywithfivepageframesandthefollowingsequenceofpagereferences:3,8,2,3,9,1,6,3,8,9,3,6,2,1,3.Whichoneofthefollowing
istruewithrespecttopagereplacementpoliciesFirstInFirstOut(FIFO)andLeastRecentlyUsed(LRU)?
A.
B.
C.
D.

Bothincurthesamenumberofpagefaults
FIFOincurs2morepagefaultsthanLRU
LRUincurs2morepagefaultsthanFIFO
FIFOincurs1morepagefaultsthanLRU

FIFO:
33:1pagefault
838:2pagefaults
2382:3pagefaults
3382:3pagefaults
93829:4pagefaults
138291:5pagefaults
682916:6pagefaults
329163:7pagefaults
891638:8pagefaults
991638:8pagefaults
391638:8pagefaults
691638:8pagefaults
216382:9pagefaults
116382:9pagefaults
316382:9pagefaults
LRU:
33:1pagefault
838:2pagefaults
2382:3pagefaults
3823:3pagefaults
98239:4pagefaults
182391:5pagefaults
623916:6pagefaults
329163:6pagefaults
891638:7pagefaults
916389:7pagefaults
316893:7pagefaults
618936:7pagefaults
289362:8pagefaults
193621:9pagefaults
396213:9pagefaults
So,optionA.
name

GATE20151_48top
Consideradiskpackwithaseektimeof4millisecondsandrotationalspeedof10000rotationsperminute(RPM).Ithas600sectorspertrackandeachsector
canstore512bytesofdata.Considerafilestoredinthedisk.Thefilecontains2000sectors.Assumethateverysectoraccessnecessitatesaseek,andthe
averagerotationallatencyforaccessingeachsectorishalfofthetimeforonecompleterotation.Thetotaltime(inmilliseconds)neededtoreadtheentirefile
is__________________.

Sinceeachsectorrequiresaseek,
Totaltime=2000*(seektime+avg.rotationallatency+datatransfertime)
Sincedatatransferrateisnotgiven,wecantakethatin1rotation,alldatainatrackisread.i.e.,in60/10000=6ms,600*512bytesareread.So,timeto
http://gateoverflow.in/book

120/400

2/26/2015

GATEOverflow Book

read512bytes=6/600ms=0.01ms
=2000*(4ms+60*1000/2*10000+0.01)
=2000*(7.01ms)
=14020ms.
http://www.csee.umbc.edu/~olano/611s06/storageio.pdf
name

GATE20153_1top
ThemaximumnumberofprocessesthatcanbeinreadyReady stateforacomputersystemwithn CPUsis

A. n
B. n 2
C. 2 n
D. Independentofn
D.independentofn.
ThenumberofprocessesthatcanbeinREADYstatedependsontheReadyQueuesizeandisindependentofthenumberofCPU's.
name

GATE20153_10top
TwoprocessesXandYneedtoaccessacriticalsection.Considerthefollowingsynchronizationconstructusedbyboththeprocesses
ProcessX

ProcessY

/* other code for process x*/


while (true)
{
varP = true;
while (varQ == true)
{
/* Critical Section */
varP = false;
}
}
/* other code for process X */

/* other code for process Y */


while (true)
{
varQ=true;
while (varP == true)
{
/* Critical Section */
varQ = false;
}
}
/* other code for process Y */

HerevarPandvarQaresharedvariablesandbothareinitializedtofalse.Whichoneofthefollowingstatementsistrue?

A.
B.
C.
D.

Theproposedsolutionpreventsdeadlockbutfailstoguaranteemutualexclusion
Theproposedsolutionguaranteesmutualexclusionbutfailstopreventdeadlock
Theproposedsolutionguaranteesmutualexclusionandpreventsdeadlock
Theproposedsolutionfailstopreventdeadlockandfailstoguaranteemutualexclusion

Whenbothprocessestrytoentercriticalsectionsimultaneously,bothareallowedtodososincebothsharedvariablesvarPandvarQaretrue.So,clearlythere
isNOmutualexclusion.Also,deadlockispreventedbecausemutualexclusionisoneoftheconditionsfordeadlocktohappen.Hence,answerisA.
tanaya

GATE20153_34top
Fortheprocesseslistedinthefollowingtable,whichofthefollowingschedulingschemeswillgivethelowestaverageturnaroundtime?
Process

ArrivalTime

ProcessTime

A
B
C
D

0
1
4
6

3
6
4
2

A. FirstComeFirstServe
http://gateoverflow.in/book

121/400

2/26/2015

GATEOverflow Book

B. NonpreempriveShortestjobfirst
C. ShortestRemainingTime
D. RoundRobinwithQuantumvaluetwo

FCFS
Averageturnaroundtime=[3forA+(2+6)forB+(5+4)forC+(7+2)forD]/4=7.25
NonpreemptiveShortestJobFirst
Averageturnaroundtime=[3forA+(2+6)forB+(3+2)forD+(7+4)forC]=7
ShortestRemainingTime
Averageturnaroundtime=[3forA+(2+1)forB+(0+4)forC+(2+2)forD+(6+5)forremainingB]/4=6.25
RoundRobin
Averageturnaroundtime=[2forA+(1+2)forB+(0+2)forC+(0+2)forD+(6+1)forA+(5+2)forB+(7+2)forC+(2+2)forB]/4=9
name

GATE20153_52top
Considerthefollowingpoliciesforpreventingdeadlockinasystemwithmutuallyexclusiveresources.
I. Processshouldacquirealltheirresourcesatthebeginningofexecution.Ifanyresourceisnotavailable,allresourcesacquiredsofararereleased.
II. Theresourcesarenumbereduniquely,andprocessesareallowedtorequestforresourcesonlyinincreasingresourcenumbers
III. Theresourcesarenumbereduniquely,andprocessesareallowedtorequestforresourcesonlyindeccreasingresourcenumbers
IV. Theresourcesarenumbereduniquely.Aprocessesisallowedtorequestforresourcesonlyforaresourcewithresourcenumberlargerthanitscurrently
heldresources
Whichoftheabovepoliciescanbeusedforpreventingdeadlock?

A.
B.
C.
D.

AnyoneofIandIIIbutnotIIorIV
AnyoneofI,IIIandIVbutnotII
AnyoneofIIandIIIbutnotIorIV
AnyoneofI,II,IIIandIV

AnswerisDTheseallcasesarevariousmethodsforpreventingdeadlock
ppm

http://gateoverflow.in/book

122/400

2/26/2015

GATEOverflow Book

Databasestop
GATE2012_2top
WhichofthefollowingisTRUE?
(A)Everyrelationin3NFisalsoinBCNF
(B)ArelationRisin3NFifeverynonprimeattributeofRisfullyfunctionallydependentoneverykeyofR
(C)EveryrelationinBCNFisalsoin3NF
(D)NorelationcanbeinbothBCNFand3NF
(C)EveryrelationinBCNFisalsoin3NF.StriaghtfromdefinitionofBCNF.
name

GATE2012_14top
GiventhebasicERandrelationalmodels,whichofthefollowingisINCORRECT?
(A)Anattributeofanentitycanhavemorethanonevalue
(B)Anattributeofanentitycanbecomposite
(C)Inarowofarelationaltable,anattributecanhavemorethanonevalue
(D)Inarowofarelationaltable,anattributecanhaveexactlyonevalueoraNULLvalue
(C)isincorrectasarelationaltablerequiresthat,inarow,anattributecanhaveexactlyonevalueorNULLvalue.
name

GATE2012_15top
WhichofthefollowingstatementsareTRUEaboutanSQLquery?
P:AnSQLquerycancontainaHAVINGclauseevenifitdoesnothaveaGROUPBYclause
Q:AnSQLquerycancontainaHAVINGclauseonlyifithasaGROUPBYclause
R:AllattributesusedintheGROUPBYclausemustappearintheSELECTclause
S:NotallattributesusedintheGROUPBYclauseneedtoappearintheSELECTclause
(A)PandR
(B)PandS
(C)QandR
(D)QandS
(C)QandRaretrue.
HAVINGclauseismeantforgroupsandhenceaGROUPBYclauseisnecessaryandGROUPBYisworkingontheselectedattributesandhenceall
attributesintheGROUPBYclausemustappearintheSELECTclause.
name

GATE2008_70top
Considerafileof16384records.Eachrecordis32byteslonganditskeyfieldisofsize6bytes.Thefileisorderedonanonkeyfield,andthefileorganization
isunspanned.Thefileisstoredinafilesystemwithblocksize1024bytes,andthesizeofablockpointeris10bytes.Ifthesecondaryindexisbuiltonthekey
fieldofthefile,andamultilevelindexschemeisusedtostorethesecondaryindex,thenumberoffirstlevelandsecondlevelblocksinthemultilevel
indexarerespectively
(A)8and0(B)128and6(C)256and4(D)512and5

Contentofanindexwillbe<key,blockpointer>andsowillhavesize6+10=16.
Inthefirstlevel,therewillbeanentryforeachrecordofthefile.So,totalsizeoffirstlevelindex
=16384*16
No.ofblocksinthefirstlevel=Sizeoffirstlevelindex/blocksize
=16384*16/1024
=16*16=256
Inthesecondleveltherewillbeanentryforeachblockinthefirstlevel.So,totalnumberofentries=256andtotalsizeofsecondlevelindex
=No.ofentries*sizeofanentry
=256*16
http://gateoverflow.in/book

123/400

2/26/2015

GATEOverflow Book

No.ofblocksinsecondlevelindex=Sizeofsecondlevelindex/blocksize
=256*16/1024
=4

gatecse

GATE2008_15top
Whichofthefollowingtuplerelationalcalculusexpression(s)is/areequivalenttot

r(P (t))

1. t r(P (t))
2. t r(P (t))
3. t r(P (t))
4. t r(P (t))
(A)Ionly
(B)IIonly
(C)IIIonly
(D)IIIandIVonly

OnlyIIIiscorrect.
Thegivenstatementmeansforalltuplesfromr,Pistrue.IIImeanstheredoesnotexistatupleinrwherePisnottrue.Bothareequivalent.
IVisnotcorrectasitassayingthatthereexistatuple,notinrforwhichPisnottrue,whichisnotwhatthegivenexpressionmeans.
name

GATE2008_68top

(d)i,iii,iv
iv)isexpansionfornatuarljoinrepresentedwithotheroperators
name

GATE2008_69top

(c)

http://gateoverflow.in/book

124/400

2/26/2015

GATEOverflow Book

incollectionallthenonprimeattributesdependdirectlyoncandidatekeysoBCNFandhence3NF(actuallycollectionhasonlyprimeattributessoit
should,bydefaultbeatleastin3NF)
inbookthenonprimeattr(price),dependsindirectlyonthecandidatekey(catalog_no)thusformingtransitivedependencyandhencenotin3NF.Thereisno
partialdependencyso2nf
name

GATE2000_2.24top
Giventhefollowingrelationinstance.
X
1
1
1
3

Y
4
5
6
2

Z
2
3
3
2

Whichofthefollowingfunctionaldependenciesaresatisfiedbytheinstance?

A.
B.
C.
D.

XYZandZY
YZXandYZ
YZXandXZ
XZYandYX

(b)
ifa>bthenforeachsamevalueofa,bshouldbesame,
wehavetogettheoppositeofthedefni.eifnovaluesofaaresamethenbneedbesame
name

GATE2000_2.25top
Givenrelationsr(w,x)ands(y,z)theresultof
select distinct w, x
from r, s

isguaranteedtobesameasr,provided.
A.
B.
C.
D.

rhasnoduplicatesandsisnonempty
randshavenoduplicates
shasnoduplicatesandrisnonempty
randshavethesamenumberoftuples

(a)
ifsisemptyrxswillgiveemptyset,soscantbeempty
name

GATE2000_2.26top
InSQL,relationscancontainnullvalues,andcomparisonswithnullvaluesaretreatedasunknown.Supposeallcomparisonswithanullvaluearetreatedas
false.Whichofthefollowingpairsisnotequivalent?
A.
B.
C.
D.

x=5not(not(x=5))
x=5x>4andx<6,wherexisaninteger
x5not(x=5)
noneoftheabove

(c)
as(null)!=5givesfalse
not((null)=5).>not(false)>true
name

GATE2001_2.23top
http://gateoverflow.in/book

125/400

2/26/2015

GATEOverflow Book

R(A,B,C,D)isarelation.Whichofthefollowingdoesnothavealosslessjoin,dependencypreservingBCNFdecomposition?
A.
B.
C.
D.

A B, B C D
A B, B C , C D
AB C , C AD
A BC D

(C)istheanswer.BecauseofAB>CandC>A,wecannothaveA,BandCtogetherinanyBCNFrelationinrelationABC,CisnotasuperkeyandC
>AexistsviolatingBCNFcondition.So,wecannotpreserveAB>CdependencyinanydecompositionofABCD.
For(A)wecanhaveAB,BCD,AandBtherespectivekeys
For(B)wecanhaveAB,BC,CD,A,BandCtherespectivekeys
For(D)wecanhaveABCD,Aiskey
name

GATE2002_1.19top
Relation R with an associated set of functional dependencies, F, is decomposed into BCNF. The redundancy (arising out of functional dependencies) in the
resultingsetofrelationsis
A.
B.
C.
D.

Zero
Morethanzerobutlessthanthatofanequivalent3NFdecomposition
ProportionaltothesizeofF+
Indeterminate

IfarelationschemaisinBCNFthenallredundancybasedonfunctionaldependencyhasbeenremoved,althoughothertypesofredundancymaystillexist.
ArelationalschemaRisinBoyceCoddnormalformifandonlyifforeveryoneofitsdependenciesXY,atleastoneofthefollowingconditions
hold:
XYisatrivialfunctionaldependency(YX)
XisasuperkeyforschemaR
http://en.wikipedia.org/wiki/Boyce%E2%80%93Codd_normal_form
Priya_das

GATE2004_14top

Rollnoinstudentsiskey,ansstudentstablehas120tuples,InEnrolltablerollnoisFKreferencingtoStudentstable.innaturaljoinit'llreturntherecords
wheretherollnovalueofenrollmatcheswiththerollnoofstudentssoinbothconditionsminandmaxrecordswillberesulted(8,8).
henceAistheanswer.
Hint:tablewhichhasnonkey,noofrecordsofthatwillberesulted.
name

GATE2004_50top

IfweproceedwithgivenFDstheneitherName,coursenoorRollNo,courseNobecomesthecandidatekey.Sonononprimeattributesarepartiallydependent
onanyKeyattributes.Hence2NFtestpassed.
Againfor3rdand4thFD,Name,rollarepartofthekeyandforfirst2FDs,determinantsarecandidatekeyitself.So3NFtestpassedbutnotBCNF.Hence
3NFanswer.b.
http://gateoverflow.in/book

126/400

2/26/2015

GATEOverflow Book

name

GATE2007_60top
Considertherelationemployee(name,sex,supervisorName)withnameasthekey,supervisorNamegivesthenameofthesupervisoroftheemployeeunder
consideration.WhatdoesthefollowingTupleRelationalCalculusqueryproduce?

A.
B.
C.
D.

Namesofemployeeswithamalesupervisor.
Namesofemployeeswithnoimmediatemalesubordinates.
Namesofemployeeswithnoimmediatefemalesubordinates.
Namesofemployeeswithafemalesupervisor.

Queryisselectingesuchthateisanemployeeandforallx,eitherxisnotanemployeeorx'ssupervisor'snameisnote.nameorxismale.
So,thisisequivalenttosaying,selectallemployeeswhodoesn'thaveanimmediatefemalesubordinate.(Assumingthereisnotransgender).(C)option.
name

GATE2007_62top

(d)
Defnfromwiki:
The3NFversionofthedefinitionisweakerthanDate'sBCNFvariation,astheformerisconcernedonlywithensuringthatnonkeyattributesaredependent
onkeys.Primeattributes(whicharekeysorpartsofkeys)mustnotbefunctionallydependentatalltheyeachrepresentafactaboutthekeyinthesenseof
providingpartorallofthekeyitself.(Itshouldbenotedherethatthisruleappliesonlytofunctionallydependentattributes,asapplyingittoallattributes
wouldimplicitlyprohibitcompositecandidatekeys,sinceeachpartofanysuchkeywouldviolatethe"wholekey"clause.)
name

ConsidertableR(A,B,C,D,E)withFDsasA>B,BC>EandED>A.Thetableisinwhichnormal
form?Justifyyouranswer.top
Firststep:Identifythecandidatekeys.Candidatekeysmustbeabletodetermineallotherattributes.Mostofthetimetheycanbefoundbyjustlookingatthe
FDs.Here,
EDCisacandidatekeysoareACDandBCD.
Now,justcheckfortheconditionsofeachnormalform.
WecanseeA>B.
ACDisthecandidatekeyandAisapartialkey.ButBisaprimeattribute(partofacandidatekey).Hence,thisisnotapartialfunctionaldependency.
SimilarlyinBC>EandED>A,EandAareprimeattributesandhencebotharenotpartialfunctionaldependencies.HenceRisin2NF.
Now3NFstatesthateverynonprimeattributemustbedependentonthecandidatekey.Inthegivenfunctionaldependencies,alldependentattributesare
primeattributesandhenceitistriviallyin3NF.
NowBCNFrequiresthatforeveryFD
henceRisnotinBCNF.

, mustbeasuperkey(candidatekeyoritssuperset).Thisconditionisviolatedbyallthe3FDsgivenand

>

So,3NFisthehighestnormalformtablecanbein.
gatecse

GATE2009_45top
LetRandSberelationalschemessuchthatR={a,b,c}andS={c}.Nowconsiderthefollowingqueriesonthedatabase:
1.RS (r) RS (RS (r) s RS,S (r))
{t t

(r) u s(v r(u = v[s] t = v[R S ]))}

RS
http://gateoverflow.in/book

127/400

2/26/2015

GATEOverflow Book

2.{t

t RS (r) u s(v r(u = v[s] t = v[R S ]))}

3.{t

t RS (r) v r(u s(u = v[s] t = v[R S ]))}

4.
Select R.a,R.b
From R,S
Where R.c = S.c

Whichoftheabovequeriesareequivalent?
(A)1and2
(B)1and3
(C)2and4
(D)3and4

1.RS (r) RS (RS (r) s RS,S (r))


=a,b (r) a,b (a,b (r) s R (r))
=(r/s)
2.Expandinglogicallythestatementmeanstoselectt(a,b)fromrsuchthatforalltuplesuins,thereisatuplevinr,suchthatu=v[S]andt=v[RS].This
isjustequivalentto

(r/s)

3.Expandinglogicallythestatementmeansthatselectt(a,b)fromrsuchthatforalltuplesvinr,thereisatupleuins,suchthatu=v[S]andt=v[RS].
Thisisequivalenttosayingtoselect(a,b)valuesfromr,wherethecvalueisin(s/r) ,whichwillbetrueonlyifcinrisaforeignkeyreferringtocins.
4.Thisselects(a,b)fromalltuplesfromrwhichhasanequivalentcvalueins.
So,1and2areequivalent
r
a
Arj
Arj
Cell
Tom
Ben

b
TY
TY
TR
TW
TE

c
12
14
13
12
14

s
c
12
14
1. willgive<Arj,TY>
2. willgive<Arj,TY>
3. willnotreturnanytupleasthecvalue13,isnotins.
4. willgive<Arj,TY>,<Arj,TY>,Tom,TW>,<Ben,TE>
http://pages.cs.wisc.edu/~dbbook/openAccess/firstEdition/slides/pdfslides/mod3l1.pdf
name

GATE2005_29top

optionc
name
http://gateoverflow.in/book

128/400

2/26/2015

GATEOverflow Book

GATE2005_30top

AnswerisC.

A
1
1

B
2
5

C
3
3

D
3
4

D
3
4
S=R1*R2
B
C
2
3
2
3
5
3
5
3

D
3
4
3
4

R1
B
2
5
R2

A
1
1
A
1
1
A
1
1
1
1

C
3
3

RedcolorrowsofSarepresentinRso

andonemoreresultR*S=R.
name

GATE2005_76top

(c)
sincedeleting(2,4),since2isaprimarykey,uhavetodeleteitsforeignkeyoccurencei.e(5,2)and(7,2)
sincewearedelting5,and7wehavedeleteitforeignkeyoccurencei.e(9,5)
thereisnoforeignkeyoccurencefor9
name

http://gateoverflow.in/book

129/400

2/26/2015

GATEOverflow Book

GATE1999_2.25top
Whichofthefollowingis/arecorrect?
A.
B.
C.
D.

AnSQLqueryautomaticallyeliminatesduplicates
AnSQLquerywillnotworkiftherearenoindexesontherelations
SQLpermitsattributenamestoberepeatedinthesamerelation
Noneoftheabove

(d)
sqlwontremoveduplicates,wehavetoremoveitexpliciltybydistict
sql,ifwedinchoseanyindexesitwillchoosebyitsown
sqldoesnnotpermit2attributestohavesamename
name

Trivialfunctionaldependencytop
Hereisparafromwiki,aboutfunctionaldependencyinrelationdbms
GivenarelationR,asetofattributesXinRissaidtofunctionallydetermineanothersetofattributesY,alsoinR,(writtenXY)if,andonlyif,eachXvalue
isassociatedwithpreciselyoneYvalueRisthensaidtosatisfythefunctionaldependencyXY.Equivalently,theprojection\pi_{X,Y}Risafunction,i.e.Y
isafunctionofX.[1][2]Insimplewords,ifthevaluesfortheXattributesareknown(saytheyarex),thenthevaluesfortheYattributescorrespondingtoxcan
bedeterminedbylookingthemupinanytupleofRcontainingx.CustomarilyXiscalledthedeterminantsetandYthedependentset.Afunctionaldependency
FD:XYiscalledtrivialifYisasubsetofX.
Icouldnotgetthelastpoint"AfunctionaldependencyFD:XYiscalledtrivialifYisasubsetofX."
pleasegivemeanexampleandexplainit
Thankyou:)

Theproblemhereis"trivial".AnativeEnglishspeakerwouldn'thaveanydoubtinthis.Hereisoneexampleusageofit:
(a)Anengineeringstudenthavingattendedhighschoolistrivial.
Moredetails:
http://dictionary.reference.com/browse/trivial
Now,comingtoFD,wesayXYwhenYisdependentonX.Thatis,wheneverXvaluechangesYvalueshouldchangeaccordingly.NowconsiderX={A,B,C}
andY={A},whereYisasubsetofX.LetusconsideratupleofrelationRcontainingXandY(secondoneinthebelowtablewherexrepresentsanyvalue)

A
x
first
x

B
x
456
x

C
x
chennai
x

D
x

Here,valueofXforourtuple={first,456,chennai},andvalueofY={first}.Nowwhen"first"changestosay"second",itwillchangethevalueinbothX
aswellasY,astheattributeAisthesameinbothXandY.So,thereisnomeaninginthisFDasitisalwaysthere,andhenceitbecomestrivial.

name

GATE2013_54,55top
RelationRhaseightattributesABCDEFGH.FieldsofRcontainonlyatomicvalues.F ={CHG,ABC,BCFH,EA,FEG}isasetoffunctional
+
dependencies(FDs)sothatF isexactlythesetofFDsthatholdforR.
Q.54HowmanycandidatekeysdoestherelationRhave?
(A)3(B)4(C)5(D)6

Q.55TherelationRis
(A)in1NF,butnotin2NF.
http://gateoverflow.in/book

130/400

2/26/2015

GATEOverflow Book

(B)in2NF,butnotin3NF.
(C)in3NF,butnotinBCNF.
(D)inBCNF.
54)B.4candidatekeysnamelyDA,DB,DE,DF.
55)A.
asinF>G,GisnonprimeattributebutFisapropersubsetofacandidatekey.soviolates2nfcondition.henceRisin1nf.
kalpashri

GATE1998_2.19top
Whichofthefollowingquerytransformations(i.e.,replacingthel.h.s.expressionbyther.h.sexpression)isincorrect?R1andR2arerelations,C1andC2 are
selectionconditionsandA1andA2areattributesofR1.
A.C

( C (R 1 )) C ( C (R 1 ))

B.C

( A (R 1 )) A ( C (R 1 ))

C.C

(R 1 R 2 ) C (R 1 ) C (R 2 )

D.A

( C (R 1 )) C ( A (R 1 ))
1

D)iftheselectionconditionisonattributeA2,thenwecannotreplaceitbyRHSastherewillnotbeanyattributeA2duetoprojectionofA1only.
name

GATE20141_21top
ConsidertherelationschemeR

= (E, F , G, H , I , J , K , L, M , N ) andthesetoffunctionaldependencies

{{E, F } {G}, {F } {I , J }, {E, H } {K , L},


{K } {M }, {L} {N }}

onR .WhatisthekeyforR ?

(A){E, F }
(B){E, F , H }
(C){E, F , H , K , L}
(D){E}
sinceHcannotbederivedfromanythingelseHshouldbethereinkey
usingFind{EFH}+itcontainsalltheattributesoftherelation
henceitiskey
name

GATE20141_22top
Giventhefollowingstatements:
S1:AforeignkeydeclarationcanalwaysbereplacedbyanequivalentcheckassertioninSQL.
S2:GiventhetableR(a, b, c) wherea andb togetherformtheprimarykey,thefollowingisavalidtabledefinition.
CREATE TABLE S (
a INTEGER,
d INTEGER,
e INTEGER,
PRIMARY KEY (d),
FOREIGN KEY (a) references R)

WhichoneofthefollowingstatementsisCORRECT?
(A)S1isTRUEandS2isFALSE

http://gateoverflow.in/book

131/400

2/26/2015

GATEOverflow Book

(B)BothS1andS2areTRUE
(C)S1isFALSEandS2isTRUE
(D)BothS1andS2areFALSE

(D)botharefalse
S1:foreignkeyconstraintmeansalotofconstraintsithastobeaprimarykey(whichintrunhasfewconstraints)
wecannotreplaceitwithasinglecheck
S2:
ifaandbformsaprimarykeyinR,aalonecannotformaforeignkey.
foreignkendfn:itshouldbeacandidatekeyinsomeothertable(inourcaseitisonlyaprimeattribute)

pleaseaddpointsifihadmissedany
name

GATE20141_30top
Giventhefollowingtwostatements:
S1:Everytablewithtwosinglevaluedattributesisin1NF,2NF,3NFandBCNF.
S2:AB

.D

E E C

isaminimalcoverforthesetoffunctionaldependenciesAB

,D

E AB E

,E

WhichoneofthefollowingisCORRECT?
(A)S1isTRUEandS2isFALSE.
(B)BothS1andS2areTRUE.
(C)S1isFALSEandS2isTRUE.
(D)BothS1andS2areFALSE.

(A)S1isTRUEandS2isFALSE.
arelationwith2attributesisalwaysinbcnf
thetwosetsoffnuctionaldependecyarenotthesame,couldnotderiveab>Efromthe1stset

name

GATE2006_70top
Thefollowingfunctionaldependenciesaregiven:
AB C D, AF D, DE F , C G, F E, G A

Whichoneofthefollowingoptionsisfalse?

(A){C F }

(B){BG}

(C){AF }

(D){AB}

= {AC DEF G}
= {ABC DG}
= {AC DEF G}
= {ABC DG}

{AF}*={AFDE}.HenceoptionCiswrong
name

GATE20141_54top
Giventhefollowingschema:
employees(empid,firstname,lastname,hiredate,deptid,salary)
departments(deptid,deptname,managerid,locationid)
http://gateoverflow.in/book

132/400

2/26/2015

GATEOverflow Book

YouwanttodisplaythelastnamesandhiredatesofalllatesthiresintheirrespectivedepartmentsinthelocationID1700.Youissuethefollowingquery:
SQL>SELECT last-name, hire-date
FROM employees
WHERE (dept-id, hire-date) IN
(SELECT dept-id, MAX(hire-date)
FROM employees JOIN departments USING(dept-id)
WHERE location-id =1700
GROUP BY dept-id);

Whatistheoutcome?
(A)Itexecutesbutdoesnotgivethecorrectresult
(B)Itexecutesandgivesthecorrectresult.
(C)Itgeneratesanerrorbecauseofpairwisecomparison.
(D)ItgeneratesanerrorbecauseoftheGROUPBYclausecannotbeusedwithtablejoinsinasubquery.

SELECT dept-id, MAX(hire-date)


FROM employees JOIN departments USING(dept-id)
WHERE location-id =1700
GROUP BY dept-id

thisinnerquerywillgivethemaxhiredateofeachdepartmentwhoselocation_id=1700
andouterquerywillgivethelastnameandhiredateofallthoseemployeeswhojoinedonmaxhiredate.
answershouldcometo(B)noerrors
Andwecanusegroupbyandwheretogether,whosaidwecannot:(
Example:createtabledepartments(dept_idnumber,dept_namevarchar2(25),location_idnumber)
Query:selectd1.dept_name,max(d1.location_id)
fromdepartmentsd1,departmentsd2
whered1.dept_name=d2.dept_name
andd1.dept_name='AA'
groupbyd1.dept_name
willgiveoutput

name

GATE20142_22top
GivenaninstanceoftheSTUDENTSrelationasshownasbelow

StudentID
2345
1287
7853
9876
8765

StudentName
Shankar
Swati
Shankar
Swati
Ganesh

StudentEmail
Shankar@math
swati@ee
Shankar@cse
swati@mech
ganesh@civil

StudentAge
X
19
19
18
19

CPI
9.4
9.5
9.4
9.3
8.7

For(S tudentN ame, S tudentAge) tobeakeyforthisinstance,thevalueXshouldNOTbeequalto______.

shouldnoteqaulto19.
Sinceifitisequalthesamekeywillhavetwodifferentvalueswhichcannotbetruebythedefinitionofcandidate/primary/superkey.
name

GATE20143_21top
What is the optimized version of the relation algebra expression A1 ( A2 ( F 1 ( F 2 (r)))), where A1, A2 are sets of attributes in r with A1
F 1, F 2 areBooleanexpressionsbasedontheattributesinr ?

A2

and

(A) A1 ( (F 1F 2) (r))
(B) A1 ( (F 1F 2) (r))
(C) A2 ( (F 1F 2) (r))
(D) A2 ( (F 1F 2) (r))

http://gateoverflow.in/book

133/400

2/26/2015

GATEOverflow Book

(A)A1((F1F2)(r))

sinceA1issubsetofA2willgetonlyA1attributesasitisintheoutside,sowecanremoveprojectA2
twoselectswithbooleanexpreassioncanbecombinedintooneselectwithandoftwobooleanexpressions
name

GATE20143_22top
AprimeattributeofarelationschemeR isanattributethatappears
(A)inallcandidatekeysofR
(B)insomecandidatekeyofR
(C)inaforeignkeyofR
(D)onlyintheprimarykeyofR

primeattributeisaconstituentofacandidatekey.itneednotpresentinallcandidatekeys.henceoptionBiscorrect
correctmeifiwentwrong
name

GATE20143_30top
Considertherelationalschemagivenbelow,whereeIdoftherelationdependentisaforeignkeyreferringtoempIdoftherelationemployee.Assumethat
everyemployeehasatleastoneassociateddependentinthedependentrelation.
employee(empId,empName,empAge)
dependent(depId,eId,depName,depAge)
Considerthefollowingrelationalalgebraquery:
empI d (employee) empI d (employee (empI d=eI D)(empAgedepAge) dependent)

TheabovequeryevaluatestothesetofempIdsofemployeeswhoseageisgreaterthanthatof
(A)somedependent.
(B)alldependents.
(C)someofhis/herdependents.
(D)allofhis/herdependents.
(D)allofhis/herdependents.
Theinnerqueryselectstheemployeeswhoseageislessthanorequaltoatleastoneofhisdependents.So,subtractingfromthesetofemployees,gives
employeeswhoseageisgreaterthanallofhisdependents.
name

GATE20143_54top
Considerthefollowingrelationalschema:
employee(empId,empName,empDept)
customer(custId,custName,salesRepId,rating)
salesRepIdisaforeignkeyreferringtoempIdoftheemployeerelation.Assumethateachemployeemakesasaletoatleastonecustomer.Whatdoesthe
followingqueryreturn?
SELECT empName
FROM employee E
WHERE NOT EXISTS (SELECT custId
FROM customer C
WHERE C.salesRepId = E.empId
AND C.rating <> 'GOOD');

(A)NamesofalltheemployeeswithatleastoneoftheircustomershavingaGOODrating.
(B)Namesofalltheemployeeswithatmostoneoftheircustomershavinga'GOOD'rating.
http://gateoverflow.in/book

134/400

2/26/2015

GATEOverflow Book

(C)Namesofalltheemployeeswithnoneoftheircustomershavinga'GOOD'rating.
(D)Namesofalltheemployeeswithalltheircustomershavinga'GOOD'rating.
(D)
innerqueryselects"employeeswithatleastonebadrating"
sonegationontheabovestmtgive>"employeeswithallratingsasgood"
PS:putavendiagramandpracticeforthesekindofquestions
name

GATE2011_32top
ConsideradatabasetableTcontainingtwocolumnsX andY eachoftypeinteger.Afterthecreationofthetable,onerecord(X=1, Y=1) isinsertedinthe
table.
LetMXandMYdenotetherespectivemaximumvaluesofX andY amongallrecordsinthetableatanypointintime.UsingMXandMY,newrecordsare
insertedinthetable128timeswith X and Y valuesbeingMX+1, 2*MY+1respectively.Itmaybenotedthateachtimeaftertheinsertion,valuesof MX
andMYchange.
WhatwillbetheoutputofthefollowingSQLqueryafterthestepsmentionedabovearecarriedout?
SELECT Y FROM T WHERE X=7;

(A)127
(B)255
(C)129
(D)257
X=1,Y=1
X=2,Y=2*1+1=3
X=3,Y=2*3+1=7
X=4,Y=2*7+1=15
X=5,Y=2*15+1=31
X=6,Y=2*31+1=63
X=7,Y=2*63+1=127
name

GATE2011_46top
DatabasetablebynameLoan_Records isgivenbelow.

Borrower
Ramesh
Suresh
Mahesh

Bank_Manager
Sunderajan
Ramgopal
Sunderajan

Loan_Amount
10000.00
5000.00
7000.00

WhatistheoutputofthefollowingSQLquery?
SELECT count(*)
FROM (
SELECT Borrower, Bank_Manager FROM Loan_Records) AS S
NATURAL JOIN
(SELECT Bank_Manager, Loan_Amount FROM Loan_Records) AS T
);

(A)3
(B)9
(C)5
(D)6

http://gateoverflow.in/book

135/400

2/26/2015

GATEOverflow Book

ithinkansis(c)
whenweperformnaturaljoinonSandTthenresultwillbelikethis
BORROWBMANAGERLOAD_AMOUNT
rameshsunderajan10,000
rameshsunderajan7000
sureshramgopal5000
maheshsunderajan10,000
maheshsunderajan7000

afterthatcount(*)willcounttotaltuplespresentinthistablesohereitis5
nehapawar

GATE2012_43top
SupposeR 1 (
A , B)and R 2 ( C , D) aretworelationschemas.Let r 1 and r 2 bethecorrespondingrelationinstances. B isaforeignkeythatrefersto C in

R 2 .Ifdatainr 1 andr 2 satisfyreferentialintegrityconstraints,whichofthefollowingisALWAYSTRUE?


(A)B (r 1 ) C (r 2 ) =
(B)C (r 2 ) B (r 1 ) =
(C)B (r 1 ) = C (r 2 )
(D)B (r 1 ) C (r 2 )
(a)
Referentialintegritymeans,allthevaluesinforeignkeyshouldbepresentinprimarykey
r2(c)isthesupersetofr1(b)
so{subsetsuperset}isalwaysemptyset
name

GATE2010_42top
ConsiderthefollowingschedulefortransactionsT1,T2andT3:

T1
Read(X)

Write(X)

T2

Read(Y)

Write(Y)

Read(X)
Write(X)

T3

Read(Y)

Write(X)

Whichoneoftheschedulesbelowisthecorrectserializationoftheabove?
(A)T 1

T3 T2

(B)T 2

T1 T3

(C)T 2

T3 T1

(D)T 3

T1 T2

YoucanusemethodofconflictserializabilitygraphorprecedencegraphRef:ElmasriNavathe.ThenserialisationisT1T3T2
name

GATE2010_43top
ThefollowingfunctionaldependenciesholdforrelationsR(A, B, C ) andS (B, D, E).
B A
A C

TherelationR contains200tuplesandtherelationS contains100tuples.WhatisthemaximumnumberoftuplespossibleinthenaturaljoinR


http://gateoverflow.in/book

?
136/400

2/26/2015

GATEOverflow Book

(A)100
(B)200
(C)300
(D)2000

(A)100
naturaljoinwillcombinetupleswithsamevalueofthecommonrows(iftherearetwocommonrowsthenbothvauesmustbeequaltogetintotheresultant
set).Sobythisdefn:wecangetatthemaxonly100commonvalues:P
name

GATE1995_27top

a.selectpnamefrompublisher
2.selectauthor.*fromauthor,book
whereauthor.aname=book.name
andbook.pname='TECHNICALPUBLISHERS'
3.selectauthor.anamefromauthor,book,publisher
whereauthor.aname=book.aname
andbook.pname=publisher.pname
andpublisher.pcity='Madras'
name

GATE1996_27top
Alibraryrelationaldatabasesystemusesthefollowingschema
USERS(User#,UserName,HomeTown)
BOOKS(Book#,BookTitle,AuthorName)
ISSUED(Book#,User#,Date)
ExplaininoneEnglishsentence,whateachofthefollowingrelationalalgebraqueriesisdesignedtodetermine
a. User#=6 (User#, Book Title ((USERS ISSUED) BOOKS))
b. Author Name (BOOKS Home Town=Delhi (USERS ISSUED))
(a)Selectthe(user#and)titlesofthebooksissuedtoUser#6
(b)SelectauthornamesofthebooksissuedtouserswhosehometownisDelhi
name

functionaldependencytop
GIvenarelationinstance
X
2
2

Y
8
10

Z
4
6

2
6

12
4

6
4

http://gateoverflow.in/book

137/400

2/26/2015

GATEOverflow Book

whichofthefollowingFDsissatisfiedbyrelation
A)XYZ,ZY
B)YZX,YZ
C)YZX,XZ
D)XZY,YX
Z>YisnotsatisfiedaswhenZ=4,Yhasvalues8aswellas4.So,(A)isFalse.
YZandYareuniqueandhenceFDsin(B)aretriviallysatisfied.
X>ZisnotsatisfiedaswhenX=2,Zcanhave4aswellas6.So,(C)isfalse.
XZ>YisnotsatisfiedaswhenXZ={2,6},Ycanhave10aswellas12.So,Disfalse.
name

FindthenumberofcandidateskeysthatincludesattributeA3top
ArelationRwith5attributesA1,A2,A3,A4,A5.GiventhefollowingFDs
A1A2
A2A3A5
A4A5A1
FindthenumberofcandidateskeysthatincludesattributeA3
A4andA3arenotcomingontheRHSofanyFD.So,theymustbeinallcandidatekeys.
ConsiderA4A5,duetoA4A5>A1andA1>A2,A4A5determines{A1A2A4A5},andhenceA3A4A5isacandidatekey.
Similarly,A2A3A4andA1A3A4arecandidatekeys.
So,3istheanswer.
name

GATE2008IT_61top
LetR(A,B,C,D)bearelationalschemawiththefollowingfunctionaldependencies:
AB,BC,
CDandDB.ThedecompositionofRinto(A,B),(B,C),(B,D)

A)
B)
C)
D)

givesalosslessjoin,andisdependencypreserving
givesalosslessjoin,butisnotdependencypreserving
doesnotgivealosslessjoin,butisdependencypreserving
doesnotgivealosslessjoinandisnotdependencypreserving
OptionA.
(A,B)(B,C)>commonattributeisBandduetoB>C,Bisakeyfor(B,C)andhenceABCcanbelosslesslydecomposedinto(A,B)and(B,C).
(A,B,C)(B,D),commonattributeisBandB>DisaFD(viaB>C,C>D),andhenceBisakeyfor(B,D).So,decompositionof(A,B,C,D)into(A,B,
C)(B,D)islossless.
Thusthegivendecompositionislossless.
ThegivendecompositionisalsodependencypreservingasthedependenciesA>Bisispresentin(A,B),B>Cispresentin(B,C),D>Bispresentin(B,D)
andC>DisindirectlypresentviaC>Bin(B,C)andB>Din(B,D).
http://www.sztaki.hu/~fodroczi/dbs/deppresown.pdf
name

GATE2007IT_68top
Considerthefollowingrelationschemas:
bSchema=(bname,bcity,assets)
aSchema=(anum,bname,bal)
dSchema=(cname,anumber)
Letbranch,accountanddepositorberespectivelyinstancesoftheaboveschemas.Assumethataccountanddepositorrelationsaremuchbiggerthanthebranch
relation.
http://gateoverflow.in/book

138/400

2/26/2015

GATEOverflow Book

Considerthefollowingquery:
cname(bcity="Agra"bal<0(branch(accountdepositor)
Whichoneofthefollowingqueriesisthemostefficientversionoftheabovequery?

A)

cname(bal<0(bcity="Agra"branchaccount)depositor)

B)

cname(bcity="Agra"branch(bal<0accountdepositor))

C)

cname((bcity="Agra"branchbcity="Agra"bal<0account)depositor)

D)

cname(bcity="Agra"branch(bcity="Agra"bal<0accountdepositor))
ItshouldbeA.AsinBwearedoingajoinbetweentwomassivetablewhereasinAwearedoingjoinbetweenrelativelysmallertableandlargeroneandthe
outputthatthisinnertablegives(whichissmallerincomparisontojoinsthatwearedoinginB)isusedforjoinwithdepositertablewiththeselection
condition.
name

GATE2006IT_14top
Considertherelationsr1(P,Q,R)andr2(R,S,T)withprimarykeysPandRrespectively.Therelationr1contains2000tuplesandr2contains2500tuples.The
maximumsizeofthejoinr1r2is:

A)
B)
C)
D)

2000
2500
4500
5000
thecommonattributeisRanditisprimarykeyinthesecondrelation.hencetheRvalueisdistinctfor2500rows.hencewhenwejoinmaxpossiblenumber
oftuplesis2000
optionA
name

GATE2006IT_84top

Consideradatabasewiththreerelationinstancesshownbelow.TheprimarykeysfortheDriversandCarsrelationaredidandcidrespectivelyandtherecords
arestoredinascendingorderoftheseprimarykeysasgiveninthetables.Noindexingisavailableinthedatabase.
did
22
29
31
32
58
64
71
74
85
95

D:Driversrelation
dname
Karthikeyan
7
Salman
1
Boris
8
Amoldt
8
Schumacher
10
Sachin
7
Senna
10
Sachin
9
Rahul
3
Ralph
3

did
22
22
22
22
31
31
31
64
64
http://gateoverflow.in/book

101
102
103
104
102
103
104
101
102

R:Reservesrelation
cid
10/10/06
10/10/06
08/10/06
07/10/06
10/11/06
06/11/06
12/11/06
05/09/06
08/09/06

rating

age
25
33
55
25
35
35
16
35
25
53

day

139/400

2/26/2015

GATEOverflow Book

74

103

08/09/06
C:carsrelation
cname

cid

colour

101
102

Renault
Renault

blue
red

103
104

Ferrari
Jaguar

green
red

WhatistheoutputofthefollowingSQLquery?
select D.dname
from Drivers D
where D.did in (

A)
B)
C)
D)

select R.did
from Cars C, Reserves R
where R.cid = C.cid and C.colour = 'red'
intersect
select R.did
from Cars C, Reserves R
where R.cid = C.cid and C.colour = 'green'
)

Karthikeyan,Boris
Sachin,Salman
Karthikeyan,Boris,Sachin
Schumacher,Senna

Forcolor="Red"
did={22,22,31,64}
Forcolor="Green"
did={22,31,74}
intersectionofRedandGreenwillgive={22,31}
whichisKarthikeyanandBoris
Ans:A
name

GATE2004IT_21top
Whichleveloflockingprovidesthehighestdegreeofconcurrencyinarelationaldatabase?

A)
B)
C)
D)

Page
Table
Row
Page,tableandrowlevellockingallowthesamedegreeofconcurrency
rowlevellockingprovidesmoreconcurrency.becausedifferenttransactionscanaccessdifferentrowsinatable/pageatsametime
name

GATE2004IT_74top
A relational database contains two tables student and department in which student table has columns roll_no, name and dept_id and department table has
columnsdept_idanddept_name.Thefollowinginsertstatementswereexecutedsuccessfullytopopulatetheemptytables:
Insert into department values (1, 'Mathematics')
Insert into department values (2, 'Physics')
Insert into student values (l, 'Navin', 1)
Insert into student values (2, 'Mukesh', 2)
Insert into student values (3, 'Gita', 1)

HowmanyrowsandcolumnswillberetrievedbythefollowingSQLstatement?
http://gateoverflow.in/book

140/400

2/26/2015

GATEOverflow Book

Select * from student, department

A.
B.
C.
D.

0rowand4columns
3rowsand4columns
3rowsand5columns
6rowsand5columns

sincethereisnospecificjoiningconditionspecifieditwillretrievecartesianproductofthetable
numberofrows=productofnumberofrowsineachrealtion=3*2=6
numberofcolumns=sumofnumberofcolumns=3+2=5
answer:D
name

GATE2004IT_75top
ArelationEmpdtlisdefinedwithattributesempcode(unique),name,street,city,stateandpincode.Foranypincode,thereisonlyonecityandstate.Also,for
anygivenstreet,cityandstate,thereisjustonepincode.Innormalizationterms,Empdtlisarelationin
A.
B.
C.
D.

1NFonly
2NFandhencealsoin1NF
3NFandhencealsoin2NFand1NF
BCNFandhencealsoin3NF,2NFan1NF

itsin2nffor2nfallnonprimeattributeshouldbefullyfunctionallydependentonkey.herekeyisempcode.keycontainsonlyoneattributehence.no
partialdependency.butthereistransitivedependencyinthis.soitisnotin3NF
answer:B
name

GATE2004IT_76top
AtableT1inarelationaldatabasehasthefollowingrowsandcolumns:
rollno.

marks

10

20

30

Null

ThefollowingsequenceofSQLstatementswassuccessfullyexecutedontableT1.
Update T1 set marks = marks + 5
Select avg(marks) from T1

Whatistheoutputoftheselectstatement?

A.
B.
C.
D.

18.75
20
25
Null

Updateonnullgivesnull.Now,avgfunctionignoresnullvalues.So,hereavgwillbe(15+25+35)/3=25.
http://msdn.microsoft.com/enus/library/ms177677.aspx
name

GATE2004IT_78top
Considertwotablesinarelationaldatabasewithcolumnsandrowsasfollows:
http://gateoverflow.in/book

141/400

2/26/2015

GATEOverflow Book

Table:Student
Name
ABC
DEF
GHI
JKL

Roll_no
1
2
3
4

Dept_id
1
1
2
3

Table:Department
Dept_id

Dept_name

1
2
3

A
B
C

Roll_no is the primary key of the Student table, Dept_id is the primary key of the Department table and Student.Dept_id is a foreign key from
Department.Dept_id
WhatwillhappenifwetrytoexecutethefollowingtwoSQLstatements?
i. updateStudentsetDept_id=NullwhereRoll_on=1
ii. updateDepartmentsetDept_id=NullwhereDept_id=1

A)
B)
C)
D)

Both(i)and(ii)willfail
(i)willfailbut(ii)willsucceed
(i)willsucceedbut(ii)willfail
Both(i)and(ii)willsucceed
ansisC
herein(i)whenweupdateinSTUDENTtabledeptid=NULLthenitwillnotcauseanyproblemtoreferencedtable
butin(II)ifwesetinDEPARTMENTtabledeptid=NULLthenitwillproduceinconsistencybecauseinSTUDENTtablewestillhavethetuples
containingthedeptid=1
nehapawar

GATE2005IT_21top
Considertheentities'hotelroom',and'person'withamanytomanyrelationship'lodging'asshownbelow:

Ifwewishtostoreinformationabouttherentpaymenttobemadebyperson(s)occupyingdifferenthotelrooms,thenthisinformationshouldappearasan
attributeof

A)
B)
C)
D)

Person
HotelRoom
Lodging
Noneofthese
sinceitismanytomany.rentcannotbeanattributeofroomorpersonentitiesalone.ifdependingonnumberofpersonssharingaroomtherentforeach
personfortheroomwillbedifferent.otherwiserentcanbeattributeofroom.henceigoforattributeofLodging
name

GATE2005IT_22top
AtablehasfieldsFl,F2,F3,F4,F5withthefollowingfunctionaldependencies
F1F3F2F4(F1.F2)F5
IntermsofNormalization,thistableisin

1)
2)
3)

1NF
2NF
3NF

http://gateoverflow.in/book

142/400

2/26/2015

GATEOverflow Book

4)

Noneofthese
ans:1
keyisf1f2
f1>f3,f2>f4arepartialdependencies
name

GATE2005IT_24top
AmongsttheACIDpropertiesofatransaction,the'Durability'propertyrequiresthatthechangesmadetothedatabasebyasuccessfultransactionpersist

1)
2)
3)
4)

ExceptincaseofanOperatingSystemcrash
ExceptincaseofaDiskcrash
Exceptincaseofapowerfailure
Always,evenifthereisafailureofanykind
answerd.irrespectiveofanyfailurethesuccessfulresultoftransactionshouldpersist.
supposewebookticket2monthsinadvanceinirctcandtransactionsuccess
thenwhenwearegoingtoboardthetrainonthattimetheytellsbecauseofsystem/disk/powercrashtheydonthaveyourseatinformationandyouarenot
allowedintheseat
itisaseriousproblem.henceresultshouldpersistirrespectiveofallcrashes
name

GATE2005IT_67top
Acompanymaintainsrecordsofsalesmadebyitssalespersonsandpaysthemcommissionbasedoneachindividual'stotalsalesmadeinayear.Thisdatais
maintainedinatablewithfollowingschema:
salesinfo=(salespersonid,totalsales,commission)
Inacertainyear,duetobetterbusinessresults,thecompanydecidestofurtherrewarditssalespersonsbyenhancingthecommissionpaidtothemasperthe
followingformula:
Ifcommission<=50000,enhanceitby2%
If50000<commission<=100000,enhanceitby4%
Ifcommission>100000,enhanceitby6%
TheITstaffhaswrittenthreedifferentSQLscriptstocalculateenhancementforeachslab,eachofthesescriptsistorunasaseparatetransactionasfollows:

Update salesinfo

T1Set commission = commission * 1.02

Where commission < = 50000;

Update salesinfo

T2Set commission = commission * 1.04

Where commission > 50000 and commission is < = 100000;

Update salesinfo

T3Set commission = commission * 1.06


Where commission > 100000;

Whichofthefollowingoptionsofrunningthesetransactionswillupdatethecommissionofallsalespersonscorrectly

1)
2)
3)
4)

ExecuteT1followedbyT2followedbyT3
ExecuteT2,followedbyT3T1runningconcurrentlythroughout
ExecuteT3followedbyT2T1runningconcurrentlythroughout
ExecuteT3followedbyT2followedbyT1

http://gateoverflow.in/book

143/400

2/26/2015

GATEOverflow Book

T3followedbyT2followedbyT1willbecorrectexecutionsequence
othercasessomepeoplewillgettwotimesincrement
egifwehaveT1followedbyT2
ifinitialcommisionis49500
thenheisbelongingto<50000
hence49500*1.02=50490
nowheiseligibleinsecondcategory
then50490*1.04=52509.6

sohewilgetincrementtwotimes.butheiseligibleforonlyoneslabofcommision
name

GATE2005IT_70top
InaschemawithattributesA,B,C,DandEfollowingsetoffunctionaldependenciesaregiven

AB
AC
CDE
BD
EA

WhichofthefollowingfunctionaldependenciesisNOTimpliedbytheaboveset?

A)
CDAC
B)
BDCD
C)
BCCD
D)
ACBC

AnswerisB.
ApplymembershiptestforallthegivenFunctionalDependencies.
1.)CD>AC
CD+=CDEAB
2.)BD>CD
BD+=BD
i.e.BDcannotderiveCDandhenceisnotimplied.
Similarlydoforresttwo.
name

GATE2005IT_82atop
AdatabasetableT1has2000recordsandoccupies80diskblocks.AnothertableT2has400recordsandoccupies20diskblocks.Thesetwotableshavetobe
joinedasperaspecifiedjoinconditionthatneedstobeevaluatedforeverypairofrecordsfromthesetwotables.Thememorybufferspaceavailablecanhold
exactlyoneblockofrecordsforT1andoneblockofrecordsforT2simultaneouslyatanypointintime.Noindexisavailableoneithertable.
IfNestedloopjoinalgorithmisemployedtoperformthejoin,withthemostappropriatechoiceoftabletobeusedinouterloop,thenumberofblockaccesses
requiredforreadingthedataare

A)
B)
C)
D)

800000
40080
32020
100

Refer:http://en.wikipedia.org/wiki/Nested_loop_join
http://gateoverflow.in/book

144/400

2/26/2015

GATEOverflow Book

asperthisreferenceThisalgorithmwillinvolvenr*bs+brblocktransfers
eitherT1canbeRorT2
ifRisT1thentotalnumberofblockaccessis2000*20+80=40080
ifRisT2thentotalnumberofblockaccessis400*80+20=32020
sobetteristhesecondcase(32020)HenceigoforoptionC

name

GATE2005IT_82btop
AdatabasetableT1has2000recordsandoccupies80diskblocks.AnothertableT2has400recordsandoccupies20diskblocks.Thesetwotableshavetobe
joinedasperaspecifiedjoinconditionthatneedstobeevaluatedforeverypairofrecordsfromthesetwotables.Thememorybufferspaceavailablecanhold
exactlyoneblockofrecordsforT1andoneblockofrecordsforT2simultaneouslyatanypointintime.Noindexisavailableoneithertable.
If,insteadofNestedloopjoin,Blocknestedloopjoinisused,againwiththemostappropriatechoiceoftableintheouterloop,thereductioninnumberofblock
accessesrequiredforreadingthedatawillbe

A) 0
B) 30400
C) 38400
D) 798400

InNestedloopjoinforeachtupleinfirsttablewescanthroughallthetuplesinsecondtable.

HerewewilltaketableT2astheoutertableinnestedloopjoinalgorithm.Thenumberofblockaccessesthenwillbe20+(40080)=32020
Inblocknestedloopjoinwekeep1blockofT1inmemoryand1blockofT2inmemoryanddojoinontuples.

ForeveryblockinT1weneedtoloadallblocksofT2.Sonumberofblockaccessesis80*20+20=1620
Sothedifferenceis320201620=30400
(B)30400
name

ThomasWriteRuletop

Ans:A
http://en.wikipedia.org/wiki/Thomas_write_rule
name

GATE20152_1top
http://gateoverflow.in/book

145/400

2/26/2015

GATEOverflow Book

Considerthefollowingtransactioninvolvingtwobankaccountsx andy .
read(x); x:=x-50; write (x); read(y); y:=y+50; write(y)

Theconstraintthatthesumoftheaccountsx andy shouldremainconstantisthatof


A.
B.
C.
D.

Atomicity
Consistency
Isolation
Durability

KindlycheckoutPPTforTransactionchapterinbelowlink.(Slide5)
http://www.cse.iitb.ac.in/~sudarsha/dbbook/slidedir/
QuestionisdirectlytakenfromKorth.AndwordingalmostcompletelymatchestoConsistencyrequirement.
kshirsagar1992

GATE20152_6top
WithreferencetotheB+treeindexoforder1shownbelow,theminimumnumberofnodes(includingtheRootnode)thatmustbefetchedinordertosatisfythe
followingquery."Getallrecordswithasearchkeygreaterthanorequalto7andlessthan15"is______.

Thetotalnumberofnodesaccessedincludingrootwillbe5.
Theorderis,
(9)>(5)>(5,7)>(9,11)>(13,15).
name

GATE20151_7top
SELECToperationinSQLisequivalentto
A.
B.
C.
D.

Theselectionoperationinrelationalalgebra
Theselectionoperationinrelationalalgebra,exceptthatSELECTinSQLretainsduplicates
Theprojectionoperationinrelationalalgebra
Theprojectionoperationinrelationalalgebra,exceptthatSELECTinSQLretainsduplicates

optionDiscorrectbecauseSELECToperationinSQLisequivalenttoTheprojectionoperationinrelationalalgebra,exceptthat
SELECTinSQLretainsduplicatesbutprojectiongivesonlydistinct
name

GATE20151_24top
Afileisorganizedsothattheorderingofthedatarecordsisthesameasorclosetotheorderingofdataentriesinsomeindex.Thanthatindexiscalled
A.
B.
C.
D.

Dense
Sparse
Clustered
Unclustered

Clusteredthisisthedefinitionofclusteredindexingandforthesamereasonatablecanhaveonlyoneclusteredindex.
http://www.ece.rutgers.edu/~yyzhang/spring03/notes/7B+tree.ppt
name
http://gateoverflow.in/book

146/400

2/26/2015

GATEOverflow Book

GATE20151_27top
Considerthefollowingrelation:
Student
RollNo
1
2
3

Studentname
Raj
Rohit
Raj

Performance
RollNo
1
1
2
3
2
3

Course
Math
English
Math
English
Physics
Math

Marks
80
70
75
80
65
80

ConsiderthefollowingSQLquery.
SELECT S. student_Name, Sum(p. Marks)
FROM student S, performance P
WHERE S.Roll_No= P.Roll_No
GROUP BY S.STUDENT_Name

ThenumbersofrowsthatwillbereturnedbytheSQLqueryis_________________.

answeris2asthereareonly2distinctstudentnames.
naresh1845

GATE20151_41top
ConsideranEntityRelationship(ER)modelinwhichentitysetsE1 andE2 areconnectedbyanm:nrelationshipR12 .E1 andE3 areconnectedbya1:n(1on
thesideofE1 andnonthesideofE3 )relationshipR13 .
E1 hastwosingledattributesa11 anda12 ofwhicha11 isthekeyattribute.E2 hastwosingledvaluedattributesa21 anda22 ofwhicha21 isthekeyattribute.
E3 hastwosinglevaluedattributesa31 anda32 ofwhicha31 isthekeyattribute.Therelationshipsdonothaveanyattributes.
IfarelationalmodelisderivedfromtheaboveERmodel,thentheminimumnumberofrelationsthatwouldbegeneratedifallrelationarein3NF
is________________.

Answeris4.Therelationsareasshown:
<a11,a12>forE1
<a21,a22>forE2
<a31,a32,a11>forE3andE1E3relationship
<a11,a21>form:nrelationshipE1E2
Wecannotcombineanyrelationhereasitwillgiverisetopartialfunctionaldependencyandthusviolate3NF.
http://cisnet.baruch.cuny.edu/holowczak/classes/9440/entityrelationship/

name

GATE20153_3top
Considerthefollowingrelation
Cinema(theater, address, capacity )
WhichofthefollowingoptionswillbeneededattheendoftheSQLquery
SELECT P1.address
FROM Cinema P1

http://gateoverflow.in/book

147/400

2/26/2015

GATEOverflow Book

suchthatitalwaysfindstheaddressesoftheaterswithmaximumcapacity?

A. A. WHERE P1.capacity >= All (select P2.capacity from Cinema P2)


B. B. WHERE P1.capacity >= Any (select P2.capacity from Cinema P2)
C. C. WHERE P1.capacity > All (select max(P2.capacity) from Cinema P2)
D. D. WHERE P1.capacity > Any (select max(P2.capacity) from Cinema P2)
Aistheanswer
BReturnstheaddressesofalltheatersexcepttheonewiththemincapacity
CReturnsnullset.max()returnsasinglevalueandtherewon'tbeanyvalue>max.
DReturnsnullset.SamereasonasC.AllandANYworksthesamehereasmaxreturnsasinglevalue.
name

GATE20153_20top
ConsidertherelationX(P , Q, R, S , T , U ) withthefollowingsetoffunctionaldependencies
F = {
{P , R} {S , T }
{P , S , U } {Q, R}
}

WhichofthefollowingisthetrivialfunctionaldependencyinF + ,whereF + isclosuretoF?

A.
B.
C.
D.

{P , R} {S , T }
{P , R} {R, T }
{P , S } {S }
{P , S , U } {Q}

optionCiscorrectbecause{P,S}{S}
for trivial if XY then Y must b subset of X and for non trivial FD X

Y=.and{S}issubsetof{P,S}

name

GATE20153_46top
ConsideraB+treeinwhichthesearchkeyis12byteslong,blocksizeis1024bytes,recorderpointeris10byteslongandtheblockpointeris8bytelong.The
maximumnumberofkeysthatcanbeaccommodatedineachnonleafnodeofthetreeis______.
(n1)12+n*8<=1024
n<=51
innonleafnodenumberofkeys=n1
=511=50
ppm

http://gateoverflow.in/book

148/400

2/26/2015

GATEOverflow Book

TheoryofComputationtop
GATE2012_12top
WhatisthecomplementofthelanguageacceptedbytheNFAshownbelow?
Assume = and istheemptystring.
a

![enterimagedescriptionhere][1]
(A)
(B)
(C)a
(D)a,

[1]:http://gatecse.in/w/images/c/c5/2012_12.png
Thelanguagebeingacceptedisa+ .So,complementofthelanguageis{} .
name

Considerthefollowinglanguagestop
Considerthefollowinglanguages
A = {< M > TM M accepts at most 2 distinct inputs}

B = {< M > TM M accepts more than 2 distinct inputs}

Identifythecorrectstatementfromthefollowing:
(A)A isTuringrecognizableB isnotTuringrecognizable
(B)B isTuringrecognizableA isnotTuringrecognizable
(C)BothA andB areTuringrecognizable
(D)NeitherA norB isTuringrecognizable
BistheanswerAisnotTuringrecognizablewhileBisTuringrecognizable.
AisTuringrecognizableifTMforA,sayTA outputs"yes"for"yes"casesofAi.e.whenMacceptsatmost2distinctinputs.ButMcanloopforever
withoutacceptingmorethan2distinctinputsandwecanneverbesureifitwillorwillnotacceptanymoreinput.Thus,TA maynotoutput"yes"for"yes"
casesofthelanguageandhenceAisnotTuringrecognizable.
Similarly,BisTuringrecognizableifTMforB,sayTB outputs"yes"for"yes"casesofBi.e.whenMacceptsmorethan2distinctinputs.IfMis
acceptingmorethan2distinctinputs,it'spossibletoenumerateallstringsfromthelanguage(stringsoflength1followedbystringsoflength2andsoon)
andfeedtoM.(Weshoulduse[dovetailing][1]techniquesothatevenifsomestringcausesTMtoloopforever,wecancontinueprogress).IfMis
acceptingmorethan2distinctinputswearesurethatwe'llencounterthosestringsaftersomefinitemovesoftheTM.ThusTB canalwaysoutput"yes"for
"yes"casesofthelanguageandhenceBisTuringrecognizable.
(It'seasiertoseethatAandBarecomplementtoeachother.TMcansay"yes"for"yes"casesofBmeansitcansay"no"for"no"casesofA.ButtomakeA
Turingrecognizableweneedtheoutput"yes"for"yes"casesofA,whichisnotthecasehere.)
(OnceweprovethatBisTuringrecognizablebutnotTuringacceptable(recursive),thereisnoneedtocheckforA.ThecomplementofaTuring
recognizablebutnotTuringacceptablelanguageisalwaysnotTuringrecognizable.)
[1]:http://www.xamuel.com/dovetailing/
name

IdentifytheclassofLtop
Consider
L_1 =
n

a b c

|m, n 1

L_2 =
n

a b |n 1

L_3 =

http://gateoverflow.in/book

149/400

2/26/2015

GATEOverflow Book

L_3 =
(a + b)

(1)IntersectionofL_1 andL_2 is
(A)Regular(B)CFLbutnotregular(C)CSLbutnotCFL(D)Noneofthese
(2)L_1 L_3 is
(A)Regular(B)CFLbutnotregular(C)CSLbutnotCFL(D)Noneofthese
(1)Regular.
LL
={abcd,aabbcd,aaabbbccdd,.....}{ab,aabb,aaabbb,....}
=
(2)CFL
LL=L,henceCFL
Proof,
LL={abcd,aabbcd,aaabbbccdd,.....}{,a,b,ab,aab,.....}
={abcd,aabbcd,aaabbbccdd,.....}
=L
name

Let = {a, b, c}.Whichofthefollowingstatementsistrue?top


Let<math>=\{a,b,c\}</math>.Whichofthefollowingstatementsistrue?
a)Forany<math>A*</math>,if<math>A</math>isregular,thensois<math>\{xx|xA\}</math>
b)Forany<math>A*</math>,if<math>A</math>isregular,thensois<math>\{x|xxA\}</math>
c)Forany<math>A*</math>,if<math>A</math>iscontextfree,thensois<math>\{xx|xA\}</math>
d)Forany<math>A*</math>,if<math>A</math>iscontextfree,thensois<math>\{x|xxA\}</math>
WecangetaDFAfor<math>L=\{x|xxA\}</math>asfollows:
TakeDFAfor<math>A</math>(Q, , , S , F ) witheverythingsameexceptinitiallymakingF = .
NowforeachstateD Q ,consider2separateDFAs,onewith<math>S</math>asthestartstateand<math>D</math>asthefinalstateandanotherwith
<math>D</math>asthestartstateandsetoffinalstates F .IfboththeseDFAsacceptsamelanguagemake<math>D</math>asfinalstate.
Thisprocedureworksascheckingtheequivalenceof2DFAsisdecidable.
**Contradictionsforotherchoices**
a)ConsiderA

.Nowforw

A, L =

whichiscontextsensitive

xx|x A
=
ww|w

c)Sameexampleasfor(a)
d)ConsiderA
n

=
n

a b c a b c

|n 0

ThisisCFL.ButifwemakeLfromAasper(d),it'llbe
L =
whichisnotcontextfree..
n

a b c

|n

ge0

name

AppropriateoptionforLtop
Considerthefollowinglanguages
={an bn |n 0}
L 2 =Complement(L 1 )
L1

http://gateoverflow.in/book

L1

L2

150/400

2/26/2015

GATEOverflow Book

ChosetheappropriateoptionregardingthelanguagesL1 andL2
(A)L1 andL2 arecontextfree
(B)L1 iscontextfreebutL2 isregular
(C)L1 iscontextfreeandL2 iscontextsensitive
(D)Noneoftheabove
L_1 isclearlyaDCFLandDCFLisclosedundercomplement.Hence,L_2 isalsoDCFL.
WecanmakeaPDAforL2 ,usingthesamePDAfor{ab}asfollows:

Startbypushingeach'a'ontostack.Whenbcomesstartpopping.If'a'comesaftera'b'or'b'comeswhenthestackisempty,gotoafinalstatefromwhere
thePDAacceptsanystring.Otherwise,attheendofthestring,ifstackisnonempty,acceptthestringandifstackisempty,rejectthestring.
name

L={|L(M)isinfinite}top
L={<M>|L(M)isinfinite}
A.LisREbutL'isnotRE
B.BothLandL'areRE
C.LisnotREbutL'isRE
D.BothLandL'arenotRE

LetsassumeLisRE.So,wehaveaTMNwhichwillsay"yes"ifgivenanencodingofaTMwhoselanguageisinfinite.NowusingNwetrytosolvenon
haltingproblemasfollows:
Anonhaltingproblemisgivenasfollows:GivenanencodingofTM<H>andawordw,whetherHdoesnothaltonw.Thatis,wehavetodecideifHdoes
nothaltonw.ThisproblemisprovedtobenotREandsonoTMcannotevensay"yes"for"yes"casesoftheproblem.
Now,givenahaltingproblem(<H>,w),weproceedasfollows:WemakeanewTMsayA,whichoninputx,justsimulatesHonwfor|x|steps.IfHhalts
onw,Agoestorejectstate.Otherwiseitaccepts.So,L(A)= ifHdoesnothaltonwandL(A)=afinitesetifHhaltsonw.(IfHhaltsin|x|stepsforw,
anystringwithlengthgreaterthan|w|,wouldcertainlybenotinL,makingLafiniteset).
Now,wejustgivetheencodingofAtoourassumedTMN.IfNsays"accept",wehavethatL(A)isinfinite=>Hdoesnothaltonw=>wesolved"yes"
caseofnothaltingproblem,whichisnotpossible.Hence,ourinitialassumptionofLisREisfalse.LisnotRE.
ProvingL'isnotREiseasy.
L'={<M>|L(M)isfinite}
L(M)isfiniteisanonmonotonicpropertyofTM.BecausewecantakeTMTyes withL(Tyes ) = andTno withL(Tno ) = .Here,Tyes satisfiesthe
property(ofbeingfinite)andTno doesnotsatisfythepropertyandL(Tyes ) L(Tno ),makingthisanonmonotonicpropertyofTM.Andhencethis
becomesnotREasperRice'stheoremsecondpart.

So,bothLandL'arenotREmaking(D)thecorrectanswer.
http://gatecse.in/wiki/Rice%27s_Theorem_with_Examples
gatecse

L={|L(M)=*}top

L = {< M > L(M ) = }

A.LisREbutL isnotRE
B.BothLandL areRE
C.LisnotREbutL isRE

D.BothLandL arenotRE
Yes.BothLandL'arenotRE.WecanhavethesamereductionasdoneforL(M)isinfinite.

LetsassumeLisRE.So,wehaveaTMNwhichwillsay"yes"ifgivenanencodingofaTMwhoselanguageis .NowusingNwetrytosolvenon
haltingproblemasfollows:

Anonhaltingproblemisgivenasfollows:GivenanencodingofTM<H>andawordw,whetherHdoesnothaltonw.Thatis,wehavetodecideifHdoes
nothaltonw.ThisproblemisprovedtobenotREandsonoTMcannotevensay"yes"for"yes"caseoftheproblem.

Now,givenahaltingproblem(<H>,w),weproceedasfollows:WemakeanewTMsayA,whichoninputx,justsimulatesHonwfor|x|steps.IfHhalts

onw,Agoestorejectstate.Otherwiseitaccepts.So,L(A) = ifHdoesnothaltonwandL(A)=afinitesetifHhaltsonw.(IfHhaltsin|x|stepsfor
http://gateoverflow.in/book

151/400

2/26/2015

GATEOverflow Book

w,anystringwithlengthgreaterthan|w|,wouldcertainlybenotinL,makingLafinitesetandhencecanneverequal ).

Now,wejustgivetheencodingofAtoourassumedTMN.IfNsays"accept",wehavethatL(A)is =>Hdoesnothaltonw=>wesolved"yes"caseof
nothaltingproblem,whichisnotpossible.Hence,ourinitialassumptionofLisREisfalse.LisnotRE.

ProvingL'isnotREiseasy.

L'={<M>|L(M)isnotequalto }

L(M)isnotequalto isanonmonotonicpropertyofTM.BecausewecantakeTMTyes withL(Tyes ) = andTno withL(Tno ) = .Here,Tyes


satisfiestheproperty(ofbeingnotbeingequalto )andTno doesnotsatisfythatpropertyandL(Tyes ) L(Tno ),makingthisanonmonotonic
propertyofTM.AndhencethisbecomesnotREasperRice'stheoremsecondpart.

So,bothLandL'arenotREmaking(D)thecorrectanswer.

http://gatecse.in/wiki/Rice%27s_Theorem_with_Examples
gatecse

GATE2003_15top
IfthestringsofalanguageLcanbeeffectivelyenumeratedinlexicographic(i.e.,alphabetic)order,whichofthefollowingstatementsistrue?
(A)LisRegular
(b)LiscontextfreebutnotnecessarilyRegular
(c)LisrecursivebutnotnecessarilyRegular
(d)LisrecursivelyenumerablebutnotnecessarilyRecursive

Answeris(c)LisrecursivebutnotnecessarilyRegularornotevencontextfree.

Since,thestringsofLcanbeenumerateditmeansLisrecursivelyenumerable.ThatiswehaveaTMwhichacceptsallstringsinL.Now,toberecursivethe
TMshouldrejectallstringsnotinL.Since,thestringsofthelanguagecanbeenumeratedinlexicographicorder,it'seasytodothis.Foranywordw ,ifwe
seeawordintheenumerationwhichislexicographicallyhigherthanw butnow ,itmeansw isnotinthelanguage.ThismakesL'''recursive'''.

Now,whyLneednotbecontextfreeorregular?Consider
n

L = {a b c

|n 0}

Thestringsofthislanguagecanbeenumeratedinlexicographicorder.ButweknowLisnotcontextfreeasnoPDAcanacceptL.
name

TosayP=NPtop
TosayP=NPwhichoneofthefollowingissufficient?(Allreductionsinpolynomialtime)
A.ReductionofaNPproblemtoaPproblem
B.ReductionofaNPcompleteproblemtoaPproblem
C.ReductionofaPproblemtoanNPproblem
D.ReductionofaPproblemtoanNPcompleteproblem

OptionBisthemostcorrectanswer.(ToknowwhyitisnotTHEcorrectanswerreadthetailsectionofthisanswer)
Thereasonsareasfollows.
AproblempinNPisNPcompleteifeveryotherprobleminNPcanbetransformedintopinpolynomialtime.Theyhaveanotherpropertythatgivena
probleminNPandasolution,wecanverifydeterministicallyinpolynomialtimethatthesolutionisindeedavalidsolutionornot.
Prepresentstheclassofallproblemswhosesolutioncanbefoundinpolynomialtime.
ReductionofanNPCproblemtoaPproblemwouldimply2things:
1)AllproblemsinNParereducibletothisprobleminPbecauseallNPproblemsarereducibletoNPCproblems.
2)WecansolvetheNPCprobleminpolynomialtimeaswellbecausewecasolvetherprobleminPinpolynomialtimebydefinitionofclassP.
ThisimpliesthatallproblemsinNParesolvableinpolynomialtime.(1)
AproblemwhichcanbesolvedinpolynoimialtimeisessentialinP
WhichimpliesP=NP(QED)
http://gateoverflow.in/book

152/400

2/26/2015

GATEOverflow Book

Tail
ThestatementofoptionBisincomplete.ItisnotenoughttosaythatthatreductionofNPCproblemtoaprobleminP,butthereductionshouldbe
polynomialreductionorkarpreduction.
ThestatementwhichimpliesP=NPwouldbeThereexistapolynomialtimereductionofaprobleminNPCtoaprobleminP.Theanswerispartially
correctbecausewhenwesayreduction,weusuallymeanpolynomialtimereduction,butneverthlessitdoesnthurttobeprecise.
name

LetLbearegularlanguagetop
LetLbearegularlanguageandw beastringinL.Ifw canbesplitintox, y andz suchthat|xy|
|y| > 0 then,

(A)i N , xy i z L
(B)i

N , xy z L

(C)i

N , xy z L

(D)i

N , xy z L

numberofstatesintheminimalDFAforL,and

(C)i

N , xy z L

ThisistheresultofPumpingLemmaforregularlanguage
name

Whichofthefollowingareusefulinprovingalanguagetoberegular?top
Whichofthefollowingareusefulinprovingalanguagetoberegular?
1. MyhillNerodetheorem
2. Pumpinglemma
3. DrawinganNFA
4. Formingaregularexpression
(A)Allofthese
(B)1,3and4only
(C)2,3and4only
(D)3and4only

(B)1,3and4only
Asfromthegivenoptions,MyhillNerodetheoremisusefulbyprovidingnecessaryandsufficientconditionforprovingthatalanguageregular.Pumping
lemmaisoftenusedtoprovethatalanguageisnonregular.DrawinganNFAcanbeusefultoprovealanguageisregular.Formingaregularexpressioncan
alsohelpusproveifitisaregularlanguage

name

GATE2003_54top
DefinelanguagesL0andL1asfollows:
L 0 = {< M , w, 0 > M halts onw}

L 1 = {< M , w, 1 > M does not halts onw}

Here< M , w, i >isatriplet,whosefirstcomponentM isanencodingofaTuring


Machine,secondcomponentw isastring,andthirdcomponenti isabit.
LetL = L0 L1 .Whichofthefollowingistrue?

(A)Lisrecursivelyenumerable,butisnot
(B)Lisrecursivelyenumerable,butL isnot
(C)BothLandL arerecursive

(D)NeitherLnorL isrecursivelyenumerable

http://gateoverflow.in/book

153/400

2/26/2015

GATEOverflow Book

BothLandLareundecidableandnotevensemidecidable(notrecursivelyenumerable).BecausehaltingproblemcanbesolvedwithbothLandL.
Haltingproblemcanbestatedasfollows:AmachineM andawordw aregiven.Youhavetotell,ifM haltsonw .

So,tosolvehaltingproblem< M , w > usingL,justgive< M , w, 0 > and< M , w, 1 > totwoinstancesofT whichistheassumedTuringmachine


forL.IfT acceptsthetriplet< M , w, 0 > ,itmeansM haltsonw =>wehavesolvedhaltingproblem.IfT acceptsthetriplet< M , w, 1 > ,itmeans
M doesn'thaltonw =>wehavesolvedhaltingproblem.Weknowthateither< M , w, 0 > or< M , w, 1 > isinL .So,ifL isrecursivelyenumerable,
T isboundtostoponatleastoneoftheseinputs(T M forarecursivelyenumerablelanguagestopsandaccepts,whenprovidedwithawordinitslanguage).

Hence,ifLisrecursivelyenumerablewecansolvehaltingproblem=>Lisnotrecursivelyenumerable.
Similarly,wecanalsoshowthathaltingproblemcanbesolvedwithL.
Hence,neitherLnorLisrecursivelyenumerable.
gatecse

GATE2003_52top
ConsidertwolanguagesL1 andL2 eachonthealphabet .Letf :
1
f (x) L 2 ] .Further,letf
bealsopolynomialtimecomputable.

beapolynomialtimecomputablebijectionsuchthat(x)[x

L1

iff

WhichofthefollowingCANNOTbetrue?

(A)L1 P andL2 isfinite


(B)L1

NP

andL2

(C)L1 isundecidableandL2 isdecidable


(D)L1 isrecursivelyenumerableandL2 isrecursive
Since,f isapolynomialtimecomputablebijectionandf isalsopolynomialtimecomputable,L1 andL2 shouldhavethesamecomplexity
(isomorphic).Thisisbecause,givenaproblemforL1 ,wecanalwaysdoapolynomialtimereductiontoL2 andviceverse.Hence,theansweris'C',asin
'A',L1 andL2 canbefinite,in'B',L1 andL2 canbeinP andin'D',L1 andL2 canberecursive.Only,in'C'thereisnointersectionforL1 andL2 ,and
henceitcantbetrue.
1

Alternatively,wecanprove'C'tobefalseasfollows:
GivenL2 isdecidable.Now,foraprobleminL1 ,wecanhaveaT M ,whichtakesaninputx,calculatesf (x) inpolynomialtime,checkf (x) isinL2
(thisisdecidableasL2 isdecidable),andifitis,thenoutputyesandotherwiseno.ThusL1 mustalsobedecidable.
gatecse

GATE1999_1.6top
LetL1bethesetofalllanguagesacceptedbyaPDAbyfinalstateandL2thesetofalllanguagesacceptedbyemptystack.Whichofthefollowingistrue?
A)L1=L2
B)L1L2
C)L1L2
D)None
TherearetwomodesofacceptanceofDPDAfinalstateandemptystack.Forlanguagesacceptedbyemptystackthereisaprefixproperty.Explaininsimple
termsaboutthispropertyanditsimportance.

Answertothequestionis(A)L1=L2.
ReasonisforanyPDAwhichacceptsbyfinalstatethereisanequivalentPDA(equivalentmeansthatacceptsthesamelanguage)whichacceptsbyempty
stackandviceverse.
Now,thisisnotthecaseforDPDAs.
ThesetoflanguagesacceptedbyaDPDAbyemptystackisastrictsubsetofthesetoflanguagesacceptedbyaDPDAbyfinalstate.
ItcanalsobesaidthatsetoflanguagesacceptedbyaDPDAbyemptystackisthesetoflanguagesacceptedbyaDPDAbyfinalstateandwhichhasthe
prefixproperty.
Alanguagehasprefixpropertymeansifw

,thennoprefixofw

FromtheabovedefinitionofprefixpropertyitmustbeclearwhyDPDAbyemptystackhasthisproperty.Ifanyprefixofawordw(winL)isinLmeans
thestackshouldhavebeenemptyevenbeforecompletelyprocessingw .But,beingadeterministicPDA,oncethestackbecomesempty,theDPDAaccepts
andhalts.So,innowaycanaDPDAacceptsw anditsprefix.
Goodread:http://www.cs.ucr.edu/~jiang/cs150/slides4week7_PDA+EquivToCFG.pdf
http://gateoverflow.in/book

154/400

2/26/2015

GATEOverflow Book

gatecse

GATE2008_10top
Whichofthefollowingaredecidable?
I. Whethertheintersectionoftworegularlanguagesisinfinite
II. Whetheragivencontextfreelanguageisregular
III. Whethertwopushdownautomataacceptthesamelanguage
IV. Whetheragivengrammariscontextfree

A.
B.
C.
D.

IandII
IandIV
IIandIII
IIandIV

(1)Intersectionoftworegularlanguagesisregular.Andcheckingifaregularlanguageisinfiniteisdecidable.
(2)Undecidable
(3)Undecidable
(4)DecidableaswejusthavetocheckifthegrammarobeystherulesofCFG.(Obviouslyundecidablehaditbeenlanguageinsteadofgrammar)
Reference:http://gatecse.in/wiki/Grammar:_Decidable_and_Undecidable_Problems
gatecse

GATE2008_13top
IfLandL'arerecursivelyenumerablethenLis
A.
B.
C.
D.

regular
contextfree
contextsensitive
recursive

(D)recursive

http://books.google.co.in/books?
id=hsxDiWvVdBcC&pg=PA283&lpg=PA283&dq=if+l+and+l+are+recursively+enumerable+then+l+is+recursive&source=bl&ots=rdEqRfUndV&sig=1dglP3QL44ceHpn
name

GATE2008_48top

(D)iscorrectanswer
name

GATE2008_51top

http://gateoverflow.in/book

155/400

2/26/2015

GATEOverflow Book

AnswerisC.
name

GATE2008_52top

CorrectAnsis(C)
Tracethegivenregularexpressionswiththediagrams
name

GATE1991_03,xiiitop

http://gateoverflow.in/book

156/400

2/26/2015

GATEOverflow Book

ansisAandC
toknowtheansletuscheckalltheoption..
a)L(S) L(R):stringgeneratedbySisanynumbersof1'sfollowedbyone0,i.e10,110,1110,1110,,,,.stringgeneratedbyRis1followedbyany
combinationof0or1,i.e1,10,11,1110,101,110......itshowsthatallthestringsthatcanbegeneratedbyS,canalsobegeneratedbyRitmeans
L(S) L(R)istrue.L(S) L(T):herestringgeneratedbyTis
anynumbersof1(here1*meanswehavestringsas ,1,11,111,....)followedbyonlyone0,i.e0,10,110,1110.......sowecanseethatallthestringsthatare
presentinScanalsobegeneratedbyT,henceL(S) L(T)itshowsthatoptionAistrue
b)L(R) L(S):itisfalsebecausestring1whichcanbegeneratedbyL(R),cannotbegeneratedbyL(S)
C)sameasoptionA
d)L(T) L(S):itisfalsebecausestring0whichcanbegeneratedbyT,cannotbegeneratedbyL(S).

nehapawar

GATE1991_03,xivtop
03.Choosethecorrectalternatives(morethanonemaybecorrect)andwritethecorrespondinglettersonly:

(b),(c)and(d)aretrue.Butthestrongestanswerwouldbe(d)aregularlanguage.Itistrivialtosaythatafinitesetofstrings(finitelanguage)canbe
acceptedusingafinitesetofstates.Andregularlanguage contextfree contextsensitive Turingrecognizable,wouldimplythatregularlanguageisthe
strongestanswer.
gatecse

GATE1992_02,xviitop
02.Choosethecorrectalternatives(morethanonemaybecorrect)andwritethecorrespondinglettersonly:
Whichofthefollowingregularexpressionidentitiesis/areTRUE?
(a)r(

) = r

(b)(r s )
(c)(r + s)
(d)r s

= (r + s)

= r

= r

+ s

+ s

(a)istheanswer
(b)RHSgenerates whileLHScan'tgeneratestringswherer comesafters likesr, srretc.LHS RHS.

http://gateoverflow.in/book

157/400

2/26/2015

GATEOverflow
Book
sr, srr

(c)LHSgenerates whileRHScan'tgeneratestringswherer comesafterans .RHS LHS.


(d)LHScontainsallstringswhereafterans ,nor comes.RHScontainsallstringsofeitherr ors butnocombinationofthem.So,RHS LHS.
name

GATE2000_1.4top
LetS andT belanguagesover
(a)S

(b)T

(c)S

= T

(d)S

T =

(c)S =
name

= {a. b}

representedbytheregularexpressions(a + b

and(a + b) ,respectively.Whichofthefollowingistrue?

.Bothgeneratesallstringsover .

GATE2000_1.5top
LetLdenotethelanguagesgeneratedbythegrammarS0S0|00.
WhichofthefollowingisTRUE?
A.
B.
C.
D.

L=0+
Lisregularbutnot0+
Liscontextfreebutnotregular
Lisnotcontextfree

B.istheanswerforthisquestion
LanguagegeneratedbythisgrammarisL=(00)^+thatisregularbutnot0^+
name

GATE2000_2.8top
WhatcanbesaidaboutaregularlanguageLover{a}whoseminimalfinitestateautomatonhastwostates?
1. Lmustbe{an|nisodd}
2. Lmustbe{an|niseven}
3. Lmustbe{an|n0}
4. EitherLmustbe{an|nisodd},orLmustbe{an|niseven}

Ans4)EitherLmustbe{an|nisodd},orLmustbe{an|niseven}
Becauseifwedrawtheminimaldfaforeachofthem,wewillgettwostateseach.
Whereas,{an|n>=0}requiresonlyonestate.
name

GATE2000_2.9top
Considerthefollowingdecisionproblems:
(P1)Doesagivenfinitestatemachineacceptagivenstring?
(P2)Doesagivencontextfreegrammargenerateaninfinitenumberofstrings?
Whichofthefollowingstatementsistrue?
A.
B.
C.
D.

Both(P1)and(P2)aredecidable
Neither(P1)nor(P2)isdecidable
Only(P1)isdecidable
Only(P2)isdecidable

http://gateoverflow.in/book

158/400

2/26/2015

GATEOverflow Book

ForP1,wejustneedtogivearunonthemachine.FinitestatemachinesalwayshaltsunlikeTM.
ForP2,checkiftheCFGgeneratesanystringoflengthbetweennand2n1.Ifso,L(CFG)isinfinite,elsefinite.
Hence,bothP1andP2aredecidable(A).
http://gatecse.in/wiki/Grammar:_Decidable_and_Undecidable_Problems
name

GATE2001_1.4top
Considerthefollowingtwostatements:
S 1 : {0

S 2 : {0

2n

n 1}

m+n

isaregularlanguage

m 1andn 1}

isaregularlanguage

Whichofthefollowingstatementiscorrect?
(A)OnlyS1iscorrect
(B)OnlyS2iscorrect
(C)BothS1andS2arecorrect
(D)NoneofS1andS2iscorrect
Onlys1iscorrectadfawith2stateswhereoneofthestatesisboththeinitialandfinalstate..
name

GATE2001_1.5top
Whichofthefollowingstatementsistrue?
(A)Ifalanguageiscontextfreeitcanalwaysbeacceptedbyadeterministicpushdownautomaton
(B)Theunionoftwocontextfreelanguagesiscontextfree
(C)Theintersectionoftwocontestfreelanguagesisacontextfree
(D)Thecomplementofacontextfreelanguageisacontextfree

Answeris(B)
(A)iswrongasalanguagecanbecontextfreeevenifitisbeingacceptedbynondeterministicPDAforex{WWr:W*(a,b)andWris
reverse}
(C)and(D)notalwaystrueasContextfreelanguagesarenotclosedunderComplementandIntersection.
name

GATE2001_2.7top
ConsiderthefollowingproblemX.
GivenaTuringmachineMovertheinputalphabet ,anystateqofMandawordw

,doesthecomputationofMonwvisitthestateofq?

WhichofthefollowingstatementsaboutXiscorrect?
A.
B.
C.
D.

Xisdecidable
Xisundecidablebutpartiallydecidable
Xisundecidableandnotevenpartiallydecidable
Xisnotadecisionproblem

Xisundecidablebutpartiallydecidable.
WehavetheTMM.JustmakethestateqthefinalstateandmakeallotherfinalstatesnonfinalandgetanewTMM'.GiveinputwtoM'.Ifwwouldhave
takenMtostateq(yescaseoftheproblem),ournewTMM'wouldacceptit.So,thegivenproblemispartiallydecidable.
IfMgoesforaninfiniteloopandneverreachesstateq(nocasefortheproblem),M'cannotoutputanything.Thisproblemisthestateentryproblem,which
likewordacceptingproblemandhaltingproblemisundecidable.
http://gateoverflow.in/book

159/400

2/26/2015

GATEOverflow Book

name

GATE2001_7top
LetadecisionproblemX bedefinedasfollows:
X

:GivenaTuringmachineM over andanywordw

,doesM loopforeveronw ?

YoumayassumethatthehaltingproblemofTuringmachineisundecidablebutpartiallydecidable.
(a)ShowthatX isundecidable
(b)ShowthatX isnotevenpartiallydecidable

ThequestionasksifMloopforeveronw.IfMloopforeveronw,Mwouldn'thaltonw.AndifMdoesn'thaltonw,Mshouldloopforever.So,thisproblem
is exactly same as asking if "M doesn't halt on w", which is the complement of halting problem and is not even partially decidable. So, X is not even
partiallydecidable.
name

GATE2002_2.14top
Whichofthefollowingistrue?

A.
B.
C.
D.

Thecomplementofarecursivelanguageisrecursive
Thecomplementofarecursivelyenumerablelanguageisrecursivelyenumerable
Thecomplementofarecursivelanguageiseitherrecursiveorrecursivelyenumerable
Thecomplementofacontextfreelanguageiscontextfree

Complementofrecursivelanguageisalwaysrecursive
name

GATE2003_13top
NobodyknowsyetifP=NP.ConsiderthelanguageLdefinedasfollows.

L = {

(0 + 1)

ifP = N P

otherwise

Whichofthefollowingstatementsistrue?
(A)Lisrecursive
(B)Lisrecursivelyenumerablebutnotrecursive
(C)Lisnotrecursivelyenumerable
(D)WhetherLisrecursivelyenumerableornotwillbeknownafterwefindoutifP
(A)Lisrecursive.IfP
name

= NP

= NP

,Lis whichisrecursive(infactregular).Ifnot,L

whichisagainrecursive.So,inbothcasesLisrecursive.

GATE2003_14top

Theregularexpression0 (10 ) denotesthesamesetas


(A)(1 0)

(B)0 + (0 + 10)
(C)(0 + 1)

10(0 + 1)

(D)Noneoftheabove

http://gateoverflow.in/book

160/400

2/26/2015

GATEOverflow Book

(A)istheanswer.Both(A)andthegivenexpressiongeneratesallstringsover .
(B)doesn'tgenerate11
(C)doesn'tgenerate11
name

GATE2003_53top
AsingletapeTuringMachineMhastwostatesq0andq1,ofwhichq0isthestartingstate.ThetapealphabetofMis{0,1,B}anditsinputalphabetis{0,1}.
ThesymbolBistheblanksymbolusedtoindicateendofaninputstring.ThetransitionfunctionofMisdescribedinthefollowingtable.

q0
q1

0
q1,1,R
q1,1,R

1
q1,1,R
q0,1,L

B
Halt
q0,B,L

Thetableisinterpretedasillustratedbelow.
Theentry(q1,1,R)inrowq0andcolumn1signifiesthatifMisinstateq0andreads1onthecurrentpagesquare,thenitwrites1onthesametapesquare,
movesitstapeheadonepositiontotherightandtransitionstostateq1.
WhichofthefollowingstatementsistrueaboutM?
A.
B.
C.
D.

Mdoesnothaltonanystringin(0 + 1)

Mdoesnothaltonanystringin(00 + 1)
Mhaltsonallstringsendingina0
Mhaltsonallstringsendingina1

optionA.orepsilonisonlyacceptedi.etapecontainBasthefirstcharacter
name

GATE2003_55top
ConsidertheNFAMshownbelow.

LetthelanguageacceptedbyMbeL.LetL1 bethelanguageacceptedbytheNFAM 1 obtainedbychangingtheacceptingstateofMtoanonacceptingstate


andbychangingthenonacceptingstatesofMtoacceptingstates.Whichofthefollowingstatementsistrue?
A.
B.
C.
D.

L 1 = {0, 1}
L 1 = {0, 1}

L1 L
L1 = L

http://gateoverflow.in/book

161/400

2/26/2015

GATEOverflow Book

L=(0+1)^+whileL1=(0+1)^*SoAnsisB
name

GATE2004_86top

Optioncandoptiondarecancelledoutclearlybecausewith31swecanreachthefinalstate...thereisanstringwherewecanreachthefinalstateby61's
now6isntoddbutitisdivisivbleby3henceoptionaiscorrect
name

findminimaldfaforLtop
n

L = {a b : n 0} {b a : n 1}

6statesarerequired.

gatecse

GATE2007_6top
Whichofthefollowingproblemsisundecidable?
A.
B.
C.
D.

MembershipproblemforCFGs
AmbiguityproblemforCFGs
FinitenessproblemforFSAs
EquivalenceproblemforFSAs

Membershipproblemisdecidableasitcanbesolvedbyparsers.
FinitenessproblemisdecidableforFSAs(alsoforCFGs),aswejustneedtocheckforaloopintheDFA.
EquivalenceproblemforFSAsisdecidableaswecantakethecomplementofoneFSA(complementofFSAisanotherFSA),anddoanintersectionwiththe
other(FSAsareclosedunderintersectionalso),givinganewFSA.IfthisnewFSAacceptnostring,thenthegivenFSAsareequivalent,elsenotequivalent.
OnlyambiguityproblemforCFGsareundecidable.
http://gatecse.in/wiki/Grammar:_Decidable_and_Undecidable_Problems
name
http://gateoverflow.in/book

162/400

2/26/2015

GATEOverflow Book

GATE2007_7top
WhichofthefollowingisTRUE?
A.
B.
C.
D.

Everysubsetofaregularsetisregular
Everyfinitesubsetofanonregularsetisregular
Theunionoftwononregularsetsisnotregular
Infiniteunionoffinitesetsisregular

(B)Everyfinitesubsetofanonregularsetisregular.
Anyfinitesetisalwaysregular.

beingregularanynonregularlanguageisasubsetofthis,andhence(A)isfalse.

IfwetakeaCFLwhichisnotregular,andtakesunionwithitscomplement(complementofaCFLwhichisnotregularwon'tberegularasregularisclosed

undercomplement),weget whichisregular.So,(C)isfalse.
Regularsetisnotclosedunderinfiniteunion.Example:
LetLi={0i1i},iN
Now,ifwetakeinfiniteunionoveralli,weget
L={0i1i|iN},whichisnotregular.
So,Disfalse.
name

GATE2007_30top

TheanswerisB.
name

GATE2007_31top

A.CFL
B.CFL
C.Regular,languageisstringstatingandendingwithsamesymbolandhavinglengthatleast3.e.g.0x0or1x1
D.CFL
http://gatecse.in/wiki/Identify_the_class_of_the_language
name

GATE2007_74,75top

http://gateoverflow.in/book

163/400

2/26/2015

GATEOverflow Book

Theanswerfor74isC.
Youcanseethatboththestates,Q1andQ2arefinalandareaccepting(a+b)*.
75itsB.
ThestateQ3isredundantasitisnotreachable.AndtheRegularexpressionb*a(a+b)*canbemadewithtwostates.
Q1>b>Q1
Q1>a>Q2
Q2>a>Q2
Q2>b>Q2.
Clearlythereare2states.
name

GATE2006_34top
ConsidertheregularlanguageL

= (111 + 11111)

.TheminimumnumberofstatesinanyDFAacceptingthislanguagesis:

(A)3
(B)5
(C)8
(D)9

therewillbe9states.with1st,4th,6th,7thand9thstatebeingthefinalstates.withaloopontheninthstate.
{0,3,5,6,8,9,10,11,12,........}thisisthesetwhichwillbeacceptedbythemindfaforthisexpression.

name

GATE2009_12top
S aS a bS b a b

Thelanguagegeneratedbytheabovegrammaroverthealphabet{a, b}isthesetof
(A)allpalindromes
(B)alloddlengthpalindromes
(C)stringsthatbeginandendwiththesamesymbol
(D)allevenlengthpalindromes
ansisB..stringgeneratedbythislanguageisa,b,aba,bab,aabaa,.....allthisstringsareoddlengthpalindromes
nehapawar

GATE2009_15top
http://gateoverflow.in/book

{0, 1}

(0 + 1) 0(0 + 1) 0(0 + 1)

164/400

2/26/2015

GATEOverflow Book

Whichoneofthefollowinglanguagesoverthealphabet{0, 1} isdescribedbytheregularexpression:(0 + 1)

0(0 + 1) 0(0 + 1)

(A)Thesetofallstringscontainingthesubstring00
(B)Thesetofallstringscontainingatmosttwo0 's
(C)Thesetofallstringscontainingatleasttwo0 's
(D)Thesetofallstringsthatbeginandendwitheither0 or1
(C)istheanswer.
Counterexampleforotherchoices:
(A)1010isacceptedwhichdoesn'tcontain00
(B)000isaccepted
(D)01isnotaccepted
name

GATE2009_16top

Optiondndpaismorepowerfulthandpdasotheyarenotequivalent..actuallydpdaisasubsetofndpa...
name

GATE2005_56top
LetL1bearecursivelanguage,andletL2bearecursivelyenumerablebutnotarecursivelanguage.WhichoneofthefollowingisTRUE?
A.
B.
C.
D.

L1'isrecursiveandL2'isrecursivelyenumerable
L1'isrecursiveandL2'isnotrecursivelyenumerable
L1'andL2'arerecursivelyenumerable
L1'isrecursivelyenumerableandL2'isrecursive

L1beingrecursive,wehaveaTMMforL1whichacceptsallwordsinL1andrejectsallwordsinL1'.So,thisTMalsoworksforL1'bychangingtheaccept
andrejectstates.ThusL1'isrecursive.
L2beingrecursivelyenumerablebutnotrecursivemeansTMforL2canacceptallwordsinL2butcannotrejectallwordsnotinL2=>TMforL2'cannot
exist(asotherwiseTMforL2couldsimulatethemovesofthatTMtorejectwordsinL2')=>L2'isnotrecursivelyenumerable.So,(B).
name

GATE2005_57top

B.http://gatecse.in/wiki/Identify_the_class_of_the_language
name

http://gateoverflow.in/book

165/400

2/26/2015

GATEOverflow Book

GATE2013_8top
ConsiderthelanguagesL1

andL2

= a

.WhichoneofthefollowingrepresentsL1 L2

L1

(A){}
(B)
(C)a
(D){, a}
L1.anythingisemptylanguageandemptyunionempty*isepsilonhencea
kireeti

GATE1999_1.5top

Cflarenotclosedunderintersectionandcomplementnowchoosethecorrectoptionsob)unionandklenneclosure
name

GATE2013_32top
Considerthefollowinglanguages.
p

L 1 = {0 1 0
L 2 = {0 1 0

p, q, r 0}

p, q, r 0, p r}

WhichoneofthefollowingstatementsisFALSE?
(A)L2 iscontextfree.
(B)L1 L2 iscontextfree.
(C)ComplementofL2 isrecursive.
(D)ComplementofL1 iscontextfreebutnotregular.

L1isregularandhencecontextfreealso.RegularexpressionforL1is0*1*0*.So,(D)isthefalsechoice.
L2iscontextfreebutnotregular.Weneedastacktocountifthenumberof0'sbeforeandafterthe1(1maybeabsentalso)arenotsame.(L2isbutnot
deterministiccontextfree)
So,L1L2iscontextfreeasregularcontextfreeiscontextfree.>(B)istrue.
ComplementofL2isrecursiveascontextfreecomplementisalwaysrecursive(actuallyevencontextsensitive).

name

GATE2013_41top
Whichofthefollowingis/areundecidable?
1. G isaCFG.IsL(G) = ?
2. G isaCFG.IsL(G) = ?
3. M isaTuringmachine.IsL(M ) regular?
4. A isaDFAandN isanNFA.IsL(A) = L(N ) ?
(A)3only(B)3and4only(C)1,2and3only(D)2and3only
ItwillbeD.
FirstisEmptinessforCFG.
SecondiseverythingforCFG.
ThirdisRegularityforREC
Fourthisequivalenceforregular.
http://gateoverflow.in/book

166/400

2/26/2015

GATEOverflow Book

name

GATE2012_24top
Whichofthefollowingproblemsaredecidable?
1. Doesagivenprogrameverproduceanoutput?

2. IfLisacontextfreelanguage,then,isL
alsocontextfree?

3. IfLisaregularlanguage,then,L isalsoregular?

4. IfLisarecursivelanguage,then,isL
alsorecursive?
(A)1,2,3,4
(B)1,2
(C)2,3,4
(D)3,4
CFLsarenotclosedundercomplementationandaprogramcanloopforever.So,itmaynotproduceanyoutput.
Regularandrecursivelanguagesareclosedundercomplementation.
Hence,only3,4aredecidable.
name

GATE2012_25top
GiventhelanguageL

= {ab, aa, baa}

,whichofthefollowingstringsareinL ?

1. abaabaaabaa
2. aaaabaaaa
3. baaaaabaaaab
4. baaaaabaa
(A)1,2and3
(B)2,3and4
(C)1,2and4
(D)1,3and4
Onlystrings1,2,4isinthelanguageL^*
name

GATE1998_1.9top
IftheregularsetA isrepresentedbyA
(a)A

(b)B

= (01 + 1)

andtheregularsetB isrepresentedbyB

= ((01) 1 )

,whichofthefollowingistrue?

(c)A andB areincomparable


(d)A

= B

(d)A =
name

.Bothgeneratesallstringsover{0, 1} wherea0isimmediatelyfollowedbya1.

GATE1998_1.11top

http://gateoverflow.in/book

167/400

2/26/2015

GATEOverflow Book

AnsB
name

GATE1998_1.12top
Thestring1101doesnotbelongtothesetrepresentedby
(a)110*(0+1)
(b)1(0+1)*101
(c)(10)*(01)*(00+11)*
(d)(00+(11)*0)*
Only(a)and(b)cangenerate1101.
In(c)after11,wecannothave01andso1101cannotbegenerated.
In(d)wecangenerate110and11011butnot1101.
name

GATE1998_2.6top
Whichofthefollowingstatementsisfalse?
(a)Everyfinitesubsetofanonregularsetisregular
(b)Everysubsetofaregularsetisregular
(c)Everyfinitesubsetofaregularsetisregular
(d)Theintersectionoftworegularsetsisregular
(b)isFalse.Anylanguageisasubsetof whichisaregularset.So,ifwetakeanynonregularlanguage,itisasubsetofaregularlanguage.

(a)and(c)areregularasanyfinitelanguageisregular.
(d)isregularasregularsetisclosedunderintersection.
name

GATE20141_16top
Considerthefiniteautomatoninthefollowingfigure:

Whatisthesetofreachablestatesfortheinputstring0011?
(A){q 0 , q 1 , q 2 }
(B){q 0 , q 1 }
(C){q 0 , q 1 , q 2 , q 3 }
(D){q 3 }

qo,q1,q2canbereachedinthisnfabyenumeratingallthepossibilities
name

GATE20141_35top

LetLbealanguageandL
beitscomplement.WhichoneofthefollowingisNOTaviablepossibility?

http://gateoverflow.in/book

168/400

2/26/2015

GATEOverflow Book

(A)

NeitherLnorL
isrecursivelyenumerable(r. e. ) .

(B)OneofLandL
isr.e.butnotrecursivetheotherisnotr.e.

(C)BothLandL
arer.e.butnotrecursive.

(D)BothLandL
arerecursive.

(C)isnotpossible.IfLisrewehaveaTMthatacceptsstringinL.IfL'isre,wehaveaTMthatacceptsstringsinL'.So,usingboththeseTMswecanmake
anewTMMwhichacceptsstringsinLandrejectsstringsinL'thatisMdecidesL,makingLrecursive.
name

GATE20141_36top
WhichoftheregularexpressionsgivenbelowrepresentthefollowingDFA?

I. 0 1(1 + 00 1)
II. 0 1 1 + 11 0 1

III. (0 + 1) 1

(A)IandIIonly
(B)IandIIIonly
(C)IIandIIIonly
(D)I,IIandIII

(B)istheanswer.(II)doesn'tgenerate11011whichisacceptedbythegivenDFA
name

GATE20142_15top
IfL1

= {a

n 0}

andL2

= {b

n 0}

,consider

(I)L1 . L2 isaregularlanguage
(II)L1 . L2

= {a b

n 0}

WhichoneofthefollowingisCORRECT?
(A)Only(I)
(B)Only(II)
(C)Both(I)and(II)
(D)Neither(I)nor(II)

OptionA
L1={,a,aa,aaa,aaaa,........................}
L2={,b,bb,bbb,bbbb,........................}
L1.L2={,a,b,ab,abb,abbb,abbbb,..........,aab,aabb,aabbb,................}=a*b*Thisisregularlanguageandnotequaltoanbn

http://gateoverflow.in/book

169/400

2/26/2015

GATEOverflow Book

name

GATE20142_16top
LetA

B denotesthatlanguageAismappingreducible(alsoknownasmanytoonereducible)tolanguageB.WhichoneofthefollowingisFALSE?

(A)IfA

m B andBisrecursivethenAisrecursive.

(B)IfA

m B andAisundecidablethenBisundecidable.

(C)IfA

m B andBisrecursivelyenumerablethenAisrecursivelyenumerable.

(D)IfA

m B andBisnotrecursivelyenumerablethenAisnotrecursivelyenumerable.

AmBmeansAcannotbeharderthanB.(SinceAcanbereducedtoB,insteadofdecidingA,wecannowdecideB)
So,thefirst3optionsarecorrect.Option(D)isfalse,asBisnotrecursivelyenumerabledoesn'tguaranteeAisnotrecursivelyenumerable.
name

GATE20142_35top
Let<

M >

betheencodingofaTuringmachineasastringover

= {0, 1}

.Let

L = {< M > M is a Turing machine that accepts a string of length 2014}

.ThenLis
(A)decidableandrecursivelyenumerable
(B)undecidablebutrecursivelyenumerable
(C)undecidableandnotrecursivelyenumerable
(D)decidablebutnotrecursivelyenumerable

Thereareonlyafinitenumberofstringsoflength2014.So,wecangiveallthosestringstoTMsimulatingeachstringfor1step,then2stepandsoon
(dovetailing),andiftheTMacceptsanyofthem("yes"caseofTM),wecansay"yes".So,Lisrecursivelyenumerable.
(IftheTMdoesn'tacceptanystringoflength2014,itcangotoaninfiniteloop("no"caseofTM),andhencewecan'tsaythemethodisdecidable).
Now,toprovewhethertheproblemisdecidableornotwecanmakeuseofRice'stheorem.Rice'stheorem(I)statesthatanynontrivialpropertyofL(TM)is
undecidable.L(TM)hasastringoflength2014isanontrivialpropertyasthereareTMswhoselanguagecontainssuchastringandthereareTMswhose
languagedoesn'thavesuchastring.So,thegivenproblemisundecidable.
http://gatecse.in/wiki/Rice%27s_Theorem_with_Examples
name

GATE20142_36top
LetL1

= {w {0, 1}

whas at least as many occurrences of(110) s as(011) s} .Let

L 2 = {w {0, 1} whas at least as many occurrences of(000) s as(111) s} .WhichoneofthefollowingisTRUE?

(A)L1 isregularbutnotL2
(B)L2 isregularbutnotL1
(C)BothL1 andL2 areregular
(D)NeitherL1 norL2 areregular

(A)isTrue.ThoughatfirstlookbothL1andL2looksnonregular,L1isinfactregular.Thereasonistherelationbetween110and011.
Wecannothavetwo110'sinastringwithouta011orviceverse.Andthiswouldmeanthatweonlyneedafinitenumberofstatestocheckforacceptanceof
anywordinthislanguage.
Thatwasjustanintuitiveexplanation.NowIsaythatLcontainsallbinarystringsstartingwith11.Yes,ifabinarystringstartswith11,itcanneverhave
moreno.of011than110.
Letstakeanexample:
http://gateoverflow.in/book

170/400

2/26/2015

GATEOverflow Book

11011011Therearetwo011's.Buttherearealsotwo110's.Similarlyforanybinarystringstartingwith11.
Usingthisproperty,DFAforL1canbeconstructedasfollows:

gatecse

GATE20143_15top
ThelengthoftheshorteststringNOTinthelanguage(over

= {a, b})

ofthefollowingregularexpressionis_______.

a b (ba) a

theshortestlengthis3.
answer:"bab"
name

GATE20143_35top
Whichoneofthefollowingproblemsisundecidable?

(A)Decidingifagivencontextfreegrammarisambiguous.
(B)Decidingifagivenstringisgeneratedbyagivencontextfreegrammar.
(C)Decidingifthelanguagegeneratedbyagivencontextfreegrammarisempty.
(D)Decidingifthelanguagegeneratedbyagivencontextfreegrammarisfinite.

(A)istheanswer.Proving(A)isundecidableisnotsoeasy.Butwecaneasilyprovetheotherthreeoptionsgivenherearedecidable.
http://gatecse.in/wiki/Grammar:_Decidable_and_Undecidable_Problems
name

GATE20143_36top
Considerthefollowinglanguagesoverthealphabet
L 1 = {0

L 2 = {wcw

L 3 = {ww

= {0, 1, c}

n 0}

w {0, 1} }

w {0, 1} }

Here,w r isthereverseofthestringw .WhichoftheselanguagesaredeterministicContextfreelanguages?


(A)Noneofthelanguages
(B)OnlyL1
(C)OnlyL1 andL2
(D)Allthethreelanguages

C.
L3isCFLandnotDCFLasinnowaywecandeterministicallydeterminetheMIDDLEpointoftheinputstring.
name

http://gateoverflow.in/book

171/400

2/26/2015

GATEOverflow Book

GATE2011_8top
WhichofthefollowingpairshaveDIFFERENTexpressivepower?
(A)Deterministicfiniteautomata(DFA)andNondeterministicfiniteautomata(NFA)
(B)Deterministicpushdownautomata(DPDA)andNondeterministicpushdownautomata(NPDA)
(C)DeterministicsingletapeTuringmachineandNondeterministicsingletapeTuringmachine
(D)SingletapeTuringmachineandmultitapeTuringmachine

(B)Deterministicpushdownautomata(DPDA)andNondeterministicpushdownautomata(NPDA)

Inrestoftheoptionsbothmachineareequivalentinpower.
name

GATE2011_26top
ConsiderthelanguagesL1,
p

L1 = {0 1
L2 = {0 1

L2 and L3

asgivenbelow.

p, q N },
p, q N and p = q} and

L3 = {0 1 0

p, q, r N and p = q = r}.

WhichofthefollowingstatementsisNOTTRUE?
(A)PushDownAutomata(PDA)canbeusedtorecognizeL1 andL2
(B)L1 isaregularlanguage
(C)Allthethreelanguagesarecontextfree
(D)Turingmachinescanbeusedtorecognizeallthelanguages

AnswerisC.

name

GATE2011_42top
DefinitionofalanguageLwithalphabet{a} isgivenasfollowing.
L = {a

nk

k > 0,

and nis a positive integer constant}

WhatistheminimumnumberofstatesneededinaDFAtorecognizeL?
(A)k + 1
(B)n + 1
(C)2 n+1
(D)2 k+1

(A)n+1
Weneedastateforstringsoflength0,1,2,...n(andtheirrespectivemultipleswithk).EachofthesesetofstringsformanequivalenceclassasperMyhill
NerodetheoremandhenceneedsaseparatestateinminDFA.
name

GATE2010_17top
LetL1 betherecursivelanguage.LetL2 andL3 belanguagesthatarerecursivelyenumerablebutnotrecursive.Whichofthefollowingstatementsisnot
necessarilytrue?
(A)L2

L 1 is recursively enumerable.

L 1 L 3 is recursively enumerable.

http://gateoverflow.in/book

172/400

2/26/2015

GATEOverflow Book

(B)L1

L 3 is recursively enumerable.

(C)L2

L 3 is recursively enumerable.

(D)L2

L 3 is recursively enumerable.

Recursivelyenumerablelanguagesareclosedunderunionandintersection.So,letsconsidereachoption
(A)L2 L1 = L2 L1
Recursivelanguagesareclosedundercomplement,andsoL1 isrecursiveandhencerecursivelyenumerablealso.So,L2
alwaysTRUE.
(B)L1

L1

isrecursivelyenumerableis

L3 = L1 L3

Recursivelyenumerablelanguagesarenotclosedundercomplement.So,L3 mayormaynotberecursivelyenumerableandhencewecan'tsayanythingif

L 1 L 3 isrecursivelyenumerableornot.
(C)Intersectionoftworecursivelyenumerablelanguagesisalwaysrecursivelyenumerable(REclosedunderintersection).
(D)Unionoftworecursivelyenumerablelanguagesisalwaysrecursivelyenumerable(REclosedunderunion).
Forverifyingclosureproperties:
http://gatecse.in/wiki/Closure_Property_of_Language_Families
name

GATE1997_6.4top
Whichoneofthefollowingregularexpressionsover{0, 1} denotesthesetofallstringsnotcontaining100 assubstring?
(a)0 (1 + 0)

(b)0 1010
(c)0 1 01
(d)0 (10 + 1)

"Aregularexpressiondenotingalanguage(setofstrings)meansitshouldgenerateallstringinLandnotgenerateanystringnotinL"
(a)generates100
(b)doesn'tgenerate0(starttryingstringsinlexicographicorder0,1,00,01,10,...)
(c)doesn'tgenerate1
(d)istheanswer
name

GATE1997_6.5top

EquivalenceoftwoTMsisundecidable
name

GATE1997_21top
GiventhatLisalanguageacceptedbyafinitestatemachine,showthatLP andLR arealsoacceptedbysomefinitestatemachines,where
L

= {s ss

Lsome strings }

= {s sobtained by reversing some string inL}

SupposewehaveafiniteautomationforL,thenwecanbuildafiniteautomationforLP bymarkingallthestatesfromwhichfinalstateisreachableasthe
http://gateoverflow.in/book

173/400

2/26/2015

GATEOverflow Book

finalstatesfornewautomaton,thereasoningisthatsupposewecanreachfinalstatefformsomestateq,thenthatmeansthereexistssomestrings'thattakes
automationfromqtof,soifthereissomestringsthattakesautomationtostateqfromstartstatethisstringshouldbelongtothenewlanguageLP .
Also,wecanobtainanautomationforL byswappingthestartandfinalstatesoforiginalautomationL
name
R

GATE1993_27top
Drawthestatetransitionofadeterministicfinitestateautomatonwhichacceptsallstringsfromthealphabet{a, b},suchthatnostringhas3consecutive
occurrencesoftheletterb.

yeahihavedonemistake..sorryforthat..ifwemaketransitionfor'a'onstateq1andq2tostateq0thenithinkitwillbecorrectdfa
nehapawar

GATE2010_39top
LetL = {w (0 + 1)
belowrepresentsL?
(A)(0 10 1)
(B)0

(C)0

whas even number of1s} .i.e.,L isthesetofallthebitstringswithevennumbersof1 s.Whichoneoftheregularexpressions

(10 10 )

(10 1) 0

(D)0 1(10 1)

10

(A)Ifthestringcontainsa1,itmustendina1hencecannotgenerateallbitstringswithevennumberof1's(eg,1010)
(B)istheanswer
(C)betweenthesecondandthird1'sa0isnotallowed(eg,011011)
(D)00isnotallowed,zeroisanevennumber.
name

GATE2010_40top
Considerthelanguages
i

L1 = {0 1 i j},

L2 = {0 1

L3 = {0 1

L4 = {0 1

i = j},

i = 2j + 1},

i 2j}

(A)OnlyL2iscontextfree.
(B)OnlyL2andL3arecontextfree.
(C)OnlyL1andL2arecontextfree.
(D)Allarecontextfree

Allarecontextfree.
L1>Push0onstackandwhen1comes,startpopping.Ifstackbecomesemptyand1'sareremainingstartpushing1.Atendofstringacceptifstackisnon
empty.
L2>DothesameasforL1,butacceptifstackisemptyatendofstring.
L3>Do,thesameasforL2,butforeach0,pushtwo0'sonstackandstartthestackwitha0.
L4>DothesameasforL1,butforeach0,pushtwo0'sonstack
name

GATE2010_41top
http://gateoverflow.in/book

{0, 1}

174/400

2/26/2015

GATEOverflow Book

Letw betheanystringoflengthn in{0, 1} .LetLbethesetofallsubstringsofw .Whatistheminimumnumberofstatesinnondeterministicfiniteautomation


thatacceptsL?
(A)n 1
(B)n
(C)n + 1
(D)2 n1

Weneedastateforcountingthelength.So,forlengthnweneednstates.Now,wealsoneedarejectstateforlargerstrings.So,totallyn+1statesare
required.
name

Toctheoremprooftop
How

= {} ,whichisemptyset.Nowbydefinitionof*,itrepeatsthecontentofasetZEROormoretimes.Andanythingrepeatedzerotimeis .Andnothing
repeated1ormoretimesisnothing.

So, generatesthelanguage{} whoseregularexpressionis .Hence,

Itcanbealsoshownas:

a generates{, a, aa, aaa, . . . . }

generates{}

name

GATE1994_1.16top

ThiswillbeC.BecauseifthatwouldhavebeenpossiblethenNPDAandDPDAmusthadsamepowers,whichisnotthecase.YoucantakeexampleofNFA
andDFA.Bothareconvertibletoeachotherandhencesharethesamepower.
name

GATE1994_2.10top

L={0*1*}
name

GATE1994_19top
(a)Givenaset
S = {x there is an x-block of 5's in the decimal expansion of}

(Note:xblockisamaximalblockofxsuccessive5's)

http://gateoverflow.in/book

175/400

2/26/2015

GATEOverflow Book

WhichofthefollowingstatementsistruewithrespecttoS?Noreasontobegivenfortheanswer.
i. S isregular
ii. S isrecursivelyenumerable
iii. S isnotrecursivelyenumerable
iv. S isrecursive
(b)GiventhatalanguageL1 isregularandandthatthelanguageL1

L2

isregular,isthelanguageL2 alwaysregular?Proveyouranswer.

(a)Sisregular.Itmightnotbepossibletofindwhatisx,butonceitisfound,itwillbeanintegerandhencecanberepresentedusinganautomaton.For
findingtheclassofalanguage,weneedn'tconsiderthedifficultyingettingthelanguagecontents(stringsoflanguage).Weonlyneedtocountthedifficulty
inrecognizingthestringsoflanguage.
(b)No.neednotbe.TakeL2={anbn|n>0}andL1=allstringsover{a,b}.Now,L1UL2isL1onlyandisregularbutL2isnotregular.
name

GATE1995_1.9top
Insomeprogramminglanguage,anidentifierispermittedtobealetterfollowedbyanynumberoflettersordigits.IfLandD denotethesetsoflettersand
digitsrespectively,whichofthefollowingexpressionsdefinesanidentifier?
(a)(L D)

(b)L(L D)
(c)(LD)

(d)L(LD)

ItisB.
Ithastobestartedbyaletterfollowedbyanynumberoflettersanddigits.
name

GATE1995_2.20top

A.
Intheothertwoyoucanhaveanynumberofxandy.Thereisnosuchrestrictionoverthenumberofbothbeingequal.
name

GATE1995_2.23top

Acc.tomeitshouldbeB)
http://gateoverflow.in/book

176/400

2/26/2015

GATEOverflow Book

name

GATE1995_2.24top
Let

= {0, 1}, L =

andR

= {0

n > 0}

thenthelanguagesL R andR arerespectively

(A)regular,regular
(B)notregular,regular
(C)regular,notregular
(D)notregular,notregular
Answeris(C).L R isnothingbutLasR isasubsetofLandhenceregular.R isdeterministiccontextfreebutnotregularaswerequireastacktokeep
thecountof0'stomatchthatof1's.
name

GATE1996_1.8top

C.
youcanhaveanyno.of0'saswellasnull.
Aisfalsebecauseyoucannothavesingle0inii).sameforoptionB.InDyouareforcedtohavesingle0iniv)whereasnotiniii).
name

GATE1996_1.9top

D..
equivalenceofRegularlanguagesisdecidable.
1.Membership,
2.Emptiness,
3.Finiteness,
4.Equivalence,
5.Ambiguity,
6.Regularity,
7.Everything,
8.Disjointedness...
AllaredecidableforRegularlanguages.
First3forCFL.
Only1stforCSLandREC.
NoneforRE.
http://gateoverflow.in/book

177/400

2/26/2015

GATEOverflow Book

name

GATE1996_1.10top
LetL

where

= {a, b}

.Whichofthefollowingistrue?

(a)L

= {x xhas an equal number ofa's andb's}

(b)L

= {a b

(c)L

= {x xhas more number ofa's thanb's}

(d)L

= {a

n 1}

isregular

isregular

m 1, n 1}

isregular

isregular

OnlyD.becausenandmareindependentandthusnomemoryelementrequired.
aandbaresameandareDCFL's.
cisL={anbm|n>m}.whichisnotregular.
Correction:Ithinkcshouldbethatxhasmorea'sthanb's.
name

GATE1996_2.8top

B.
CFL'sarenotclosedunderintersection.
name

GATE1996_13top
LetQ = ({q 1 , q 2 }, {a, b}, {a, b, }, , , )beapushdownautomatonacceptingbyemptystackforthelanguagewhichisthesetofallnonemptyeven
palindromesovertheset{a, b}.Belowisanincompletespecificationofthetransitions .Completethespecification.Thetopofthestackisassumedtobeat
therightendofthestringrepresentingstackcontents.
1. (q 1 , a, ) = {(q 1 , a)}
2. (q 1 , b, ) = {(q 1 , b)}
3. (q 1 , a, a) = {(q 1 , aa)}
4. (q 1 , b, a) = {(q 1 , ab)}
5. (q 1 , a, b) = {(q 1 , ba)}
6. (q 1 , b, b) = {(q 1 , bb)}
7. (q 1 , a, a) = {( , )}
8. (q 1 , b, b) = {( , )}
9. (q 2 , a, a) = {(q 2 , )}
10. (q 2 , b, b) = {(q 2 , )}
11. (q 2 , , ) = {(q 2 , )}

(q 1 , a, b) = {(q 2 , ba)}

meansfromstateq 1 oninputa withstacktopbeingb ,thePDAmovestostateq 2 andpushesa ontopofstack.

So,herethemissingtransitionsareatthemiddleoftheinputstring:
(q 1 , a, a) = {(q 2 , )}
(q 1 , b, b) = {(q 2 , )}

Oncemiddleisreached,nowweshouldstartpopping.Andso,wemustgotostateq 2 aswellaspopthepreviouscharacteronthestack.(Thecharacter
beforeandafterthemiddlemustbesameasthestringisevenlengthpalindrome)
(ThisisanondeterministicPDA)
name

http://gateoverflow.in/book

178/400

2/26/2015

GATEOverflow Book

GATE1998_3btop
Givearegularexpressionforthesetofbinarystringswhereevery0isimmediatelyfollowedbyexactlyk 1's(k isafixedinteger)

ialsothinkthattheexpressionwillbeintheform1*(01k)*
nehapawar

Regularornot?top
{wxw|wbelongsto{0,1}*,xbelongsto{0,1}+}

LetsseethestringsinL
={0,1,00,01,10,11,000,.....}(Whenwis,wxwgeneratesallthesestringsandhencewedon'tneedtoconsideranyothercaseforw)
=*{}
Hence,regular.
Moreexamples:http://gatecse.in/wiki/Identify_the_class_of_the_language
name

GATE2008IT_5top
Whichofthefollowingregularexpressionsdescribesthelanguageover{0,1}consistingofstringsthatcontainexactlytwo1's?

A)
B)
C)
D)

(0+1)*11(0+1)*
0*110*
0*10*10*
(0+1)*1(0+1)*1(0+1)*
A)withatleast2consecutive1's,anynoof0'sandanynoof1's
B)exactlytwoconsecutive1's
C)exactlytwo1'sbutneednotbeconsecutive
D)anynoof1'sand0'swithatleasttwo1's
HenceC)isthecorrectoption.
name

GATE2008IT_35top
Whichofthefollowinglanguagesis(are)nonregular?
L1={0m1n|0mn10000}
L2={w|wreadsthesameforwardandbackward}
L3={w{0,1}*|wcontainsanevennumberof0'sandanevennumberof1's}

A)

L2andL3only

B)

L1andL2only

C)

L3only

D)

L2only

L1isregular..since10000isfinite..sofinitestatesarerequired..
L3isalsoregular..wecanmakeDFAforL3..stateswillrepresentmod2for0andmod2for1,whichisfinite
L2isnon.regular..itisCFGS>aSa|...|zSz|epsilon|[az]

sooption(d)
name

GATE2008IT_36top
http://gateoverflow.in/book

179/400

2/26/2015

GATEOverflow Book

Considerthefollowingtwofiniteautomata.M1acceptsL1andM2acceptsL2.
WhichoneofthefollowingisTRUE?

A)

L1=L2

B)

L1L2

C)

L1L2'=

D)

L1L2L1
L1:0*(1+0*)*11(0+1)*L2:(0+1)*11(0+1)*itisquiteclearthatL1=L2..So,option(A)
name

Gate2011_24top
LetP bearegularlanguageandQ beacontextfreelanguagesuchthatQ P .(Forexample,letP bethelanguagerepresentedbytheregularexpressionp
n
n
andQ be{p q n N }) .ThenwhichofthefollowingisALWAYSregular?
(A)P

(B)P

(C)

(D)

P
Q

c)complementofregularLanguageisregular
name

GATE2006IT_29top
Considertheregulargrammarbelow
SbS|aA|
AaS|bA
TheMyhillNerodeequivalenceclassesforthelanguagegeneratedbythegrammarare

A) {w(a+b)*|#a(w)iseven)and{w(a+b)*|#a(w)isodd}
B) {w(a+b)*|#a(w)iseven)and{w(a+b)*|#b(w)isodd}
C) {w(a+b)*|#a(w)=#b(w)and{w(a+b)*|#a(w)#b(w)}
D) {},{wa|w(a+b)*and{wb|w(a+b)*}

OptionAiscorrect.
Thegivengrammargeneratesallstringoverthealphabet

whichhaveanevennumberof 's.

ThegivenrightlineargrammarcanbeconvertedtothefollowingDFA.

http://gateoverflow.in/book

180/400

2/26/2015

GATEOverflow Book

name

GATE2006IT_30top
WhichofthefollowingstatementsaboutregularlanguagesisNOTtrue?

A)
B)
C)
D)

Everylanguagehasaregularsuperset
Everylanguagehasaregularsubset
Everysubsetofaregularlanguageisregular
Everysubsetofafinitelanguageisregular

OptionCisnotTrue.
A)Everylanguagehasaregularsuperset:True.

issuchasuperset.

B)Everylanguagehasaregularsubset:True. issuchasubset.
C)Everysubsetofaregularlanguageisregular:False.

,but

isnotRegular.

D)Everysubsetofafinitelanguageisregular:True.Everysubsetofafinitesetmustbefinitebydefinition.Everyfinitesetisregular.Hence,every
subsetofafinitelanguageisregular.
name

GATE2006IT_37top
ForastatemachinewiththefollowingstatediagramtheexpressionforthenextstateS+intermsofthecurrentstateSandtheinputvariablesxandyis

A)

S+=S'.y'+S.x

B)

S+=S.x.y'+S'.y.x'

C)

S+=x.y'

D)

S+=S'.y+S.x'

Answeris(A)
ForSis1onlywhen:Either(S=1andx=1)OR(s=0andy=0)
ThereforS(next)=S'y'+Sx

name

http://gateoverflow.in/book

181/400

2/26/2015

GATEOverflow Book

GATE2004IT_9top
WhichoneofthefollowingstatementsisFALSE?

A)
B)
C)
D)

Thereexistcontextfreelanguagessuchthatallthecontextfreegrammarsgeneratingthemareambiguous
Anunambiguouscontextfreegrammaralwayshasauniqueparsetreeforeachstringofthelanguagegeneratedbyit
Bothdeterministicandnondeterministicpushdownautomataalwaysacceptthesamesetoflanguages
Afinitesetofstringfromsomealphabetisalwaysaregularlanguage
A)thisistrueforinherentlyambiguouslanguage
B)alwayscorrect,that'swhycalledunambiguous
C)NPDAisasuppersetofDPDA,henceit'sFALSE
D)finitelanguageisalwaysregular
name

GATE2004IT_41top
LetM=(K,,,s,F)beafinitestateautomaton,where
K={A,B},={a,b},s=A,F={B},
(A,a)=A,(A,b)=B,(B,a)=Band(B,b)=A
AgrammartogeneratethelanguageacceptedbyMcanbespecifiedasG=(V,,R,S),whereV=KU,andS=A.
WhichoneofthefollowingsetofruleswillmakeL(G)=L(M)?

A)
B)
C)
D)

{AaB,AbA,BbA,BaA,B)
{AaA,AbB,BaB,BbA,B)
{AbB,AaB,BaA,BbA,B)
{AaA,AbA,BaB,BbA,A)
itsb)
name

GATE2005IT_4top
LetLbearegularlanguageandMbeacontextfreelanguage,bothoverthealphabet.LetLcandMcdenotethecomplementsofLandMrespectively.Which
ofthefollowingstatementsaboutthelanguageLcMcisTRUE?

A)
Itisnecessarilyregularbutnotnecessarilycontextfree.
B)
Itisnecessarilycontextfree.
C)
Itisnecessarilynonregular.
D)
Noneoftheabove

TakeL=*thenLc=andMc=Mc.
WeknowthatcomplementofCFLneednotbeaCFLasCFLisnotclosedundercomplement.
So,(A)and(B)arefalse.
IfwetakeL=thenLc=*andMc*=*whichisregular(C)isalsofalse.
So,answer(D)
name

GATE2005IT_5top
WhichofthefollowingstatementsisTRUEabouttheregularexpression01*0?

A)
B)
C)
D)

Itrepresentsafinitesetoffinitestrings.
Itrepresentsaninfinitesetoffinitestrings.
Itrepresentsafinitesetofinfinitestrings.
Itrepresentsaninfinitesetofinfinitestrings.

http://gateoverflow.in/book

182/400

2/26/2015

GATEOverflow Book

(B).Infiniteset(becauseof*)offinitestrings.AregularexpressioncannotgenerateanyinfinitestringAFAIK.
name

GATE2005IT_6top
Thelanguage{0n1n2n|1n106}is

A)
B)
C)
D)

regular
contextfreebutnotregular.
contextfreebutitscomplementisnotcontextfree.
notcontextfree.
Regular(infactfinite).Sincenisfinite,wehaveafinitesetofstringssatisfyingthegivenconditions.So,wecaneasilymakeafiniteautomataforthose
strings.
name

GATE2005IT_37top
Considerthenondeterministicfiniteautomaton(NFA)showninthefigure.

State X is the starting state of the automaton. Let the language accepted by the NFA with Y as the only accepting state be L1. Similarly, let the language
acceptedbytheNFAwithZastheonlyacceptingstatebeL2.WhichofthefollowingstatementsaboutL1andL2isTRUE?

A)
B)
C)
D)

L1=L2
L1L2
L2L1
Noneoftheabove
InQs.Z>Y(0edge)
L1canhave00stringwhileL2can't.L2canhave01whileL1can't
Sowecanconcludeneithertheyaresamesetnotpropersubsetofeachother.
HenceAns.D.
name

GATE2005IT_39top
Considertheregulargrammar:
SXa|Ya
XZa
ZSa|
YWa
WSa
whereSisthestartingsymbol,thesetofterminalsis{a}andthesetofnonterminalsis{S,W,X,Y,Z}.
Wewishtoconstructadeterministicfiniteautomaton(DFA)torecognizethesamelanguage.WhatistheminimumnumberofstatesrequiredfortheDFA?

A)
B)
C)
D)

http://gateoverflow.in/book

2
3
4
5

183/400

2/26/2015

GATEOverflow Book

(D)3
Thestringgeneratedbythelanguageisthesetofstringswitha 'ssuchthatnumberofa mod3is2.
Sothenumberofstatesrequiredshouldbe3tomaintainthecountofnumberofa 'smod3.
name

GiventhatalanguageLA=L1UL2,top
GiventhatalanguageLA = L1
statementsisnecessarilyTRUE?
A.
B.
C.
D.

L 2

,whereL1 andL2 aretwootherlanguages.IfLA isknowntobearegularlanguage,thenwhichofthefollowing

IfL1 isregularthenL2 willalsoberegular


IfL1 isregularandfinitethenL2 willberegular
IfL1 isregularandfinitethenL2 willalsoberegularandfinite
Noneofthese

(b)istheanswerbecausewecannotmakeanirregularsetSregular,byaddingafinitenumberofelementstoit.Thiscanbeprovedasfollows:
LetRF=Tberegular,whereFisafiniteset.WeremoveallelementsfromFwhichareinRandletthenewsetbeE.Still,
RE=T.andEisafiniteset(butnostringscommonbetweenEandR)
Now,TbeingregularmeanswehaveaDFAforT.WecanfindallthestatesinthisDFAwhereeachofthestringsinFisbeingaccepted.Ineachofthese
acceptingstate,noneofthestringinRwillbeacceptedasRandEdoesnthaveanystringincommon.So,ifwemakeallthesestatesnonaccepting,whatwe
getisDFAforR.MeaningRisregular.
Wecanprove(a)falsebetakingL1

(c)canbeprovedfalsebytakingL1

= {a}

andL2

= {a b

andL2

= {a

n > 0}

n > 0}

.Now,unionoftheseis whichisregularbutL2 isnotregular.

.NowL1

L2

isregularandL1 finitebutL2 isnotfinite.

name

HowtodrawNPDAforlanguageL={a^ib^jc^m|m>=min(i,j)}top
L1={a^ib^jc^m|mmin(i,j)}
L2={a^ib^jc^m|mmax(i,j)}
WhichlanguageisCFL?
ANS:L1isCFLbutL2isNOT.
Myunderstanding:
ForLanguageL1:
(HereIaminterestedincheckingWhetherlanguageisDCFLornot,also.)
CheckingDCFLornot:
Bylookingatlanguage,itisnotpossibletoconstructPDAasitcontains2conditions(i>jori<jAndmmin(i,j))
ButthereisawayofcheckinglanguageisDCFLornot.(ByPrefixProperty)
NoProperPrefixPrefixpropertyDCFL
ButthereisNoProperPrefixgettingforthislanguage,So,Prefixproperty,andsoL1isDCFL(butthereisnoDPDAforL1aspermy1stconclusion(i.e.2
conditions>NoPDA)
ItmeanssomewhereIamwrong.Pleasecorrectme.
CheckingCFLornot:
WewillhavetocheckwhetheritisacceptedbyNPDAornot.
IdontknowcorrectwaytoconstructNPDAbutItriedinfollowingway.
1)AtsomepointPDAwillassumethati<jori>j
condition1st:i<j
Weareinterestedinmin,soconsideronlyi,meansaccept"a"andskipall"b"andforeach"c",popeach"a"
Condition2nd:i>j
Weareinterestedinmin,soconsideronlyjmeansskipall"a"andaccept"b"andforeach"c",popeach"b"SoitisCFL.Pleasecorrectmeifitiswrong.
IfaboveNPDAisright,thenwecanconstructNPDAforL2also.
ButAnswerpartsayingL2isnotCFL.
SoaboveNPDAisrightorwrong??
http://gateoverflow.in/book

184/400

2/26/2015

GATEOverflow Book

PrefixpropertyisnotobeyedbyallDCFLs.ItisobeyedonlybythoselanguagesacceptedbyadeterministicPDAwhichacceptsbyemptystackifaprefix
ofthestringisinL,stackshouldhavebeenemptybeforeanddeterministicmeans,thiscannothappen.
Now,alanguageobeysprefixpropertydoesn'tmeanitisDCFL.{anbncn|n1}obeysprefixpropertybutnotevenCFL.

L1={aibjcm|mmin(i,j)}
Here number of c's is greater than minimum of number of a's and number of b's. So, we can say that if number of c's is greater than number of a's or if
numberofc'sisgreaterthannumberofb's,weaccept.i.e.,

L1={aibjcm|miORmj)}
TheORconditionheremeanseventhoughweneedtodotwochecks,wecanacceptineithercaseandhenceusingnondeterminismwejustneedaPDAto
acceptL1(wenondeterministicallycheckifmjandifmi).So,L1isaCFLbutnotDCFL.

L2={aibjcm|mmax(i,j)}
Thiscanberewrittenas

L2={aibjcm|miANDmj)}
TheANDconditionheremeansweneedtodotwochecksandevennondeterminismcannothelpushere.Thisisbecauseifwenondeterministicallyguess
ij,andacceptifmi,supposeiftheguessiswrong,thenwewouldhaveacceptedawordnotinL2.(Inshortnondeterminismcanhelponlywhenwe
haveORcondition).So,L2isnotevenCFLitisaCSL.
name

GivenLanguageisRECorNonREtop

IthinkoptionAiscorrect,becauseit'sgivenindefinitionitselfthatTMwillhaltoneverygivenstring.pleaseconfirmtheanswer.thanks!!

Well,thereisaneasysolutiontothisthanksto@Sonu.
LheredescribestheencodingofTMwhichhaltsforallinputs.Inotherwords,LdescribestheencodingofTMswhoselanguageisrecursive.Now,this
problemcanbesolvedeasilyusingRice'stheorem.(part2).
L(TM)isrecursive?isanonmonotonicproperty,becausewehaveaTMforwhichL(TM)isrecursiveTMyes,andwecanhaveanotherTMforwhich
http://gateoverflow.in/book

185/400

2/26/2015

GATEOverflow Book

L(TM) is nonrecursive Mno andL(TMyes) subset of L(M)no. (For example L(TMyes) is and L(TMno) is any nonrecursive language). Now, all non
monotonicpropertyoflanguageofTMarenotevensemidecidabletheirlanguageisnotrecursivelyenumerable.So,Lisnotrecursivelyenumerable.
L'canbestatedasisL(M)nonrecursive?ThisisagainanonmonotonicpropertyaswecanhaveL(TMyes)=anonrecursivelanguageandL(TMno)=*,
sothatthesubsetconditionholds.So,L'isalsononrecursivelyenumerable.

http://gatecse.in/wiki/Rice%27s_Theorem_with_Examples
name

Whichistrue?top

REGcontainsthesetofallstringswhichareencodingsofTMwhoselanguageisregular.So,REGisdecidingapropertyofTMweareluckyandcanmake
useofRice'stheorem.
HerewewanttoprovewhetherREornot.(Rice'stheorempart1won'thelp)
So,letsseeifthepropertyisnonmonotonicsothatwecanapplyRice'stheorempart2.
Fornonmonotonicity,languageofTMsatisfyingthepropertymustbeasubsetoflanguageofTMnotsatisfyingtheproperty.So,ifwetakeL(TMyes)=
andT(TMno)=anynonregularlanguage,thisprovesthepropertyisnonmonotonic.So,asperRice'stheorempart2,REGisnotRE.
UsingthesametechniquewecanproveCoRegisalsonotRE.JusttakeL(TMyes)=anynonregularlanguageandL(TMno)=*.
http://gatecse.in/wiki/Rice%27s_Theorem_with_Examples
name

LetL1isregularandL2isCFG.ThenwhatisL1L2?top
(A)Regular(B)CFG
(C)DeterministicCFG(D)ContextSensitive

L1L2=L1L2'
NowCFLcomplementneednotbeCFL(asCFL'sarenotclosedundercomplement).ButanyCFLisalsoaCSLandCSLsareclosedundercomplement.
So,anyCFLcomplementisguaranteedtobeaCSL.Now,CSLintersectionCSL(regularisalsoaCSL)isCSL,andsoL1L2isalwaysContextSensitive.
(ItcanalsoberegularorCFLbutwecansayalwaysonlywithrespecttoCSL)
http://gatecse.in/wiki/Closure_Property_of_Language_Families
name

Ithinktheanswershouldbe32butitsnotinoptions?Helpmeinthisquestion..top

FirstofallIwouldliketoclearthatemptylanguageisandnotandthereisonlyonewaytohavefinalstateinfiniteautomatathenBynothavingany
finalstateatall.Now16istotalnumberoftransitionspossibleinDFAoftwostatesandtwoinputs.SopossiblenumberofDFA'swithnofinalstate=16,
nowthereare4morepossibilitieswhenq1isfinalstateanditisnotreachablefrominitialstate..(courtesy@Arjunsir)Thereforeansis16+4=20
name

plzanswer...top
http://gateoverflow.in/book

186/400

2/26/2015

GATEOverflow Book

LetsseethestringsgeneratedbyGandG'.
ForG,
S>bAcAb>bcAb>bcb
S>bbSbb>bbAcAbb>bbcbb
S>bbSbb>bbAcAbb>bbcAb>bbcb
So,Gisgeneratingallstringswherenumberofb'stotheleftof'c'intheinputstringisgreaterthanorequaltothenumberofb'stotheright.So,L(G)is
contextfreebutnotregular.
ForG'wehaveanextraproductionbA>Awhichcancondenseanynumberofb's.So,G'willgenerateallstringsoverbandccontainingatleastoneb
beforeandafterac.Thislanguageishenceregular.
So,(B)iscorrect.

name

DoesPDAacceptsL={a^nb^n|n>=0,n!=13}???top
Ifitdoes,how??

ConsiderthefollowingLanguages:

Wecanseethat
isaDeterministicContextFreeLanguage(
isaRegularLanguage(
)
Since

,wecanconcludethat is

TodrawtheDPDAfor :
DrawaDPDAfor
DrawaDFAfor
Taketheproductofthetwomachines.Itissimple.Theprocedurefordoingthatislistedinthispdf(Clicktoview)
name

mydoubtisthatwhennotmentionedweshouldconsideritdfaornfacozanswillvarytop
http://gateoverflow.in/book

187/400

2/26/2015

GATEOverflow Book

Seethislink:ItsaysBydefault,FAisdeterministic

name

WhethergivenCFLisRegularisDecidable?top

HowcanaCFLbegiven?IfitisgivenasthelanguagegeneratedbyaCFG,thentheproblemisundecidable.
Thequestionhereisambiguous.
name

ThenumberofstatesinaDFAacceptingallthestringsover{0,1}inwhich5thsymbolfromright
handsideisalways'1'is?top
Willtheanswerbe4 or2 5 ?

Itwillbe25as25possiblecombinationsofcharactersarepossiblewiththe5thlastcharacterbeing1.Weneedtoremembereachofthemasanyofthemcan
bethe5thlastcharacteraswecontinueprocessingfurthercharacters.
name

LanguageacceptedbyPDAis__________?top

http://gateoverflow.in/book

188/400

2/26/2015

GATEOverflow Book

L={}
Becauseinq0whenstackisemptyandan'a'comes,'a'ispushedonstack.Now,togotoq1,again'a'willbepushedonstack.Fromq1'a'canbepoppedon
aninput'b'butthiscanhappenonlyonce.So,whenwereachq3atleastone'a'willbeonstackandnotransitionisgivenforthatcase.So,thegivenPDA
cannotacceptanystring.So,disthecorrectanswer.
name

equivalentregularexpression?top
AssumeR 1 ,R 2 ,andR 3 arethreeregularexpressions.
GivenR 1
equation.

+ R 2 R 3 = (R 1 + R 2 ) (R 1 + R 3 )

1.R 1

= R2

2.R 1

= R3

3.R 1

foranyR 2 andR 3 .Whichofthefollowingcouldbecorrectconditionwhichalwayssatisfiestheabove

A)only1and2arecorrect
B)only1and3arecorrect
C)only2and3arecorrect
D)1,2,and3arecorrect
AnswerisgivenasD
(R1+R2)(R1+R3)=R1R1+R1R3+R2R1+R2R3
Now,R1=R2=>LHS=R1+R2R3=R1+R1R3
RHS=R1R1+R1R3+R1R1+R1R1
So,theyarenotequal.ForexampleconsiderR1=R2=a,R3=b.LHS=a+ab,RHS=aa+ab
WhenR1=R3,LHS=R1+R2R1
RHS=R1R1+R1R1+R2R1+R2R1,againnotequal.Forexample,R1=R3=a,R2=b,LHS=a+ba,RHS=aa+ba
WhenR1=,
LHS=asconcatenatedwithanythingis
RHS=henceequal.
name

toctop
LetL1={anbmcn|m,n0}andL2={ancn|n0}.BothL1andL2arecontextfreelanguages.ifL=(L1L2)thenLis____.
a.FiniteLanguage
b.Regularlanguage
c.DCFL
http://gateoverflow.in/book

189/400

2/26/2015

GATEOverflow Book

d.NotDCFL

L1L2={anbmcn|m>0,n0}
DCFL.
name

WhichofthefollowinglanguagesareRecursivelyEnumerablelanguage?top
WhichofthefollowinglanguagesareRecursivelyEnumerablelanguage?
a.{<M>|MisaTMandthereexistaninputwhoselengthislessthan100,onwhichMhalts}
b.{<M>|MisaTMandL(M)={00,11}}
c.{<M1,M2,M3>|L(M1)=L(M2)L(M3)}
d.Allofthese

a)isrecursivelyenumerablebutnotrecursive.Ifthereissuchaninput,thenwecansay"yes".Butforthenocasewecannotdecideaswecanneverbesure
thatsuchaninputdoesnotexist.
b)isnotRE.WecanuseRice's2ndtheoremwhichwillbemoststraightforward.HerewearegiventheencodingofaTMandaskedifthelanguageofthat
machineis{00,11}.(Thisisdifferentfromaskingifthatmachineaccepts00and11,whichwouldbeRE).So,nowtoapplyRice's2ndtheorem,weneedto
make 2 TMs, TMyes and TMno, with L(TMyes) = {00,11} and L(TMno) != {00,11} and L(TMyes) subset of L(TMno). (The last condition is for non
monotonicity).
Here,wecaneasilygetaTMnoasL(TMno)canbe{00,11,011}oranysubsetofsigmastarcontaining{00,11}except{00,11}.SincewegetTMyes,and
TMno,thegivenlanguageisnotRE.
c)Checkingtheequivalenceoflanguageof2TMsitselfisnotevensemidecidable.So,thisisadoublenonrecursivelyenumerablelanguage.Wecanuse
Rice's2'ndtheoremherealso,bytakingL(TMno)=sigmastar.
name

No.ofstatesintheminimalfiniteautomatawhichacceptsthebinarystringswhoseequivalentis
divisibleby32is________?top
No.ofstatesintheminimalfiniteautomatawhichacceptsthebinarystringswhoseequivalentisdivisibleby32is________?
A.5
B.6
C31
D32

Answeris6.
Forbinarystringsdivisibleby2wecheckifthelastcharfromrightisa0.
Forbinarystringsdivisibleby22wecheckifthelastcharfromrightisa00.
...
Forbinarystringsdivisibleby25wecheckifthelastcharfromrightisa00000
So,weneed6statesforcountingthenumberof0'sonright,from0to5.

name

GATE20151_3top
ForanytwolanguagesL1 andL2 suchthatL1 iscontextfreeandL2 isrecursivelyenumerablebutnotrecursive,whichofthefollowingis/arenecessarily
true?

I. L
1 (ComplimentofL 1 )isrecursive

II. L
2 (ComplimentofL 2 )isrecursive

1
http://gateoverflow.in/book

190/400

2/26/2015

III.
IV.

GATEOverflow Book

L1

L1

iscontextfree
L2 isrecursivelyenumerable

A.
B.
C.
D.

Ionly
IIIonly
IIIandIVonly
IandIVonly

D.
L1iscontextfreeandhencerecursivealso.Recursivesetbeingclosedundercomplement,L1'willberecursive.
L1'beingrecursiveitisalsorecursivelyenumerableandRecursivelyEnumerablesetisclosedunderUnion.So,L1'UL2isrecursivelyenumerable.
ContextfreelanguagesarenotclosedundercomplementsoIIIisfalse
Recursivesetisclosedundercomplement.So,ifL2'isrecursive,(L2')'=L2isalsorecursivewhichisnotthecasehere.So,IIisalsofalse.
name

GATE20152_21top
Considerthefollowingstatements.
I. ThecomplementofeveryTuringdecidablelanguageisTuringdecidable
II. ThereexistssomelanguagewhichisinNPbutisnotTuringdecidable
III. IfLisalanguageinNP,LisTuringdecidable
Whichoftheabovestatementsis/aretrue?

A.
B.
C.
D.

OnlyII
OnlyIII
OnlyIandII
OnlyIandIII

Answer:D
name

GATE20152_35top
Considerthealphabet = {0, 1} ,thenull/emptystringandthesetofstringsX 0 , X 1 , andX 2 generatedbythecorrespondingnonterminalsofaregular
grammar.X 0 , X 1 , andX 2 arerelatedasfollows.
X 0 = 1X 1
X 1 = 0X 1 + 1X 2
X 2 = 0X 1 + {}

WhichoneofthefollowingchoicespreciselyrepresentsthestringsinX 0 ?

A.
B.
C.
D.

10(0*+(10)*)1
10(0*+(10)*)*1
1(0+10)*1
10(0+10)*1+110(0+10)*1

optionciscorrectbecauselookatthesmalleststringgeneratedbythegrammaris11whichisnotacceptedbyanyoption.
name

GATE20152_51top
Whichofthefollowingis/areregularlanguages?
L 1 : {wxw
n

L 2 : {a b

L 3 : {a b c

w, x {a, b} and|w|, |x| > 0}, w

is the reverse of stringw

m nandm, n 0}
r

p, q, r 0}

1
3
http://gateoverflow.in/book

191/400

2/26/2015

A.
B.
C.
D.

GATEOverflow Book

andL3 only
L 2 only
L 2 andL 3 only
L 3 only
L1

AnsA.
L1:allstringsoflength3ormorewithsamestartandendletterbecauseeverythinginmiddlecanbeconsumedbyxasperthedefinitionofL.
L2:Weneedtocomparenumberofa'sandb'sandthesearenotbounded.So,weneedatleastaDPDA.
L3:Anynumberofa'sfollowedbyanynumberofb'sfollowedbyanynumberofc's.Henceregular.
name

GATE20152_53top
Thenumberofstatesintheminimaldeterministicfiniteautomatoncorrespondingtotheregularexpression(0 + 1)

(10)

is_____.

Allstringsendingwith10.So,weneed3states.
Fromfirststateon1,wegotosecondstate.
Fromsecondstateon0wegotothirdstate.
Fromthirdstateon0wegotofirststateandon1wegotosecondstate.
Onlythirdstateisfinal.
name

GATE20151_51top
ConsidertheNPDAQ = {q 0 , q 1 , q 2 }, = {0, 1}, = {0, 1, }, , q 0 , , F = {q 2 },where(asperusualconvention)Qisthesetofstates, is
theinputalphabet,isthestackalphabet, isthestatetransitionfunctionq0 istheinitialstate, istheinitialstacksymbol,andFisthesetofaccepting
states.Thestatetransitionisasfollows:

Whichoneofthefollowingsequencesmustfollowthestring101100sothattheoverallstringisacceptedbytheautomaton?
A.
B.
C.
D.

10110
10010
01010
01001

ThegivenPDAisacceptingallstringsofoftheformx0x'rorx1x'r,wherex'risthereverseofthe1'scomplementofx.
Thegivenstring101100has6lettersandwearegiven5letterstrings.So,x0isdone,withx=10110.So,x'r=(01001)r=10110.
Bchoice.
name

GATE20151_52top

ConsidertheDFAsMandNgivenabove.ThenumberofstatesinaminimalDFAthatacceptthelanguageL(M)L(N)is_____________.
L(M)=(a+b)*a={a,aa,ba,aaa,aba,bba,...}
L(N)=(a+b)*b={b,ab,bb,aab,abb,bbb,...}

http://gateoverflow.in/book

192/400

2/26/2015

GATEOverflow Book

So,L(M)L(N)={}.So,intheminimalDFA,wejusthave1startstatewithalltransitionsgoingtoitselfandnofinalstate.
name

GATE20153_18top
LetLbethelanguagerepresentedbytheregularexpression

L (complementofL)?

0011

where

= {0, 1}

.WhatistheminimumnumberofstatesinaDFAthatrecognizes

A.
B.
C.
D.

4
5
6
8

firstwecandrawdfaforLwhichhas5statesafterthatforLcomplimentwewillconvertallfinaltononfinalandallnonfinaltofinalsototalstatesis5..
optionB
name

GATE20153_32top
Whichofthefollowinglanguagesarecontextfree?
L 1 : {a
L 2 : {a
L 3 : {a

b a b

b a

|m, n 1}

b |m, n 1}

b |m = 2n + 1}

A.
B.
C.
D.

andL2 only
andL3 only
L 2 andL 3 only
L 3 only
L1
L1

firstcheckforL1.nowlooka^m&b^manda^n&b^nmustbcomparableusingonestackforCFL.
nowtakeastackpushalla^mintothestackthenpushallb^nintostacknowa^niscomingsopopb^nforeacha^nbythisb^nanda^n
willbcomparable.nowwehaveleftonlya^minstackandb^miscomingsopopa^mforeachb^mbywhichwecancomparea^mtob^m
..weconcludethatwearecomparingthisL1usingasinglestacksothisisCFG.
nowforL2.thiscannotbedoneintoasinglestackbecausemandnarenotcomparablewecannotfindwhentopushorpopsothisis
CSL.
nowforL3.pushalla'sintostackandpopasingleaforevery2bandafterpoppingalla'swith2b'swewillgetasinglebinstacksothis
comparablehenceL3isCFG.
sotheoptionisB..L1andL3areCFG
name

http://gateoverflow.in/book

193/400

2/26/2015

GATEOverflow Book

ComputerNetworkstop
GATE2012_10top
Theprotocoldataunit(PDU)fortheapplicationlayerintheInternetstackis
(A)Segment
(B)Datagram
(C)Message
(D)Frame
(C)Messageisanswer.
ForApplication,PresentationandSessionlayers,thePDUismessage
ForTransportlayer,PDUissegmentforTCPanddatagramforUDP
ForNetworklayer,PDUispacket
ForDatalinklayer,PDUisframes
Forphysicallayer,PDUisstreamofbits
gatecse

Ifaorganisationrequires30hosts.whichisthebestpossiblemaskthatcanbeused?top
Sinceorganistationhas30hosts,ClassCnetworkwith/24Prefixshouldbeusedsinceitcansupport254hosts.
Nowthereare30hosts,sotheminimumnumberofbitsrequiredforhostnumberis5,since2 5

is30.

Therestofbitsi.e3canbeusedassubnetnumber.
Sothemaskis11111111.11111111.11111111.11100000
Forreferencehavealookathttp://andthatsjazz.org/wbglinks/pages/reads/misc/ip.html
name

GATE2008_14top

ansa)
name

GATE2006_05top
Forwhichoneofthefollowingreasonsdoesinternetprotocol(IP)usethetimetolive(TTL)fieldinIPdatagramheader?
(A)Ensurepacketsreachdestinationwithinthattime
(B)Discardpacketsthatreachlaterthanthattime
(C)Preventpacketsfromloopingindefinitely
(D)Limitthetimeforwhichapacketgetsqueuedinintermediaterouters
ansc)
name

GATE2003_82top
Thesubnetmaskforaparticularnetworkis255.255.31.0.WhichofthefollowingpairsofIPaddressescouldbelongtothisnetwork?
A. 172.57.88.62and172.56.87.233
B. 10.35.28.2and10.35.29.4
http://gateoverflow.in/book

194/400

2/26/2015

GATEOverflow Book

C. 191.203.31.87and191.234.31.88
D. 128.8.129.43and128.8.161.55

AandCarenottheanswersasthesecondbyteofIPdiffersandsubnetmasthas255forsecondbyte.
ConsiderB,
10.35.28.2&255.255.31.0=10.35.28.0(28=11100)
10.35.29.4&255.255.31.0=10.35.29.0(29=11111)
So,wegetdifferentsubnetnumbers
ConsiderD.
128.8.129.43&255.255.31.0=128.8.1.0(129=10000001)
128.8.161.55&255.255.31.0=128.8.1.0(161=10100001)
Thesubnetnumbermatches.So,Distheanswer.
name

GATE2003_84top
HostAissendingdatatohostBoverafullduplexlink.AandBareusingtheslidingwindowprotocolforflowcontrol.Thesendandreceivewindowsizesare
5packetseach.Datapackets(sentonlyfromAtoB)areall1000byteslongandthetransmissiontimeforsuchapacketis50s.Acknowledgementpackets
(sentonlyfromBtoA)areverysmallandrequirenegligibletransmissiontime.Thepropagationdelayoverthelinkis200 s.Whatisthemaximumachievable
throughputinthiscommunication?
A.

7.69 10

B.

11.11 10

C.

12.33 10

D.

15.00 10

bps
6

bps

bps

bps

Ithinkoptionsaregiveninbytespersecinsteadofbitspersec.
Transmissiontime=50microsec
Propagationtime=200microsec
RTT=50+2*200=450microsec(ReceivercansendanACKassoonasthefirstpacketisreceived)
totalnumberofbitstransmittedbeforefirstACKisreceived=1000x5x8bits=40000bits
AfterfirstACKisreceived,samecycleofactionrepeats.So,
Throughput=(40000/450)x10^6bits=88.88x10^6bitsps=11.11x10^6bytespersec
name

GATE2004_15top

ansa)
name

GATE2004_55top
http://gateoverflow.in/book

195/400

2/26/2015

GATEOverflow Book

TheAnswermustbeA.
For1stpacket,
(128.75.43.16)&&(255.255.255.0)=(128.75.43.0)since{16&&0=0},aswellas
(128.75.43.16)&&(255.255.255.128)=(128.75.43.0)since{16&&128=0}.
Now,sinceboththesesubnetmasksareproducingthesameNetworkID,henceTheonewithgreaternumberofoneswillbeselected,andthepacketwillbe
forwardedthere.Hencepacket1willbeforwardedtoEth1.
For2ndpacket,
(192.12.17.10)whenandedwitheachofthesubnetmasksdoesnotmatchwithanyofthenetworkID,since:
(192.12.17.10)&&(255.255.255.0)=(192.12.17.0){Doesnotmatchwithanyofthenetworkaddresses}
(192.12.17.10)&&(255.255.255.128)=(192.12.17.0){Doesnotmatchwithanyofthenetworkaddresses}
(192.12.17.10)&&(255.255.255.255)=(192.12.17.10){Doesnotmatchwithanyofthenetworkaddresses}
Hence,Defaultinterfacemustbeselectedforpacket2,i.eInterfaceEth2.
saurabhrk

GATE2004_56,57top

PacketAsendsanIPpacketof180bytesofdata+20bytesofTCPheader+20bytesofIPheadertoB.
IPlayerofBnowremoves20bytesofIPheaderandhas200bytesofdata.So,itmakes3IPpackets[80+20,80+20+40+20]andsendstoCastheIp
packetsizeofBis100.So,Creceives260bytesofdatawhichincludes60bytesofIPheadersand20bytesofTCPheader.
Fordatarate,weneedtoconsideronlytheslowestpartofthenetworkasdatawillbegettingaccumulatedatthatsender(dataratetillthatslowestpart,we
needtoaddtimeifafasterpartfollowsaslowerpart).
So,here180bytesofapplicationdataaretransferredfromAtoCandthiscauses260bytestobetransferredfromBtoC.
Timetotransfer260bytesfromBC=260*8/(512*1000)=65/16000=13/3200
So,datarate=180*3200/13=44.3kBps=354.46kbps
http://gateoverflow.in/book

196/400

2/26/2015

GATEOverflow Book

name

GATE2007_65top

ansc)
name

GATE2007_70top
Matchthefollowing:
(P)
(Q)
(R)
(S)

SMTP
BGP
TCP
PPP

(1)
(2)
(3)
(4)
(5)

Applicationlayer
Transportlayer
Datalinklayer
Networklayer
Physicallayer

P2,Q1,R3,S5
P1,Q4,R2,S3
P1,Q4,R2,S5
P2,Q4,R1,S3
Iguessansweris(b)here.PPPisadatalinklayerprotocol
https://docs.oracle.com/cd/E18752_01/html/8164554/ipov6.html
name

GATE2009_57,58top

Bandwidthwon'tbehalvedinfullduplex.http://superuser.com/questions/335979/does1gbitsportinfullduplexmean1gbitssendand1gbitsreceive
Propagationtimeisgivenas25ms.
Bandwidth=106bps.
So,tofullyutilizethechannel,wemustsend106bitsintothechannelinasecond,whichwillbe1000framespersecondaseachframeis1000bits.Now,
sincethepropagationtimeis25ms,tofullypackthelinkweneedtosendatleast1000*25*103=25frames.So,weneedlog225=5bits.

58.I=5,so2I=32framesaresent.
Now,weneedtogetRTT(whichisthetimebetweenwhichaframeissentanditsACKisreceived),todeterminethewaitingtime.
http://gateoverflow.in/book

197/400

2/26/2015

GATEOverflow Book

Transmissiontime(foraframeofsize1000bits)=1000/106=1ms.
So,transmissiontimefor32frames=32ms.
RTT=Propagationtimeforframe+Transmissiontimeforframe+PropagationtimeforACK+TransmissiontimeforACK
=25ms+1ms+25ms+1ms(ACKispiggybackedandassumingframesizeforpiggybackingisalso1000bits)
=52ms
So,waitingtime=5232=20ms.
name

GATE2005_23top
Packetsofthesamesessionmayberoutedthroughdifferentpathsin:
A.
B.
C.
D.

TCP,butnotUDP
TCPandUDP
UDP,butnotTCP
NeitherTCPnorUDP

b)TCPandUDP.
RoutinghappensinNetworklayerandhencehasnodependencywiththethetransportlayerprotocolsTCPandUDP.Thetransportlayerprotocolwhether
TCPorUDPishiddentotherouterandtheroutingpathisdeterminedbasedonthethenetworkconfigurationatthetimeandhencecanchangeevenduringa
session.
name

GATE2005_24top
Theaddressresolutionprotocol(ARP)isusedfor:
(a)FindingtheIPaddressfromtheDNS
(b)FindingtheIPaddressofthedefaultgateway
(c)FindingtheIPaddressthatcorrespondstoaMACaddress
(d)FindingtheMACaddressthatcorrespondstoanIPaddress
ansd)
name

GATE2005_25top
Themaximumwindowsizefordatatransmissionusingtheselectiverejectprotocolwithn bit framesequencenumbersis:
(a)2 n (b)2 n1 (c)2 n

(d)2 n2

ansb)
Inselectiverejectprotocol,themaximumwindowsizemustbehalfthesequencenumberspace=2n/2=2n1.
ForGobackn,themaximumwindowsizecanbe2n1.
http://webmuseum.mi.fhoffenburg.de/index.php?view=exh&src=73
name

GATE2005_74top
Supposetheroundtrippropagationdelayfora10MbpsEthernethaving48bitjammingsignalis46.4s.Theminimumframesizeis:
A.
B.
C.
D.

94
416
464
512

http://gateoverflow.in/book

198/400

2/26/2015

GATEOverflow Book

The sender must be able to detect a collision before completely sending a frame. So, the minimum frame length must be such that, before the frame
completelyleavesthesenderanycollisionmustbedetected.
Now,theworstcaseforcollisiondetectioniswhenthestartoftheframeisabouttoreachthereceiverandthereceiverstartssending.Collisionhappensand
ajamsignalisproducedandthissignalmusttraveltothesender.So,thetimeforthiswillbepropagationdelayforthestartoftheframetoreachnearthe
receiver+propagationdelayforthejamsignaltoreachthesender+transmissiontimeforthejamsignal.(Wedon'tneedtoincludepropagationtimeforthe
frameasassoonasthefirstbitoftheframearrives,thereceiverwillhavedetectedit).So,thiswillbe
2*46.4/2+48/10(48bitsat10Mbpstakes4.8microsec.)=51.2s.
Now,theframelengthmustbesuchthatitstransmissiontimemustbemorethan51.2s.So,minimumframelength
=51.2*10=512bits.
http://gatecse.in/w/images/3/32/3MACSublayer.ppt
name

GATE2012_22top
Whichofthefollowingtransportlayerprotocolsisusedtosupportelectronicmail?
(A)SMTP
(B)IP
(C)TCP
(D)UDP
ansc)
SMTPisusedinApplicationLayer.
name

GATE20141_24top
Whichofthefollowingareusedtogenerateamessagedigestbythenetworksecurityprotocols?
(P)RSA(Q)SHA1(R)DES(S)MD5
(A)PandRonly
(B)QandRonly
(C)QandSonly
(D)RandSonly
RSAandDESareusedforEncryptionwhereMD5andSHA1areusedtogenerateMessage
Digest.
name

GATE20141_26top
Consideratokenringnetworkwithalengthof2kmhaving10stationsincludingamonitoringstation.Thepropagationspeedofthesignalis2 108 m/sand
thetokentransmissiontimeisignored.Ifeachstationisallowedtoholdthetokenfor2sec,theminimumtimeforwhichthemonitoringstationshould
wait(insec )beforeassumingthatthetokenislostis_______.

Timerequiredtocompleteonecycle=Tp(RingLatency)+N*THT
=2km/(2*108m/s)+10*2
=10+10*2=30s
whereTHTistokenholdingtime.
name

GATE20141_27top
LetthesizeofcongestionwindowofaTCPconnectionbe32KBwhenatimeoutoccurs.Theroundtriptimeoftheconnectionis100msecandthemaximum
segmentsizeusedis2KB.Thetimetaken(inmsec)bytheTCPconnectiontogetbackto32KBcongestionwindowis_________.

http://gateoverflow.in/book

199/400

2/26/2015

GATEOverflow Book

Ans:GiventhatatthetimeofTimeOut,CongestionWindowSizeis32KBandRTT=100ms,
WhenTimeOutoccurs,forthenextroundofSlowStart,Threshold=(sizeofCwnd)/2,
ItmeansThreshold=16KB
So,wehaveSlowstart==>>2KB|4KB|8KB|16KB(nowthresholdreachessoAdditiveincreasestarts)|18KB|20KB|22KB|24KB|26KB|
28KB|30KB|32KB
So,inabovenumberof|(verticalline)isrepresentedbyRTTsototalnumberofverticallineis11*100ms==>>1100msecisAnswer...

name

GATE2006_46top
StationAneedstosendamessageconsistingof9packetstoStationBusingaslidingwindow(windowsize3)andgobacknerrorcontrolstrategy.All
packetsarereadyandimmediatelyavailablefortransmission.Ifevery5thpacketthatAtransmitsgetslost(butnoacksfromBevergetlost),thenwhatisthe
numberofpacketsthatAwilltransmitforsendingthemessagetoB?
(A)12
(B)14
(C)16
(D)18

Sinceallpacketsarereadyinitiallyitself,wecanassumeatimeoutisdetectedafterallpossiblepacketsaresent.So,thesendinghappensasshowninfigure
(Idrawthefigureassuming10packets.For9packetsanswerwillbe16).

name
http://gateoverflow.in/book

200/400

2/26/2015

GATEOverflow Book

GATE20142_25top
Inthediagramshownbelow,L1isanEthernetLANandL2isaTokenRingLAN.AnIPpacketoriginatesfromsenderSandtraversestoR,asshown.Thelinkswithin
eachISPandacrossthetwoISPs,areallpointtopointopticallinks.TheinitialvalueoftheTTLfieldis32.ThemaximumpossiblevalueoftheTTLfieldwhenR
receivesthedatagramis_______.

TTLfieldreducedateachrouter,therearetotal5routersandfinallyatreceiver.
=32(5+1)=26
name

GATE2010_15top
OneoftheheaderfieldsinanIPdatagramistheTimetoLive(TTL)field.Whichofthefollowingstatementsbestexplainstheneedforthisfield?
(A)Itcanbeusedtoprioritizepackets.
(B)Itcanbeusedtoreducedelays.
(C)Itcanbeusedtooptimizethroughput.
(D)Itcanbeusedtopreventpacketlooping.

Itcanbeusedtopreventpacketlooping.

name

GATE2008IT_65top
TheminimumframesizerequiredforaCSMA/CDbasedcomputernetworkrunningat1Gbpsona200mcablewithalinkspeedof2108m/sis

A)
B)
C)
D)

125bytes
250bytes
500bytes
Noneoftheabove

Minimumframesizeisneededtoensurethatcollisionsaredetectedproperly.Theminimumframesizeensuresthatbeforeaframeiscompletelysend,it
wouldbenotifiedofanypossiblecollisionandhencecollisiondetectionworksperfectly.
InCSMA/CDasenderwon'tsendapacketifitsensesthatanothersenderisusingit.So,assumeasenderAandareceiverB.Whensendersendsapacket,
receivermightusethecableuntilitisnotifiedthatapacketisbeingsendtoit.Thereceiverwillbenotifiedassoonasthefirstbitarrivesthatapacketis
cominganditwon'tsendanypacketafterthisuntilthatpacketisfinished.So,intheworstcaseforcollision,receiverwilltransmitapacketbacktothe
senderjustbeforethefirstbitofthepacketreachesit.(Iftd isthepropagationdelayofthechannel,thistimewouldbejusttd ).Inthiscase,surelytherewill
becollision.Butforthesendertodetectit,itshouldbenotifiedofB'spacketbeforethesendingofthefirstpacketfinishes.i.e.,whenB'spacketarrivesatA
(takesanother td time),Ashouldn'thavefinishedtransmissionofthefirstpacketforittodetectacollision.i.e.,Ashouldbestillcontinuingthesendingof
thepacketinthistimeintervalof2 td .Thus,
TheamountofbitsthatcanbetransmittedbyAin2 td timeshouldbelessthantheframesize(S)(sendingoftheframeshouldn'tfinishinthistime)
distance
Amountofbitstransmittedintimetisbandwidth t andpropagationdelaytd is link
speed

So,S

2 bandwidth t d

2 10

200
210

2000

250

bits

http://gateoverflow.in/book

201/400

2/26/2015

GATEOverflow Book

250

bytes

name

GATE2008IT_70top
The total number of keys required for a set of n individuals to be able to communicate with each other using secret key and public key cryptosystems,
respectivelyare:

A)
B)
C)
D)

n(n1)and2n
2nand((n(n1))/2)
((n(n1))/2)and2n
((n(n1))/2)andn

Forprivatekeycryptoforcommunicationbetweeneachpairofindividualsonsecretkeywillberequired,soifaindividualwantstocommunicatewithother
n1individualsheshouldhaven1secretkeys,sothetotalnumberofsecretkeysforprivateencryptionisn*(n1).
Forpublickeyencryptioneachindividualneedstohaveapublicandprivatekey,sothetotalkeysrequiredin2*n
SotheanswerisA)n(n1)and2n
name

GATE2007IT_64top
Abroadcastchannelhas10nodesandtotalcapacityof10Mbps.Itusespollingformediumaccess.Onceanodefinishestransmission,thereisapollingdelay
of 80 s to poll the next node. Whenever a node is polled, it is allowed to transmit a maximum of 1000 bytes. The maximum throughput of the broadcast
channelis

1)
2)
3)
4)

1Mbps
100/11Mbps
10Mbps
100Mbps
Propagationtimeisnotgivensothat'snegligiblehere.
efficiency=transmissiontime/(transmissiontime+pollingtime)
Tx=1000bytes/10Mbps=800s.
Delaybecauseofpollingis=80s
Efficiencyofchannel,e=transmissiondelay/(totaldelay)=800/(800+80)=10/11
Maximumthroughputis=(10/11)*10Mbps=100/11Mbps
name

GATE2006IT_70top
AsubnettedClassBnetworkhasthefollowingbroadcaseaddress:144.16.95.255.Itssubnetmask

A)
B)
C)
D)

isnecessarily255.255.224.0
isnecessarily255.255.240.0
isnecessarily255.255.248.0.
couldbeanyoneof255.255.224.0,255.255.240.0,255.255.248.0
option(D)iscorrect.Inthebroadcastaddressforasubnet,allthehostbitsaresetto1.Soaslongasallthebitstotherightare1,bitslefttoitcanbetakenas
possiblesubnet.
broadcastaddressforsubnetis.95.255.01011111.11111111(asinClassB,16bitseachareusedfornetworkandhost)
Sowecantakeminimum3bits(fromleft)assubnetandmakerestashostbits(astheyare1).

.224.011100000.00000000(leftmost3bitsforsubnet)
.240.011110000.00000000(leftmost4bitsforsubnet)
.248.011111000.00000000(...5bitsforsubnet)

http://gateoverflow.in/book

202/400

2/26/2015

GATEOverflow Book

name

GATE2004IT_25top
Asenderisemployingpublickeycryptographytosendasecretmessagetoareceiver.WhichoneofthefollowingstatementsisTRUE?

A)
Senderencryptsusingreceiver'spublickey
B)
Senderencryptsusinghisownpublickey
C)
Receiverdecryptsusingsender'spublickey
D)
Receiverdecryptsusinghisownpublickey

A)Senderencryptsusingreceiver'spublickey
name

GATE2004IT_26top
Asubnethasbeenassignedasubnetmaskof255.255.255.192.Whatisthemaximumnumberofhoststhatcanbelongtothissubnet?

A)
14
B)
30
C)
62
D)
126
Cisanswersinceyouhave6zeroessoucanmake642hosts
name

GATE2004IT_45top
AserialtransmissionT1uses8informationbits,2startbits,1stopbitand1paritybitforeachcharacter.AsynchronoustransmissionT2uses3eightbitsync
charactersfollowedby30eightbitinformationcharacters.Ifthebitrateis1200bits/secondinbothcases,whatarethetransferratesofT1andT2?

A)
B)
C)
D)

100characters/sec,153characters/sec
80characters/sec,136characters/sec
100characters/sec,136characters/sec
80characters/sec,153characters/sec

1. T1:1char.=(8+2+1+1)=12bit
TransferRate=1200/12=100char/sec.
T2:Transfercharacterinbits=24+240=264bits
In264=30character
Then1200=?
264/30=1200/X
X=136.3character/sec.
socorrectoptionis(C)
name

GATE2004IT_80top
Inadatalinkprotocol,theframedelimiterflagisgivenby0111.Assumingthatbitstuffingisemployed,thetransmittersendsthedatasequence01110110as

A)
B)
C)
D)
http://gateoverflow.in/book

01101011
011010110
011101100
0110101100
203/400

2/26/2015

GATEOverflow Book

AnswerwillbeoptionD.)
Thebitstuffingisdoneaftereverytwo'11'(asflagis0111)todifferentiatethedatapartfromtheflag.andthereforeoptionD.istheanswer.
http://web.nchu.edu.tw/~pcwang/computer_networks/data_link_layer.pdf
name

GATE2004IT_81top
InaslidingwindowARQscheme,thetransmitter'swindowsizeisNandthereceiver'swindowsizeisM.Theminimumnumberofdistinctsequencenumbers
requiredtoensurecorrectoperationoftheARQschemeis

A)
B)
C)
D)

min(M,N)
max(M,N)
M+N
MN
C)M+N
BecauseWs+WrSequencenumbers(asthemaximumnumberofunacknowledgedpacketsatsenderwillbeWsandatthereceiveritwillbeWr,similarto
thesequencenumberinginSelectiveRepeat)
whereWsissizeofsenderwindowandWrisreceiverwindow'ssize.
name

GATE2004IT_86top
IntheTCP/IPprotocolsuite,whichoneofthefollowingisNOTpartoftheIPheader?

A)
B)
C)
D)

FragmentOffset
SourceIPaddress
DestinationIPaddress
Destinationportnumber
D.)DestinationPortnumber.
Why?BecausetheIPheaderhasnothingtodowiththeportnumber.
Portnumbersareusedbythetransportlayertoensureprocesstoprocessdelivery.
name

GATE2005IT_25top
Considerthethreecommands:PROMPT,HEADandRCPT.
Whichofthefollowingoptionsindicateacorrectassociationofthesecommandswithprotocolswheretheseareused?

A)
B)
C)
D)

HTTP,SMTP,FTP
FTP,HTTP,SMTP
HTTP,FTP,SMTP
SMTP,HTTP,FTP
RCPT>Recipientto,AsthenamesuggestitisusedinSMTP(SimpleMailTransferprotocol)
HEAD>thisisusedinHTTPtogetthemetainformation,todecidethecategoryofpacket.
Prompt>turnsoffpromptingforindividualfileswhenusingthemgetormputcommands
name

GATE2005IT_26top
Traceroute reports a possible route that is taken by packets moving from some host A to some other host B. Which of the following options represents the
techniqueusedbytraceroutetoidentifythesehosts

http://gateoverflow.in/book

204/400

2/26/2015

GATEOverflow Book

1) ByprogressivelyqueryingroutersaboutthenextrouteronthepathtoBusingICMPpackets,startingwiththefirstrouter
ByrequiringeachroutertoappendtheaddresstotheICMPpacketasitisforwardedtoB.ThelistofallroutersenroutetoBisreturnedbyBinanICMP
2)
replypacket
3) ByensuringthatanICMPreplypacketisreturnedtoAbyeachrouterenroutetoB,intheascendingorderoftheirhopdistancefromA
4) BylocallycomputingtheshortestpathfromAtoB

A)TracerouteworksbysendingpacketswithgraduallyincreasingTTLvalue,startingwithTTLvalueof1.Thefirstrouterreceivesthepacket,decrementstheTTL
valueanddropsthepacketbecauseitthenhasTTLvaluezero.TheroutersendsanICMPTimeExceededmessagebacktothesource.Thenextsetofpackets
aregivenaTTLvalueof2,sothefirstrouterforwardsthepackets,butthesecondrouterdropsthemandreplieswithICMPTimeExceeded.Proceedinginthis
way, traceroute uses the returned ICMP Time Exceeded messages to build a list of routers that packets traverse, until the destination is reached and returns
anICMPEchoReplymessage

name

ARPprotocolbelongstowhichlayerofOSImodel.?Accordingtomeitisneithercompletelylayer3
(Networklayer)norcompletelylayer2(datalinklayer).Pleaseclarifytop
Youarecorrect.
https://en.wikipedia.org/wiki/Address_Resolution_Protocol
name

GATE20152_8top
Alinkhastransmissionspeedof106 bits/sec.Itusesdatapacketsofsize1000byteseach.Assumethattheacknowledgementhasnegligibletransmissiondelay,
andthatitspropagationdelayisthesameasthedatapropagationdelay.Alsoassumethattheprocessingdelaysatnodesarenegligible.Theefficiencyofthe
stopandwaitprotocolinthissetupisexactly25%.Thevalueoftheonewaypropagationdelay(inmilliseconds)is_____.

Instopandwait,aframeissentandnextframewillbesentonlyafterACKisreceived.
Efficiency=Amountofdatasent/Amountofdatathatcouldbesent
=1000*8/(Prop.delayfordata+Prop.delayforACK+1000*8/106)*106
=8/(2p+8ms)(wherepistheprop.delayinmilliseconds)
=4/p+4=0.25(giveninquestion)
So,p+4=16,p=12ms.
name

GATE20152_20top
Identifythecorrectorderinwhichaserverprocessmustinvokethefunctioncallsaccept,bind,listen,andrecvaccordingtoUNIXsocketAPI.

A.
B.
C.
D.

listen,accept,bind,recv
bind,listen,accept,recv
bind,accept,listen,recv
accept,listen,bind,recv

Answer:B
Bind:Bindsthesockettoanaddress
Listen:Waitsforconnectionstothesocket
Accept:Acceptsaconnectiontothesocket
Recv:Receivesdatafromconnection
FromManpageofaccept:
Itextractsthefirstconnectionrequestonthequeueofpendingconnectionsforthelisteningsocket,createsanewconnectedsocket,andreturnsanewfile
descriptorreferringtothatsocket.Thenewlycreatedsocketisnotinthelisteningstate.Theoriginalsocketisunaffectedbythiscall

http://gateoverflow.in/book

205/400

2/26/2015

GATEOverflow Book

name

GATE20152_34top
AssumethatthebandwidthforaTCPconnectionis1048560bits/sec.LetbethevalueofRTTinmilliseconds(roundedofftothenearestinteger)afterwhich
theTCPwindowscaleoptionisneeded.Let bethemaximumpossiblewindowsizewithwindowscaleoption.Thenthevaluesofand are

A.
B.
C.
D.

63milliseconds,655352 14
63milliseconds,655352 16
500milliseconds,655352 14
500milliseconds,655352 16

answerisC.
becauseTCPwindowscaleoptionisneededwhensizeincreasesmorethan65535B.itmeansalpha(RTT)shouldbethetimetakentosend65535Btothe
receiver.
Timetosend65535B=65535*8/1048560*1000=500ms.
soalphawillbe500.
maximumwindowsizewithwindowscaleoptionispossibleinTCPis1073725440Bwhichis65535*2^14.
http://en.wikipedia.org/wiki/TCP_window_scale_option
name

GATE20151_17
top
Inoneofthepairsofprotocolsgivenbelow,boththeprotocolscanusemultipleTCPconnectionsbetweenthesameclientandtheserver.Whichoneisthat?
A.
B.
C.
D.

HTTP,FTP
HTTP,TELNET
FTP,SMTP
HTTP,SMTP

SMTP:onlyoneTCPconnection
Ref:https://tools.ietf.org/html/rfc821
Telnet:onlyoneTCPconnection
Ref:https://tools.ietf.org/html/rfc854
HTTP:Multipleconnectionscanbeusedforeachresource
Ref:http://www.w3.org/Protocols/rfc2616/rfc2616sec1.html#sec1
FTP:FTPusesTelnetprotocolforControlinfoonaTCPconnectionandanotherTCPconnectionfordataexchange
Ref:https://tools.ietf.org/html/rfc959(Seepage8)
So,answerisA.
name

GATE20151_19
top
SupposetwohostsuseaTCPconnectiontotransferalargefile.Whichofthefollowingstatementsis/areFALSEwithrespecttotheTCPconnection?
I. Ifthesequencenumberofasegmentism,thenthesequencenumberofthesubsequentsegmentisalwaysm+1.
II. Iftheestimatedroundtriptimeatanygivenpointoftimeistsec,thevalueoftheretransmissiontimeoutisalwayssettogreaterthanorequaltotsec.
III. ThesizeoftheadvertisedwindowneverchangesduringthecourseoftheTCPconnection.
IV. Thenumberofunacknowledgedbytesatthesenderisalwayslessthanorequaltotheadvertisedwindow.

A.
B.
C.
D.

IIIonly
IandIIIonly
IandIVonly
IIandIVonly

http://gateoverflow.in/book

206/400

2/26/2015

GATEOverflow Book

optionb
http://web.eecs.utk.edu/~qi/teaching/ece453f06/hw/hw7_sol.htm
GATERush

GATE20151_22top
WhichofthefollowingfieldsofanIPheaderisNOTmodifiedbyatypicalIProuter?
A.
B.
C.
D.

Checksum
Sourceaddress
TimetoLive(TTL)
Length

SourceAddress.
name

GATE20151_21top
SupposethateveryoneinagrouponNpeoplewantstocommunicatesecretlywiththeN1othersusingsymmetricKeycryptographicsystem.The
communicationbetweenanytwopersonshouldnotbedecodablebytheothersinthegroup.Thenumbersofkeysrequiredinthesystemasawholetosatisfythe
confidentialityrequirementis
A.
B.
C.
D.

2N
N(N1)
N(N1)/2
(N1)2

Insymmetrickeycryptographicsystem,bothpartieshaveaccesstokey.So,thefirstpersonhasN1keyswithotherN1people,secondonehasanotherN2
withN2people(1wealreadyconsidered)andsoontill1.So,totalnumberofkeysrequired
=N1+N2+....+1
=N(N1)/2
Cchoice.
name

GATE20152_52top
HostAsendsaUDPdatagramcontaining8880bytesofuserdatatohostBoveranEthernetLAN.Ethernetframesmaycarrydataupto1500bytes(i.e.MTU=
1500bytes).SizeofUDPheaderis8bytesandsizeofIPheaderis20bytes.ThereisnooptionfieldinIPheader.HowmanytotalnumberofIPfragmentswill
betransmittedandwhatwillbethecontentsofoffsetfieldinthelastfragment?

A.
B.
C.
D.

6and925
6and7400
7and1110
7and8880

AnsC
numberoffragments=ceil(8888/1480)=7
offsetoflastfragment=(150020)*6/8=1110(scalingfactorof8isusedinoffsetfield)
name

GATE20151_53top
Supposethatthestopandwaitprotocolisusedonalinkwithabitrateof64kilobitspersecondand20millisecondspropagationdelay.Assumethatthe
transmissiontimefortheacknowledgementandtheprocessingtimeatnodesarenegligible.Thentheminimumframesizeinbytestoachievealinkutilization
ofatleast50%is_________________.
LinkUtilization=Amountofdatasent/Max.amountofdatathatcouldbesent.
Letxbetheframesizeinbits.
Instopandwaitprotocol,onceaframeissent,nextframewon'tbesentuntilACKisreceived.Timeforthis,
RTT=Propagationdelayforframe+Transmissiontimeforframe+PropagationdelayforACK+TransmissiontimeforACK
=20ms+x/64ms+20ms+0(asgiveninquestion)
http://gateoverflow.in/book

207/400

2/26/2015

GATEOverflow Book

=(40+x/64)ms.
AmountofdatasentduringRTT=x
Max.amountofdatathatcouldbesent=(40+x/64)*64=2560+xbits.
So,linkutilization,0.5=x/(2560+x)
x=2560bits=320bytes.
name

GATE20153_6top
ConsideraCSMA/CDnetworkthattransmitsdataatarateof100Mbps(108 bitspersecond)overa1km(kilometer)cablewithnorepeaters.Iftheminimum
framesizerequiredforthisnetworkis1250bytes,whatisthesignalspeed(km/sec)inthecable?

A.
B.
C.
D.

8000
10000
16000
20000

Forcollisiontobedetected,theframesizeshouldbesuchthatthetransmissiontimeoftheframeshouldbegreaterthantwicethepropagationdelay(So,
beforetheframeiscompletelysent,anypossiblecollisionwillbediscovered).
So,1250*8/(108)>=2*1/x
x=2*104=20000
name

GATE20153_22top
Considerthefollowingstatements.
I. TCPconnectionsarefullduplex
II. TCPhasnooptionforselectiveacknowledgement
III. TCPconnectionsaremessagestreams

A.
B.
C.
D.

OnlyIiscorrect
OnlyIandIIIarecorrect
OnlyIIandIIIarecorrect
AllofI,IIandIIIarecorrect

answeris(A)sinceTCPhasoptionsforselectiveACKandTCPusesbytestreamsthatiseverybytethatissendusingTCPisnumbered.
http://repo.hackerzvoice.net/depot_madchat/ebooks/TCPIP_Illustrated/tcp_tran.htm
name

GATE20153_28top
Consideranetworkconnectingtwosystemslocated8000kilometersapart.Thebandwidthofthenetworkis500 106 bitspersecond.Thepropagationspeed
ofthemediais4 106 meterspersecond.ItisneedtodesignaGoBackN slidingwindowprotocolforthisnetwork.Theaveragepacketsizeis107 bits.
Thenetworkistobeusedtoitsfullcapacity.Assumethatprocessingdelaysatnodesarenegligible.Then,theminimumsizeinbitsofthesequencenumber
fieldhastobe______.
Answer=8bits
Inordertoachievefullutilization,senderhastokeeponsendingframestilltheacknowledgementarrivesforthefirstframe.
Timetakenforacknowledgementtoarriveis2timespropagationdelay+transmissiontimeforaframe.
Onewaypropagationtime=8000x10^3/(4x10^6)
=2secs
Timetakentotransmitoneframe=10^7/(500x10^6)
=0.02secs
http://gateoverflow.in/book

208/400

2/26/2015

GATEOverflow Book

So,RTT=2*2+0.02=4.02
Noofframesthatcanbetransmittedin4.02secs=4.02/0.02
=201
Henceminimumnumberofbitsrequiredforsequencenumberstill201is8(as2^8=256)
overtomanu

GATE20153_36top
Twohostsareconnectedviaapacketswitchwith107 bitspersecondlinks.Eachlinkhasapropagationdelayof20microseconds.Theswitchbegins
forwardingapacket35microsecondsafteritreceivesthesame.If10000bitsofdataaretobetransmittedbetweenthetwohostsusingapacketsizeof5000bits,
thetimeelapsedbetweenthetransmissionofthefirstbitofdataandthereceptionofthelastbitofthedatainmicrosecondsis______.

No.ofpacketssent=10000/5000=2.
Timeforthefirstpackettoreachswitch=Transmissiontime+Propagationdelay
=(5000/107)*106s+20s
=520s.
(Another520sisrequiredforthesamepackettoreachthedestinationfromtheswitchandinbetweenthereisaforwarddelayof35s.So,firstpacketis
receivedatdestinationat2*520+35=1075s.)
After520s,theswitchcanstartreceivingthesecondpacketandat520+500=1020s,secondframeiscompletelyreceivedbytheswitch(wedon'tneed
toaddpropagationtimehereaspacket2canjustfollowpacket1).So,at1055sfromthestarttheswitchstartssendingthesecondpacketandthiswillbe
receivedatdestinationafteranother520s=1575s.Sinceweaddedtransmissiontime,thisensuresthatthelastbitofdataisreceivedatthesender.
name

GATE20153_38top
Inthenetwork200.10.11.144/27,thefourthoctet(indecimal)ofthelastIPaddressofthenetworkwhichcanbeassignedtoahostis_____.
Answer=158
144inbinary=10010000
outofthis3bitsinleftaresubnetbits.(27bitsareusedforsubnet,whichmeanstop3bytesandleftmost3bitsfromthelastbyte)
sothe4thoctetinthelastipaddressofthenetworkwhichcanbeassignedtoahostis10011110.(itsnot10011111becauseitsnetworkbroadcastaddress)
so10011110is158indecimal.
overtomanu

http://gateoverflow.in/book

209/400

2/26/2015

GATEOverflow Book

DigitalLogictop
GATE2012_6top
Thetruthtable
X

(X,Y)

representstheBooleanfunction
(A)X
(B)X + Y
(C)X Y
(D)Y
WheneverX istrue(X, Y ) istrueandwheneverX isfalse(X, Y ) isfalse,sotheansweris(A)X .
name

GATE2012_7top
Thedecimalvalue0.5inIEEEsingleprecisionfloatingpointrepresentationhas
(A)fractionbitsof000000andexponentvalueof0
(B)fractionbitsof000000andexponentvalueof1
(C)fractionbitsof100000andexponentvalueof0
(D)noexactrepresentation
(B)istheanswer.InIEEEusesnormalizedrepresentationandhenceanimplicit'1'isusedbeforethedecimalpoint.So,ifmantissais
0000..0
itwouldbetreatedas
1.000..0
andhencetheexponentneedtobe1forustoget0.1whichisthebinaryrepresentationof0.5.
MoreintoIEEEfloatingpointrepresentation:
http://steve.hollasch.net/cgindex/coding/ieeefloat.html
gatecse

GATE2012_19top
TheamountofROMneededtoimplementa4bitmultiplieris
(A)64bits
(B)128bits
(C)1Kbits
(D)2Kbits
AROMcannotbewritten.So,toimplementa4bitmultiplierwemuststoreallthepossiblecombinationsof2 4
totalof2 4 2 4 8bits= 2048bits.So,(D)istheanswer.
name

inputbitsand8 outputbitsgivinga

tomultiplyabinarynumberwehavetodoleftshift...fordivisionrightshift....ithinkthisis
applicableonlyonlywegettheresultaspureinteger...iftheresultisfraction..thenthiswillnot
http://gateoverflow.in/book

210/400

2/26/2015

GATEOverflow Book

work....writeurcomments...plstop
Iguessyoumeantmultiplicationanddivisionbypowerof2.Formultiplicationyourquestionanswersitself,asanswerisalwaysaninteger.Fordivision,
answertoyourquestionis"yes"itwon'twork.Becausewhenweuseshiftinsteadofdivision,compilerwilljustuseshiftinstructionprovidedbytheCPU
(ifitdoes).So,letstakeIntelarchitectureandthisiswhatIntelmanualsaysforSAR(ShiftArithmeticRight)Instruction.

"UsingtheSARinstructiontoperformadivisionoperationdoesnotproducethesameresultastheIDIVinstruction.
ThequotientfromtheIDIVinstructionisroundedtowardzero,whereasthequotientoftheSARinstructionis
roundedtowardnegativeinfinity.Thisdifferenceisapparentonlyfornegativenumbers.Forexample,whenthe
IDIVinstructionisusedtodivide9by4,theresultis2witharemainderof1.IftheSARinstructionisusedto
shift9rightbytwobits,theresultis3andtheremainderis+3however,theSARinstructionstoresonlythe
mostsignificantbitoftheremainder(intheCFflag)"

So,forpositivenumbers,whenwewantonlythequotientwecansafelyuseshiftinplaceofdivisionbypowerof2.Otherwiseweshouldnotuseshift.
Reference:http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64ia32architecturessoftwaredevelopermanual325462.pdf

name

GATE1991,05,ctop
Findthemaximumclockfrequencyatwhichthecounter(giveninfigure)canbeoperated.AssumethatthepropagationdelaythrougheachflipflopandAND
gateis10ns.AlsoassumethatthesetuptimefortheJKinputsoftheflipflopsisnegligible.

InaJKflipfloptheoutputtoggleswhenbothJandKinputsare1.So,wemustensurethatwitheachclocktheoutputfromthepreviousstagereachesthe
currentstage.Fromthefigure,thereisanANDgatebetweeneachstageand2 10 = 20ns (10nsforoutputtoreachthegateand10nsfortheoutputof
ANDgatetoreachthenextflipflop)isneededfortheoutputtoreachthenextstage.So,minimumtimeperiodneededforofclockis20nswhichwouldmean
amaximumclockfrequencyof
1/20GH z = 50M H z

name

GATE2008_6top

Letr denotenumbersystemradix.Theonlyvalue(s)ofr thatsatisfytheequation121r

= 11

,is/are

(A)decimal10
(B)decimal11
(C)decimal10and11
(D)anyvalue>2

Checkbysubstitutingalltheoptionsgivensatisfiesaboverelation.(D)isthemostappropriateanswer
http://gateoverflow.in/book

211/400

2/26/2015

GATEOverflow Book

name

GATE2008_8top

answerC
withANDgateswewillchooseintersectionofminterms
withORgateswewilltakeunionofminterms
name

GATE2008_26top

Ansis(A)P Q

(P + Q )(P Q + P R)(P R + Q )

= (P P Q + P P R + P Q + P Q R)(P R + Q )

= (P Q + P R + P Q + P Q R)(P R + Q )

= P Q + P QR + P QR


= P Q + P Q (R + R)

= PQ + PQ

= PQ

name

GATE1991_01,iiitop

Hexrepresentationofgivenno.is(9753)16
Itsbinaryrepresentationis(1001011101010011)2
Theno.of1'sis9
name

GATE1992_01,itop
http://gateoverflow.in/book

212/400

2/26/2015

GATEOverflow Book

answerABC+B'C'+A'C'[EDIT]
expandthisKmapof2variables(4cells)toKmapofthreevariable(8cells)
entrieswhicharenonzeroareA'B'C',AB'C',A'BC'andABC
minimizeSOPexpressionusingthatKmap
name

GATE1992_02,itop

answerD
name

GATE2000_1.6top
Thenumber43in2'scomplementrepresentationis
A.
B.
C.
D.

01010101
11010101
00101011
10101011

2'scomplementrepresentationisnotsameas2'scomplementofanumber.In2'scomplementrepresentationpositiveintegersarerepresentedinitsnormal
binaryformwhilenegativenumbersarerepresentedinits2'scomplementform.So(c)iscorrecthere.
http://www.ele.uri.edu/courses/ele447/proj_pages/divid/twos.html
name

GATE2000_2.14top
ConsiderthevaluesofA=2.0x1030 ,B=2.0x1030 ,C=1.0,andthesequence
X:= A + B
X:= X + C

Y:= A + C
Y:= Y + B

executedonacomputerwherefloatingpointnumbersarerepresentedwith32bits.ThevaluesforXandYwillbe

a. X=1.0,Y=1.0
b. X=1.0,Y=0.0
c. X=0.0,Y=1.0
d. X=0.0,Y=0.0

Given32bitsrepresentation.So,themaximumprecisioncanbe32bits(In32bitIEEErepresentation,maximumprecisionis24bitsbutwetakebestcase
here).Thismeansapproximately10digits.
A=2.0*1030,C=1.0
So,A+Cshouldmakethe31stdigitto1,whichissurelyoutsidetheprecisionlevelofA.So,thisadditionwilljustreturnthevalueofAwhichwillbe
assignedtoY.
So,Y+Bwillreturn0.0whileX+Cwillreturn1.0.
Bchoice.
Sampleprogramifanyonewantstotry:
http://gateoverflow.in/book

213/400

2/26/2015

GATEOverflow Book

#include<stdio.h>
int main()
{
float a = 2.0e30;
float b = -2.0e30;
float c = 1.0;
float y = a+c;
printf("a = %0.25f y = %0.25f\n",a, y);
y = y + b;
float x = a + b;
printf("x = %0.25f\n",x);
x = x + c;
printf("x = %0.25f\n",x);
}

name

GATE2001_1.11top
Giventhefollowingkarnaughmap,whichoneofthefollowingrepresentstheminimalSumOfProductsofthemap?

(A)XY

+ Y

(B)W X
(C)W

+ XY + XZ

X + Y

(D)XZ

Z + XY

+ Y

answerA
name

GATE20012.10top
The2'scomplementrepresentationof(539)10inhexadecimalis
(a)ABE
(b)DBC
(c)DE5
(d)9E7

539=512+16+8+2+1=29+24+23+21+20
=(1000011011)2
Nowallanswershave12bits,soweaddtwo0'satbeginning=(001000011011)2
Toconvertto2'scomplementinvertallbitstilltherightmost1,whichwillbe(110111100101)2
=(110111100101)2
=(DE5)16

name

GATE2001_2.12top
ConsiderthecircuitgivenbelowwithinitialstateQ0

http://gateoverflow.in/book

= 1, Q 1 = Q 2 = 0

.Thestateofthecircuitisgivenbythevalue4Q2

+ 2Q 1 + Q 0

214/400

2/26/2015

GATEOverflow Book

Whichoneofthefollowingiscorrectstatesequenceofthecircuit?

A.
B.
C.
D.

1,3,4,6,7,5,2
1,2,5,3,7,6,4
1,2,7,3,5,6,4
1,6,5,7,2,3,4

Q1=Q0prev

Q0=Q1prevQ2prev

Q2=Q1prev

1
0

0
1

0
0

1
1
1
0
0
1

0
1
1
1
0
0

1
0
1
1
1
0

State=4Q2+2Q1+Q0
So,statesequence=1,2,5,3,7,6,4
name

GATE2002_2.1top
Considerthefollowinglogiccircuitwhoseinputsarefunctionsf 1 , f 2 , f 3 andoutputisf

Giventhat
f 1 (x, y, z) = (0, 1, 3, 5)
f 2 (x, y, z) = (6, 7),

and

f (x, y, z) = (1, 4, 5).


f3

is

A. (1, 4, 5)
B. (6, 7)
C. (0, 1, 3, 5)
D. Noneoftheabove

f=((f1f2)'f3')'=f1f2+f3
Inminimumsumofproductsform,ANDoftwoexpressionswillcontainthecommonterms.Sincef1andf2don'thaveanycommonterm,f1f2is0andhence
f=f3=(1,4,5)
http://gateoverflow.in/book

215/400

2/26/2015

GATEOverflow Book

name

GATE2009_5top

AnswerisB.

name

GATE2005_16top

answerA
name

GATE2005_17top
Thehexadecimalrepresentationof6578is:
(a)1AF
(b)D78
(c)D71
(d)32F

6578=(110101111)2=(1[1010][1111])2=(1AF)16
name

GATE2005_64top

http://gateoverflow.in/book

216/400

2/26/2015

GATEOverflow Book

ClearlyQ0alternatesineveryclkcycleasQ0'isfedasinputanditisDflipflop.
Q1becomes1eitherifitsprevvalueis0,orifQ0is1.
So,thesequenceoftransitionswillbe00>11>00>(B)choice.
name

GATE2013_4top
Thesmallestintegerthatcanberepresentedbyan8bitnumberin2'scomplementformis

(A)256
(B)128
(C)127
(D)0
answerB
name

GATE2013_5top
Inthefollowingtruthtable,V=1ifandonlyiftheinputisvalid.

Inputs

Outputs

D0

D1

D2

D3

X0

X1

Whatfunctiondoesthetruthtablerepresent?
(A)Priorityencoder(B)Decoder(C)Multiplexer(D)Demultiplexer

AnswerisA.
For
http://en.wikipedia.org/wiki/Priority_encoder
name

GATE1999_2.16top

answerB
forLSBadditionwedonotneedafulladder
foradditionofsubsequentbitsweneedfulladderssincecarryfrompreviousadditionhastobefedintotheadditionoperation
http://gateoverflow.in/book

217/400

2/26/2015

GATEOverflow Book

name

GATE1999_2.17top
Zerohastworepresentationsin
A.
B.
C.
D.

Signmagnitude
2'scomplement
1'scomplement
Noneoftheabove

0and0in1'scomplementthatiswhytherangeis2^n1to2^n1
name

GATE2013_21top
WhichoneofthefollowingexpressionsdoesNOTrepresentexclusiveNORofx andy ?
(A)xy + x'y' (B)x y' (C)x' y (D)x' y'

(D)x'y'
name

GATE1998_1.13top

answerA
exoroprationdonentimes
ifnisevennumberofB'sisoddhenceitwillbecomplemented
name

GATE1998_1.14top

fornbitdataselectinput
2^n:1
for4its16:1
name

GATE20141_8top
Thebase(orradix)ofthenumbersystemsuchthatthefollowingequationholdsis____________.
312
20

= 13.1

Letxbethebaseorradixofthenumbersystem.
Theequationis:(3.x2+1.x1+2.x0)/(2.x1+0.x0)=1.x1+3.x0+1.x1
=>(3.x2+x+2)/(2.x)=x+3+1/x
http://gateoverflow.in/book

218/400

2/26/2015

GATEOverflow Book

=>(3.x2+x+2)/(2.x)=(x2+3x+1)/x
Bysolvingabovequadraticequationyouwillgetx=0andx=5
Asbaseorradixofanumbersystemcannotbezero,herex=5
vinodmits

GATE20141_45top
Considerthe4to0multiplexerwithtwoselectlinesS 1 andS 0 givenbelow

TheminimalsumofproductsformoftheBooleanexpressionfortheoutputF ofthemultiplexeris

(A)P Q + QR

+ P QR

(B)P Q + P QR

+ P QR + P Q R

(C)P QR + P QR

+ QR + P Q R

(D)P QR

S0andS1areusedtoselecttheinputtothegiventooutput.
S0

S1

0
0
1
1

Output

0
1
0
1

0
1
R
R'

So,outputbecomes1for

S 0 S 1 + S 0S 1 R + S 0S 1R

= P Q + P Q R + P QR

= P Q + P QR

= Q(P

= Q(P

+ PQ R

+ PR ) + PQ R

+ R ) + P Q R( A + A B = A + B)

= P Q + QR

+ PQ R

Option(A)
name
http://gateoverflow.in/book

219/400

2/26/2015

GATEOverflow Book

GATE20143_7top
ConsiderthefollowingmintermexpressionforF :
F (P , Q, R, S ) = 0, 2, 5, 7, 8, 10, 13, 15

Theminterms2,7,8and13are'donotcare'terms.TheminimalsumofproductsformforF is

(A)QS + Q
S

(B)Q
S

+ QS


(C)Q
RS

+ Q RS + QR S + QRS


(D)P Q
S


+ P QS + P QS + P Q S

WhileputtingthetermstoKmapthe3rdand4thcolumnsareswappedsodo3rdand4throws.So,term2isgoingto(0,3)columninsteadof(0,2),8is
goingto(3,0)insteadof(2,0)etc..

SolvingthiskmapgivesB)astheanswer.
Reference:http://www.cs.uiuc.edu/class/sp08/cs231/lectures/04Kmap.pdf
name

GATE20143_45top

TheabovesynchronoussequentialcircuitbuiltusingJKflipflopsisinitializedwithQ2 Q1 Q0

= 000 .Thestatesequenceforthiscircuitforthenext3clockcyclesis

(A)001,010,011
(B)111,110,101
(C)100,110,111
(D)100,011,001

InitialState
http://gateoverflow.in/book

Input

NextState
220/400

2/26/2015

GATEOverflow Book

Q2

Q1

Q0

J2

K2

J1

K1

J0

K0

Q2'

Q1'

Q0'

OptionC
Gate_15_isHere

GATE2011_14top
ThesimplifiedSOP(SumofProduct)fromtheBooleanexpression

(P + Q + R ). (P + Q + R). (P + Q + R )

is

(A)(P . Q + R
)

(B)(P

+ Q. R )

(C)(P . Q + R)
(D)(P . Q + R)

Karnaughmap
1

AnswerisB
name

GATE2011_15top
TheminimumnumberofD flipflopsneededtodesignamod258counteris
(A)9
(B)8
(C)512
(D)258

AnswerisA
name

GATE2010_6top
Themintermexpansionoff (P , Q, R)
(A)m 2

+ m4 + m6 + m7

(B)m 0

+ m1 + m3 + m5

(C)m 0

+ m1 + m6 + m7

http://gateoverflow.in/book

= P Q + QR + P R is

221/400

2/26/2015

GATEOverflow Book

(D)m 2

+ m3 + m4 + m5

PQ+QR'+PR'=PQR+PQR'+PQR'+P'QR'+PQR'+PQ'R'
=PQR+PQR'+P'QR'+PQ'R'(111+110+010+100)
=m7+m6+m2+m4
OptionA.
name

GATE2010_7top
Amainmemoryunitwithacapacityof4megabytesisbuiltusing1M 1bitDRAMchips.EachDRAMchiphas1Krowsofcellswith1Kcellsineachrow.Thetime
takenforasinglerefreshoperationis100nanoseconds.Thetimerequiredtoperformonerefreshoperationonallthecellsinthememoryunitis
(A)100nanoseconds
(B)100 2

10

nanoseconds

(C)100 2 20 nanoseconds
(D)3200 2

20

nanosesonds

Thereare4*8=32DRAMchipstoget4MBfrom1M 1bitchips.Now,allchipscanberefreshedinparallelsodoallcellsinarow.So,thetotaltimefor
refreshwillbenumberofrowstimestherefreshtime
= 1K 100

= 100 2

10

nanoseconds

Ref:http://www.downloads.reactivemicro.com/Public/Electronics/DRAM/DRAM%20Refresh.pdf
name

GATE2010_9top
TheBooleanexpressionoftheoutputf ofthemultiplexershownbelowis

(A)
P Q R

(B)P

Q R

(C)P

+ Q + R

+ Q + R

(D)P

f = S

R + S

S 1 0R

= Q P R + Q PR

+ S0 S

+ QP R

+ S0 S1 R

+ QP R

Doingtruthvaluesubstitution,only(B)satisfiesthis.

0
0
0

0
0
1

0
1
0

http://gateoverflow.in/book

0
1
1

P Q R

0
1
1
222/400

2/26/2015

0
1
1
1
1

GATEOverflow Book

1
0
0
1
1

1
0
1
0
1

0
1
0
0
1

0
1
0
0
1

name

GATE1997_2.1top

z x = (x y) x

+ y) x
= (x

= x
+ y + x
+ x = x
x. y

name

GATE1995_2.2top

ansc)
name

GATE1995_2.5top

AnswercanbeAandD.becauseDcanbeanything,either0or1.
Forverification,justputupthevaluesandcheckforANDORoperationsandtheiroutputs.
name

GATE1995_2.12top
Thenumberof1'sinthebinaryrepresentationof(3*4096+15*256+5*16+3)are:
(A)8
(B)9
(C)10
(D)12
3 = (11)

3 4096 = 3 (2

Similarly,15 256

12

) = (11)

= (1111)

<< 12 = (11000000000000)

<< 8 = (111100000000)

So,3 4096 + 15 256 + 5 16 + 3

and5 16

= (11111101010011)

= (101)

<< 4 = (1010000)

Numberof1's=10.
http://gateoverflow.in/book

223/400

2/26/2015

GATEOverflow Book

name

GATE1996_2.22top

Optionsforthisquestionseemwrong,itsexpressionfwillcometoA'B'C+A'BC+AB'C+ABC,thatfurthercanbeminimizedtoC.
name

Kindlyhaveatry....INcanonicalPOSformfollowingequationiswrittenas(ABC)=AB+BC+AC
(A)M(0,1,2,4)(B)M(3,5,6,7)(A)M(0,1,2,3)(A)M(4,5,6,7)top
Kindlyhaveatry....INcanonicalPOSformfollowingequationiswrittenas
F(A,B,C)=AB+BC+AC
(A)M(0,1,2,4)
(B)M(3,5,6,7)
(C)M(0,1,2,3)
(D)M(4,5,6,7)

F (A, B, C ) = AB + BC + AC

= ABC

= ABC

+ ABC + ABC + A BC + AB C + ABC

+ ABC + A BC + AB C

= m(6, 7, 3, 5)

(mmintermandMmaxterm))

= M (0, 1, 2, 4)

(proofshownbelow)

F (A, B, C ) = m(3, 5, 6, 7)

F (A, B, C ) = m(0, 1, 2, 4)

F (A, B, C ) = m 0 + m 1 + m 2 + m 4

(F ) (A, B, C ) = (m 0 + m 1 + m 2 + m 4 )

F (A, B, C ) = (m m m m 4 )

F (A, B, C ) = (M 0 M 1 M 2 M 4 )

F (A, B, C ) = M (0, 12, 4)

= (A B C )

(DeMorgan'slaw)

(Complementofamintermisitscorrespondingmaxterm,forexample,m 0
)

= A B C

and

= A + B + C = M0

Ref:http://www.cs.uiuc.edu/class/sp08/cs231/lectures/04Kmap.pdf
name

GATE2008IT_1top
AsetofBooleanconnectivesisfunctionallycompleteifallBooleanfunctionscanbesynthesizedusingthose.Whichofthefollowingsetsofconnectivesis
NOTfunctionallycomplete?
http://gateoverflow.in/book

224/400

2/26/2015

GATEOverflow Book

1)

EX-NOR

2)

implication, negation

3)

OR, negation

4)

NAND

EXNORisnotfunctionallycomplete.NORandNANDarefunctionallycompletelogicgates,OR,AND,NOTanylogicgatecanbegeneratedusingthem.
And(Implication,Negation)also
p>q=p'+q=applynegation(p+q')'=pq+p'q'=applyagainnegation=(pq)'+p'q'=(p'+q')+p'q'=p'+q'+p'q'=p'+q'=againapplynegation=(p'+q')'=pqthat's
howwegotANDlogicgate.

name

GATE2008IT_7top
ThefollowingbitpatternrepresentsafloatingpointnumberinIEEE754singleprecisionformat
110000011101000000000000000000000
Thevalueofthenumberindecimalformis

1)
2)
3)
4)

10
13
26
Noneoftheabove

Signbitis1>numberisnegative
Exponentbits10000011
Exponentisaddedwith127biasinIEEEsingleprecisionformat.So,Actualexponent=10000011127=131127=4
Mantissabits101000000000000000000000
InIEEEformat,animplied1isbeforemantissa,andhencetheactualnumberis
1.101*24
=(11010)2=26
http://steve.hollasch.net/cgindex/coding/ieeefloat.html
name

GATE2007IT_7top
WhichofthefollowinginputsequencesforacrosscoupledRSflipfloprealizedwithtwoNANDgatesmayleadtoanoscillation?
A)
B)
C)
D)

11,00
01,10
10,01
00,11
forrsflipflopwithnandgate11nochange00indeterminate..............sooptionAmaymakethesystemoscillate
aravind90

GATE2007IT_42top
(C012.25)H(10111001110.101)B=

A)
http://gateoverflow.in/book

(135103.412)o
225/400

2/26/2015

B)
C)
D)

GATEOverflow Book

(564411.412)o
(564411.205)o
(135103.205)o

(C012.25)H(10111001110.101)B
=1100000000010010.00100101
0000010111001110.10100000
=1011101001000011.10000101
=1011101001000011.100001010
=(135103.412)o
Binarysubtractionislikedecimalsubtraction:00=0,11=0,10=1,01=1with1borrow.
name

GATE2004IT_8top
WhatistheminimumnumberofNANDgatesrequiredtoimplementa2inputEXCLUSIVEORfunctionwithoutusinganyotherlogicgate?

A)
3
B)
4
C)
5
D)
6
Any2inputExclusiveORfunctioncanbeimplementedwiththe4NANDgates.
1stNANDgate:
Input:A,B
output:(AB)'
2ndNANDgate:
Input:(AB)',A
output:A'+AB
3rdNANDgate:
Input:(AB)',B
output:B'+AB
4thNANDgate:
Input:A'+AB,B'+AB
output:A'B+AB'(ExclusiveORfunction)
name

GATE2004IT_10top
WhatistheminimumsizeofROMrequiredtostorethecompletetruthtableofan8bitx8bitmultiplier?

A)
B)
C)
D)

32Kx16bits
64Kx16bits
16Kx32bits
64Kx32bits

answerB
multiplying28bitdigitswillgiveresultinmaximum16bits
totalnumberofmultiplicationspossible=28x28
http://gateoverflow.in/book

226/400

2/26/2015

GATEOverflow Book

hencespacerequired=64Kx16bits
name

GATE2004IT_42top
Usinga4bit2'scomplementarithmetic,whichofthefollowingadditionswillresultinanoverflow?
i. 1100+1100
ii. 0011+0111
iii. 1111+0111

A)
B)
C)
D)

(i)only
(ii)only
(iii)only
(i)and(iii)only

Only(ii)istheanswer.
Overflowhappensonlywhen
1. Signbitoftwoinputnumbersis0,andtheresulthassignbit1
2. Signbitoftwoinputnumbersis1,andtheresulthassignbit0.
Overflowisimportantonlyforsignedarithmeticwhilecarryisimportantonlyforunsignedarithmetic.
Acarryhappenswhenthereisacarryto(orborrowfrom)themostsignificantbit.Here,(i)and(iii)causeacarrybutonly(ii)causesoverflow.
http://teaching.idallen.com/dat2343/10f/notes/040_overflow.txt

name

GATE2004IT_44top
ThefunctionABC+ABC+ABC+ABC+ABCisequivalentto

A)
B)
C)
D)

AC+AB+AC
AB+AC+AC
AB+AC+AB
AB+AC+AB

C'
C

Kmap
A'B

A'B'
0
1

0
1

AB
1
0

AB'
1
1

So,theequivalentexpressionwillbeA'C+AC'+AB'
(B)option
name

GATE2005IT_9top
A dynamic RAM has a memory cycle time of 64 nsec. It has to be refreshed 100 times per msec and each refresh takes 100 nsec. What percentage of the
memorycycletimeisusedforrefreshing?
A.
B.
C.
D.

10
6.4
1
0.64

Ans:C)1

http://gateoverflow.in/book

227/400

2/26/2015

GATEOverflow Book

name

GATE2005IT_10top
Atwowayswitchhasthreeterminalsa,bandc.InONposition(logicvalue1),aisconnectedtob,andinOFFposition,aisconnectedtoc.Twoofthesetwo
wayswitchesS1andS2areconnectedtoabulbasshownbelow.

Whichofthefollowingexpressions,iftrue,willalwaysresultinthelightingofthebulb?

A. S 1.S
2
B. S 1 + S 2

C.
S1 S2
D. S 1 S 2

Ifit'slookedcarefully,bulbwillbeonwhenbothswitchs1ands2areinsamestate,eitherofforon.thatisexnoroperation
http://gateoverflow.in/book

228/400

2/26/2015

GATEOverflow Book

S1S2Bulb
00On
01Off
10Off
11On
it'sExNORoperationhence(C)isthecorrectoption.
name

GATE2005IT_11top
Howmanypulsesareneededtochangethecontentsofa8bitupcounterfrom10101100to00100111(rightmostbitistheLSB)?

A.
B.
C.
D.

134
133
124
123

D.123Pulses.
Asina2^8Countertherangewouldbefrom0255.Hencetogofrom10101100(172)to00100111(39),thecounterhastogoinitiallyfrom172to255and
thenfrom0to39.
Hencetogofrom172to255,255172=83Clockpulseswouldberequired.thenfrom255to0,again1clockpulsewouldberequired.Thenfrom0to39,
39clockpulseswouldberequired.Henceintotal83+1+39=123Clockpulseswouldberequired.
name

GATE2005IT_47top
(34.4)8(23.4)8evaluatesto

A)

(1053.6)8

B)

(1053.2)8

C)
D)

(1024.2)8
Noneofthese

SimplyConvert34.4and23.4todecimal.Wecandothisbythismethod:
34.4=28.5indecimaland23.4=19.5indecimal.
Multiplying28.5x19.5=555.75

http://gateoverflow.in/book

229/400

2/26/2015

GATEOverflow Book

Nowconvert555.75backtooctalwhichis1053.6.
name

Letf(x,y,z)=x'+y'x+xzbeaswitchingfunction.Whichoneofthefollowingisvalid?top
Letf(x,y,z)=x'+y'x+xzbeaswitchingfunction.Whichoneofthefollowingisvalid?
1.y'xisaprimeimplicantoff.
2xzisamintermoff.
3.xzisanimplicantoff
4yisaprimeimplicantoff

xzisanimplicantand~YisbothprimeandessentialprimeimplicantandthatisitappearsintheSOP....thesopwouldbeZ+~X+~Y
http://gateoverflow.in/book

230/400

2/26/2015

GATEOverflow Book

name

whichoneisnotselfcomplemetrycodetop

Selfcomplementingcodeisacodewhereinsumofweightsis9.ExceptforD,allotheroptionshavesumofweights=9
name

GATE2015_7feb2ndtop
MinimumnumberofJKFlipFlipneededtogenerate0011223300...?
Thepattercanbegeneratedbyamod8countersotheansweris3.
name

GATE20151_20top
Considera4bitJohnsoncounterwithaninitialvalueof0000.Thecountingsequenceofthiscounteris
A.
B.
C.
D.

0,1,3,7,15,14,12,8,0
0,1,3,5,7,9,11,13,15,0
0,2,4,6,8,10,12,14,0
0,8,12,14,15,7,3,1,0

optionD
00000
10008
110012
andsoon.
http://en.wikipedia.org/wiki/Ring_counter
GATERush

GATE20152_48top
AhalfadderisimplementedwithXORandANDgates.AfulladderisimplementedwithtwohalfaddersandoneORgate.ThepropagationdelayofanXOR
gateistwicethatofanAND/ORgate.ThepropagationdelayofanAND/ORgateis1.2milliseconds.A4bitripplecarrybinaryadderisimplementedbyusing
fourfulladders.Thetotalpropagationtimeofthis4bitbinaryadderinmicrosecondsis______.
Ansis12us

Ittookmeawhilebuthere'showitis:
Thefirstcarryandsumwillbeavailableafter4.8us.Thisshouldbestraightforward.
However,forthesubsequentstages,youneedtokeepinmindthattheoutputofhalfaddersisalreadythereat2.4us.Soinasense,itisalreadycomputed.
Theremaininghalfadderforeachfulladderisjustwaitingforthepreviouscarry,whichwhenavailablefromthepreviousstagecanbeprocessedin2.4us.
Soeachnextstagewilltakeonly2.4useach.
Thecatchhereisthathalfoftheoutputineachnextstageisalreadycomputed,onlyhalfneedstobeprocessed.
name

GATE20151_37top
ApositiveedgetriggeredDflipflopisconnectedtoapositiveedgetriggeredJKflipflopasfollows.TheQoutputoftheDflipflopisconnectedtoboththeJ
andKinputsoftheJKflipflop,whiletheQoutputoftheJKflipflopisconnectedtotheinputoftheDflipflop.Initially,theoutputoftheDflipflopissetto
logiconeandtheoutputoftheJKflipflopiscleared.Whichoneofthefollowingisthebitsequence(includingtheinitialstate)generatedattheQoutputofthe
JKflipflopwhentheflipflopsareconnectedtoafreerunningcommonclock?AssumethatJ=K=1isthetogglemodeandJ=K=0isthestateholding
modeoftheJKflipflops.Boththeflipflopshavenonzeropropagationdelays.
http://gateoverflow.in/book

231/400

2/26/2015

A.
B.
C.
D.

GATEOverflow Book

0110110...
0100100...
011101110...
011001100...
Qprev

0
1
1
0
1

1
0
1
1
0
1

Q
0
1
1
0
1
1

DflipflopoutputsitsinputandJKflipflopoutputtogglesitsoutputwhen1isgiventobothJandKinputs.
Q=Dprev(Qprev')+(Dprev')Qprev
name

GATE20153_35top
Considertheequation(43) x

= (y3)

wherex andy areunknown.Thenumberofpossiblesolutionsis_____

(43)x=(y3)8
Fromthisequationitisclearxshouldbegreaterthan4andyshouldbelessthan8
x>=5,andy<=7
nowconvertthisexpressionindecimalno
4*x+3=y*8+3,ie4x=8y
x=2y.and(x>=5,y<=7)andx,yshouldbeinteger.
x=6,y=3
x=8,y=4
x=10,y=5
x=12,y=6
x=14,y=7..soIamgetting5possiblevalues
name

GATE20153_43top
Thetotalnumberofprimeimplicantsofthefunctionf (w, x, y, z)

= (0, 2, 4, 5, 6, 10)

is__________.

(CanbesolvedusingKMapalso.)
Placeallmintermsthatevaluatetooneinamintermtable.
Input(firstcolumnforno.of1's)
0
1
2

m0
m2
m4
m5
m6
m10

0000
0010
0100
0101
0110
1010

Combinemintermswithotherminterms.Iftwotermsvarybyonlyasingledigitchanging,thatdigitcanbereplacedwithadashindicatingthatthedigit
doesn'tmatter.Termsthatcan'tbecombinedanymorearemarkedwitha"*".WhengoingfromSize2toSize4,treat''asathirdbitvalue.Forinstance,
110and100or11canbecombined,but110and011cannot.(Trick:Matchupthe''first.)
FirstComparison
0

(2,0)
(4,0)
(6,2)

http://gateoverflow.in/book

000
000
010
232/400

2/26/2015

GATEOverflow Book

(10,2)
(5,4)
(6,4)

010
010
010

SecondComparison
0

(6,4,2,0)

00

PrimeImplicants
(6,4,2,0)
(10,2)
(5,4)

00
010
010

Answer:Totalnumberofprimeimplicants
Source:FindingprimeimplicantsQuineMcCluskeyalgorithmWikipedia
name

GATE20153_44top
GiventhefunctionF

= P

+ QR

,whereF isafunctioninthreeBooleanvariablesP , QandR andP

=!P

,considerthefollowingstatements.

(S 1)F = (4, 5, 6)

(S 2)F = (0, 1, 2, 3, 7)

(S 3)F = (4, 5, 6)

(S 4)F = (0, 1, 2, 3, 7)

Whichofthefollowingistrue?

A.
B.
C.
D.

(S1)False,(S2)True,(S3)True,(S4)False
(S1)True,(S2)False,(S3)False,(S4)True
(S1)False,(S2)False,(S3)True,(S4)True
(S1)True,(S2)True,(S3)False,(S4)False

F=P+QR,drawtheKmapforthis
wecanfindtheminterm(0,1,2,3,7)
and maxterm(4,5,6)

(S1)False,(S2)True,(S3)True,(S4)False

so option A is correct ...

name

http://gateoverflow.in/book

233/400

2/26/2015

GATEOverflow Book

IS&SoftwareEngg.top
GATE2009_50top

ans:b)2and3
In1,itshouldbe"path"andnot"circuit".
name

GATE20141_18top
Matchthefollowing:
1)Waterfallmodel

a)Specificationscanbe
developedincrementally

2)Evolutionarymodel

b)Requirementscompromisesare
inevitable

3)Componentbasedsoftware
engineering

c)Explicitrecognitionofrisk

4)Spiraldevelopment

d)Inflexiblepartitioningoftheprojectinto
stages

(A)1a,2b,3c,4d
(B)1d,2a,3b,4c
(C)1d,2b,3a,4c
(D)1c,2a,3b,4d

Ansis(B)
name

GATE20143_19top
Inthecontextofmodularsoftwaredesign,whichoneofthefollowingcombinationsisdesirable?
(A)Highcohesionandhighcoupling
(B)Highcohesionandlowcoupling
(C)Lowcohesionandhighcoupling
(D)Lowcohesionandlowcoupling

(B)Highcohesionandlowcoupling
(Idealsoftwaredesignrequireslessinteractionbetweenmodulessothatanymodulecanbeeasilymodified/replacedastherequirementschange)

name

GATE2011_7top
Acompanyneedstodevelopadigitalsignalprocessingsoftwareforoneofitsnewestinventions.Thesoftwareisexpectedtohave40000linesofcode.Thecompany
needstodeterminetheeffortinpersonmonthsneededtodevelopthissoftwareusingthebasicCOCOMOmodel.Themultiplicativefactorforthismodelisgivenas
2.8forthesoftwaredevelopmentonembeddedsystems,whiletheexponentiationfactorisgivenas1.20.Whatistheestimatedeffortinpersonmonths?
(A)234.25

http://gateoverflow.in/book

234/400

2/26/2015

GATEOverflow Book

(B)932.50
(C)287.80
(D)122.40

kLOC=40000/1000=40
EffortApplied(E)=2.8(40)^1.2[personmonths]
=234.22

name

GATE2011_10top
WhichoneofthefollowingisNOTdesiredinagoodSoftwareRequirementSpecifications(SRS)document?
(A)FunctionalRequirements
(B)NonFunctionalRequirements
(C)GoalsofImplementation
(D)AlgorithmforSoftwareImplementation

Algorithmsforsoftwareimplementationmaynotberequiredatrequirementphase.theyarerequiredatlaterstageslikedesignanddevelopment
name

GATE2010_21top
ThecyclomaticcomplexityofeachofthemodulesAandBshownbelowis10.Whatisthecyclomaticcomplexityofthesequentialintegrationshownontherighthand
side?

(A)19
(B)21
(C)20
(D)10

CyclomaticComplexityofmodule=Numberofdecisionpoints+1
NumberofdecisionpointsinA=101=9
NumberofdecisionpointsinB=101=9
CyclomaticComplexityoftheintegration=Numberofdecisionpoints+1
=(9+9)+1
=19
name

GATE2010_22top
Whatistheappropriatepairingofitemsinthetwocolumnslistingvariousactivitiesencounteredinasoftwarelifecycle?
P.RequirementsCapture1.ModuleDevelopmentandIntegration
Q.Design2.DomainAnalysis
R.Implementation3.StructuralandBehavioralModeling
http://gateoverflow.in/book

235/400

2/26/2015

GATEOverflow Book

S.Maintenance4.PerformanceTuning
(A)P3Q2R4S1
(B)P2Q3R1S4
(C)P3Q2R1S4
(D)P2Q3R4S1

Bisthecorrectanswer
name

GATE2010_44top
Thefollowingprogramistobetestedforstatementcoverage:
begin
if (a==b) {S1; exit;}
else if (c==d) {S2;}
else {S3; exit;}
S4;
end

ThetestcasesT1,T2,T3andT4givenbelowareexpressedintermsofthepropertiessatisfiedbythevaluesofvariablesa,
notgiven.

b, c

andd .Theexactvaluesare

T1:a,b,canddareallequal
T2:a,b,canddarealldistinct
T3:a=bandc!=d
T4:a!=bandc=d
WhichofthetestsuitesgivenbelowensurescoverageofstatementsS1,S2,S3andS4?
(A)T1,T2,T3
(B)T2,T4
(C)T3,T4
(D)T1,T2,T4
T1coversS1
T2coversS3
T3coversS1
T4coversS2,S4
soinordertocoverall4eitherT1,T2,T4orT2,T3,T4
optionD
name

GATE2008IT_60top
Whichofthefollowingrequirementspecificationscanbevalidated?
(S1)Ifthesystemfailsduringanyoperation,thereshouldnotbeanylossofdata
(S2)Thesystemmustprovidereasonableperformanceevenundermaximumloadconditions
(S3)ThesoftwareexecutablemustbedeployableunderMSWindows95,2000andXP
(S4)Userinterfacewindowsmustfitonastandardmonitor'sscreen

1)
2)
3)
4)

S4andS3
S4andS2
S3andS1
S2andS1
3rdiscorrect,asnotspecifiedwhatstandardsizeofmonitoris,andfor2nd,reasonableperformancecannotbemeasuredspecifically.
name

http://gateoverflow.in/book

236/400

2/26/2015

GATEOverflow Book

GATE2006IT_16top
Thecyclomaticcomplexityoftheflowgraphofaprogramprovides

A)
B)
C)
D)

anupperboundforthenumberofteststhatmustbeconductedtoensurethatallstatementshavebeenexecutedatmostonce
alowerboundforthenumberofteststhatmustbeconductedtoensurethatallstatementshavebeenexecutedatmostonce
anupperboundforthenumberofteststhatmustbeconductedtoensurethatallstatementshavebeenexecutedatleastonce
alowerboundforthenumberofteststhatmustbeconductedtoensurethatallstatementshavebeenexecutedatleastonce
itsCaseachedgemustbevisitedatleastoncethat'swhyweusecyclomaticcomplexitytodeterminethenumberofindependentpaths.
nagendra

GATE2006IT_17top
Withrespecttosoftwaretesting,consideraflowgraphGwithoneconnectedcomponent.LetEbethenumberofedges,Nbethenumberofnodes,andPbethe
numberofpredicatenodesofG.Considerthefollowingfourexpressions:
I. EN+P
II. EN+2
III. P+2
IV. P+1
ThecyclomaticcomplexityofGisgivenby

A)
B)
C)
D)

IorIII
IIorIII
IIorIV
IorIV
ansc)
name

GATE2004IT_69top
Considerthefollowingprogrammodule:
int module1 (int x, int y) {
while (x! = y) {
if (x > y)
x = x - y,
else y = y - x;
}
return x;
}

WhatisCyclomaticcomplexityoftheabovemodule?

A)
B)
C)
D)

1
2
3
4
answerC
Thereare2decisionpointsinthismodule
1.whileconditionand
2.ifcondition
hencecyclomaticcomplexity=numberofdecisionpoints+1=3
name

GATE2004IT_70top
AssumethatthedeliveredlinesofcodeLofasoftwareisrelatedtotheeffortEinpersonmonthsanddurationtincalendarmonthsbytherelationLP*(E/B)1/3
http://gateoverflow.in/book

237/400

2/26/2015

GATEOverflow Book

*t4/3,wherePandBaretwoconstantsforthesoftwareprocessandskillsfactor.Forasoftwareproject,theeffortwasestimatedtobe20personmonthsandthe
durationwasestimatedtobe8months.However,thecustomeraskedtheprojectteamtocompletethesoftwareprojectin4months.Whatwouldbetherequired
effortinpersonmonths?

A)
B)
C)
D)

10
40
160
320

P*(E1/B)1/3*t14/3=P*(E2/B)1/3*t24/3
E1=20personmonths
t1=8months
t2=4months
OncalculationwegetE2=321.44personmonths(Disthenearestoption)

name

GATE2004IT_71top
Asoftwarewastestedusingtheerrorseedingstrategyinwhich20errorswereseededinthecode.Whenthecodewastestedusingthecompletetestsuite,16of
theseedederrorsweredetected.Thesametestsuitealsodetected200nonseedederrors.Whatistheestimatednumberofundetectederrorsinthecodeafterthis
testing?

1)
4
2)
50
3)
200
4)
250

estimated no of undetected errors in the code after testing=n(S-s)/s=200*(20-16)/16=50...


n=no of defects be found by testing
S=total no of seeded errors
s=defects found during testing
name

GATE2004IT_72top
Whatistheavailabilityofasoftwarewiththefollowingreliabilityfigures?
MeanTimeBetweenFailure(MTBF)=25days
MeanTimeToRepair(MTTR)=6hours

A)
B)
C)
D)

1%
24%
99%
99.009%
Availability=MTBF/(MTBF+MTTR)*100
=25*24/(25*24+6)*100
=99.009%
name

GATE20151_1top
Matchthefollowing:
(P)ConditionCoverage(i)Blackboxtesting
(Q)Equivalenceclasspartitioning(ii)Systemtesting
http://gateoverflow.in/book

238/400

2/26/2015

GATEOverflow Book

(R)Volumetesting(iii)Whiteboxtesting
(S)Alphatesting(iv)Performancetesting
A.
B.
C.
D.

Pii,Qiii,Ri,Siv
Piii,Qiv,Rii,Si
Piii,Qi,Riv,Sii
Piii,Qi,Rii,Siv

C)Piii,Qi,Riv,Sii
Ref:https://en.wikipedia.org/wiki/Software_testing
piyushhurpade

GATE20152_4top
Asoftwarerequirementsspecification(SRS)documentshouldavoiddiscussingwhichoneofthefollowing?

A.
B.
C.
D.

Userinterfaceissues
Nonfunctionalrequirements
Designspecification
Interfaceswiththirdpartysoftware

AnsC

name

GATE20152_12top
ConsiderthebasicCOCOMOmodelwhereE istheeffortappliedinpersonmonths,D isthedevelopmenttimeinchronologicalmonths,K LOC isthe
estimatednumberofdeliveredlinesofcode(inthousands)andab , bb , c b , db havetheirusefulmeanings.ThebasicCOCOMOequationsareoftheform

A.
B.
C.
D.

E = ab (K LOC )exp(bb ), D = c b (E)exp(d b )


D = ab (K LOC )exp(bb ), E = c b (D)exp(d b )
E = ab exp(bb ), D = c b (K LOC )exp(d b )
E = ab exp(d b ), D = c b (K LOC )exp(bb )

Answer:A
InbasicCOCOMOmodel,
EffortApplied,E=a*(KLOC)b
DevelopmentTime,D=c*Ed
PeopleRequired,P=E/D
whereKLOC=Estimatednumberofdeliveredlinesinthousandsanda,b,c,ddependsuponthesoftwarebeingOrganic,SemidetachedorEmbedded.
http://www.mhhe.com/engcs/compsci/pressman/information/olc/COCOMO.html
name

GATE20152_43top
Whichoneofthefollowingassertionsconcerningcodeinspectionandcodewalkthroughistrue?

A. Codeinspectioniscarriedoutoncethecodehasbeenunittested
B. Codeinspectionandcodewalkthrougharesynonyms
C. Adherencetocodingstandardsischeckedduringcodeinspection
http://gateoverflow.in/book

239/400

2/26/2015

GATEOverflow Book

D. Codewalkthroughisusuallycarriedoutbyanindependenttestteam

c.
Unittestingisnotnecessarybeforecodeinspection.Codewalkthroughisdonebyamemberofdevelopmentteaminpresenceofreviewers.So,aanddare
false.
http://nptel.ac.in/courses/106105087/pdf/m10L23.pdf
http://www.tutorialspoint.com/software_testing_dictionary/code_inspection.htm
name

GATE20151_42top
ConsiderthefollowingCprogramsegment.
while (first <= last)
{
if (array[middle] < search)
first = middle + 1;
else if (array[middle] == search)
found = TRUE;
else last = middle - 1;
middle = (first + last)/2;
}
if (first > last) notpresent = TRUE;

Thecyclomaticcomplexityoftheprogramsegmentis_______________.

Numberofpredicates=4,if,elseif,whileandif.
Cyclomaticcomplexity=No.ofpredicates+1=5.
name

GATE20153_11top
Considerasoftwareprogramthatisartificiallyseededwith100faults.Whiletestingthisprogram,159faultsaredetected,outofwhich75faultsarefromthose
artificiallyseededfaults.Assumingthatbothrealandseededfaultsareofsamenatureandhavesamedistribution,theestimatednumberofundetectedrealfaults
is_______.
Answer:28
Explanation:
75%offaultsaredetectedbecause75artificiallyseededfaultsaredetectedoutof100.
Noofdetectedrealfaults=15975=84
Hencenoofrealfaults=(84)*100/75
=112
Thereforeundetectedrealfaults=11284=28.
Accordingtoaceacademysolution:175
overtomanu

GATE20153_21top
Considerasoftwareprojectwiththefollowinginformationdomaincharacteristicsforcalculationoffunctionpointmetric.
Numberofexternalinputs(I)=30
Numberofexternaloutputs(O)=60
Numberofexternalinquiries(E)=23
Numberoffiles(F)=08
Numberofexternalinterfaces(N)=02
ItisgiventhatthecomplexityweightingfactorsforI,O,E,FandNare4,5,4,10and7,respectively.Itisalsogiventhat,outoffourteenvalueadjustment
factorsthatinfluencethedevelopmenteffort,fourfactorsarenotapplicable,eachoftheotherfourfactorshavevalue3,andeachoftheremainingfactorshave
value4.Thecomputedvalueoffunctionpointmetricis_________.
http://gateoverflow.in/book

240/400

2/26/2015

GATEOverflow Book

Ans:612.06
FP=UAF*VAF
UAF=30*4+60*5+23*4+08*10+02*7=606
VAF=0.65+[4*3+6*4]/100=1.01
So,FP=606*1.01=612.06
calculationscanbedonehere:http://groups.engin.umd.umich.edu/CIS/course.des/cis525/js/f00/artan/functionpoints.htm
Fortheorypartseethis:http://www.softwaremetrics.com/fpafund.htm

ashwinianand

GATE20153_55top
Considerthefollowingsoftwareitems:ProgramX ,ControlFlowDiagramofProgramY andControlFlowDiagramofProgramZ asshownbelow

ThevaluesofMcCabe'sCyclomaticcomplexityofprogramX ,programY ,andprogramZ respectivelyare

A.
B.
C.
D.

4,4,7
3,4,7
4,4,8
4,3,8

cyclomaticcomplexity=noofpredicatenodes+1
Noofpredicatenodes=decisionmakingnodes
soforprogramX,noofpredicatenodes=3(if,while,if)
cyclomaticcomplexityofprogramX=3+1=4
ForprogramY,noofpredicatenodes=3(node3,node6,node8)
cyclomaticcomplexityforprogramY=3+1=4
ForprogramZ,noofpredicatenodes=6(3ofXfollowedby3ofY)
cyclomaticcomplexityofZ=6+1=7
http://gateoverflow.in/book

241/400

2/26/2015

GATEOverflow Book

name

http://gateoverflow.in/book

242/400

2/26/2015

GATEOverflow Book

WebTechnologiestop
GATE2009_20top

Thetabledescriptionisforthebelowtable:

So,answerwillbe(2,3,2)and(2,3,2)
name

GATE20142_28top
AgraphicalHTMLbrowserresidentatanetworkclientmachineQ accessesastaticHTMLwebpagefromaHTTPserverS .ThestaticHTMLpagehasexactlyone
staticembeddedimagewhichisalsoatS .Assumingnocaching,whichoneofthefollowingiscorrectabouttheHTMLwebpageloading(includingtheembedded
image)?

(A)Q needstosendatleast2HTTPrequeststoS ,eachnecessarilyinaseparateTCPconnectiontoserverS


(B)Q needstosendatleast2HTTPrequeststoS ,butasingleTCPconnectiontoserverS issufficient
(C)AsingleHTTPrequestfromQ toS issufficient,andasingleTCPconnectionbetweenQ andS isnecessaryforthis
(D)AsingleHTTPrequestfromQ toS issufficient,andthisispossiblewithoutanyTCPconnectionbetweenQ andS

AseparateHTMLrequestmustbesendforeachimageorcomponentinHTMLlikecssfileofjs.Butallcanbedoneinsameconnection.So,(B)isthe
answer.
name

GATE2011_9top
HTML(HyperTextMarkupLanguage)haslanguageelementwhichpermitcertainactionsotherthandescribingthestructureofthewebdocument.Whichoneofthe
followingactionsisNOTsupportedbypureHTML(withoutanyserverorclientsidescripting)pages?
(A)Embedwebobjectsfromdifferentsitesintothesamepage
(B)Refreshthepageautomaticallyafteraspecifiedinterval
(C)Automaticallyredirecttoanotherpageupondownload
(D)Displaytheclienttimeaspartofthepage

IthinkDisthecorrectanswer,todisplaythesystemtimehelpofanyscriptinglanguagelikeJavaScript,Jscriptetc..isrequiredthatcannotbedoneusing
pureHTML.
name

GATE2010_16top
Whichoneofthefollowingisnotaclientserverapplication?

http://gateoverflow.in/book

243/400

2/26/2015

GATEOverflow Book

(A)Internetchat
(B)Webbrowsing
(C)Email
(D)Ping

pingisautilitytotestwhetheranodeisreachableinthenetwork
itisnotclientserver.allotherapplicationareclientserver
name

GATE2004IT_24top
WhichoneofthefollowingstatementsisFALSE?

A)
B)
C)
D)

HTTPrunsoverTCP
HTTPdescribesthestructureofwebpages
HTTPallowsinformationtobestoredinaURL
HTTPcanbeusedtotestthevalidityofahypertextlink
Bisfalse,HTTPisprotocol,whichhasnorelationswiththestructureofawebpage.WebpagestructureisgivenusingHTML.
name

GATE2004IT_90top
GivenbelowareseveralusagesoftheanchortaginHTML.
I. <A HREF = "http://www.gate.ac.in/HTML/BASIC/testpage.html">Test Me</A>
II. <A HREF = "/BASIC/testpage.html">Test Me</A>
III. <A HREF = "testpage.html">Test Me</A>
IV. <A HREF = "testpage.html#test">Test Me</A>
Whichoftheabovearevalid?

A)
B)
C)
D)

IandIIonly
IandIIIonly
I,IIandIIIonly
I,II,IIIandIV
D)allarevalidrfc3986.
I.ForabsoluteURL
II.ForrelativeURLstartingfromwebsiteroot
III.ForrelativeURLstartingfromthecurrentpagelocation
IV.ForrelativeURLstartingfromthecurrentpagelocationandthengoingto"test"partoftheloadedpage
name

GATE2005IT_30top
AHTMLformistobedesignedtoenablepurchaseofofficestationery.Requireditemsaretobeselected(checked).Creditcarddetailsaretobeenteredand
thenthesubmitbuttonistobepressed.Whichoneofthefollowingoptionswouldbeappropriateforsendingthedatatotheserver.Assumethatsecurityis
handledinawaythatistransparenttotheformdesign.

A)
B)
C)
D)

OnlyGET
OnlyPOST
EitherofGETorPOST
NeitherGETnorPOST

http://gateoverflow.in/book

244/400

2/26/2015

GATEOverflow Book

Refer:http://www.w3schools.com/tags/ref_httpmethods.asp
sincecreditcardinfoisalsosubmittedPOSTisrecommended
name

GATE20152_13top
WhichofthefollowingstatementsisNOTcorrectaboutHTTPcookies?

A.
B.
C.
D.

AcookieisapieceofcodethathasthepotentialtocompromisethesecurityofanInternetuser
Acookiegainsentrytotheuser'sworkareathroughanHTTPheader
Acookiehasanexpirydateandtime
Cookiescanbeusedtotrackthebrowsingpatternofauserataparticularsite

ItisB.
ForreferenceyoucanhavealookattheHTTPheaderhere.
http://en.wikipedia.org/wiki/List_of_HTTP_header_fields
name

GATE20151_15
top
Whichofthefollowingstatementis/areFALSE?
I. XMLovercomesthelimitationsinHTMLtosupportastructuredwayoforganizingcontent.
II. XMLspecificationisnotcasesensitivewhileHTMLspecificationiscasesensitive.
III. XMLsupportsuserdefinedtagswhileHTMLusespredefinedtags.
IV. XMLtagsneednotbeclosedwhileHTMLtagsmustbeclosed.

A.
B.
C.
D.

only
only
IIandIVonly
IIIandIVonly

optionc
GATERush

GATE20153_8top
Inawebserver,tenWebPagesarestoredwiththeURLsoftheformhttp://www.yourname.com/var.htmlwherevarisadifferentnumberfrom1to10foreach
Webpage.SupposetheclientstorestheWebpagewithvar=1(sayW1)inthelocalmachine,editsandthentests.RestoftheWebpagesremainsontheweb
server.W1containsseveralrelativeURLsoftheform"var.html"referringtotheotherWebpages.Whichoneofthefollowingstatementsneedstobeaddedin
W1,sothatalltherelativeURLsinW1refertotheappropriateWebpagesonthewebserver?

A.
B.
C.
D.

<ahref:"http://www.yourname.com/",href:"...var.html">
<basehref:"http://www.yourname.com/">
<ahref:"http://www.yourname.com/">
<basehref:"http://www.yourname.com/",range:"...var.html">

Bchoice.
http://www.w3schools.com/tags/tag_base.asp
name

http://gateoverflow.in/book

245/400

2/26/2015

GATEOverflow Book

VerbalAbilitytop
GATE20141_GA_1top
Whichofthefollowingoptionsistheclosestinmeaningtothephraseinboldinthe
sentencebelow?
Itisfascinatingtoseelifeforms**copewith**variedenvironmentalconditions.
(A)Adoptto(B)Adaptto(C)Adeptin(D)Acceptwith
AnswerisAdaptto.Oftenseeninnewspaper"Indianplayerscouldn'tadapttoforeignconditions".
Adoptmeanslegallytakecareof.Alsomeanstotakeupanduseasin"Headoptedmypointofview."
Adeptinmeanssmartin.Example"Sachinisadeptinbatting."
name

GATE20141_GA_2top
Choosethemostappropriatewordfromtheoptionsgivenbelowtocompletethefollowingsentence.
Hecouldnotunderstandthejudgesawardingherthefirstprize,becausehethoughtthatherperformancewasquite_________.
A.superb
B.medium
C.mediocre
D.exhilarating
C.Mediocremeaningnotverygood,notuptopar,average.Herperformancewasaverageandnotworthyof1stprize.
name

GATE20141_GA_3top
Inapressmeetontherecentscam,theministersaid,"Thebuckstopshere".Whatdidtheministerconveybythestatement?
A.Hewantsallthemoney
B.Hewillreturnthemoney
C.Hewillassumefinalresponsibility
D.Hewillresistallenquiries

C.Thebuckstopshereisatermmeaningtoputanendtosomething,notcontinue,stopit.
(idiomatic)Astatementthatnoexcuseswillbemade,thatthespeakerisgoingtotakedirectresponsibilityformatters,ratherthanpasstheresponsibilitytohigherauthorities.

name

GATE20141_GA_6top
ThePalghatGap(orPalakkadGap),aregionabout30kmwideinthesouthernpartoftheWesternGhatsinIndia,islowerthanthehillyterraintoitsnorthand
south.Theexactreasonsfortheformationofthisgaparenotclear.ItresultsintheneighbouringregionsofTamilNadugettingmorerainfallfromtheSouth
WestmonsoonandtheneighbouringregionsofKeralahavinghighersummertemperatures.
Whatcanbeinferredfromthispassage?
Selectone:
A.ThePalghatgapiscausedbyhighrainfallandhightemperaturesinsouthernTamilNaduandKerala
B.TheregionsinTamilNaduandKeralathatarenearthePalghatGaparelowlying
C.ThelowterrainofthePalghatGaphasasignificantimpactonweatherpatternsinneighbouringpartsofTamilNaduandKerala
D.HighersummertemperaturesresultinhigherrainfallnearthePalghatGaparea

http://gateoverflow.in/book

246/400

2/26/2015

GATEOverflow Book

TheanswerisC.TheprimarystatementisaboutthePalghatGapbeinglowlyingwhichismentionedinthefirstsentence.Thesecondpartmentionsthe
resultsofthatcausinglotsofrainandunusualtemperaturesintheotherareas.(TamilNaduandKerala)
name

GATE20141_GA_7top
Geneticistssaythattheyareveryclosetoconfirmingthegeneticrootsofpsychiatricillnessessuchasdepressionandschizophrenia,andconsequently,that
doctorswillbeabletoeradicatethesediseasesthroughearlyidentificationandgenetherapy.
Onwhichofthefollowingassumptionsdoesthestatementaboverely?
Selectone:
A.Strategiesarenowavailableforeliminatingpsychiatricillnesses
B.Certainpsychiatricillnesseshaveageneticbasis
C.Allhumandiseasescanbetracedbacktogenesandhowtheyareexpressed
D.Inthefuture,geneticswillbecometheonlyrelevantfieldforidentifyingpsychiatricillnesses

Biscorrect,Thefirstsentencementionstwospecificillnesses,(depressionandschizophrenia).Bistheonlyonethatmentionscertainillnesses.
Astatesstrategiesarenowavailable.Thestatementsaystheyareveryclosesoitsnotyetavailable.
CstatesthatALLhumandiseasescanbetracedback.Thestatementonlymentionstwospecificillnesses.

Dthestatementdoesnotmentionatallthatitistheonlyrelevantfield.
name

GATE2013_56top
Whichoneofthefollowingoptionsistheclosestinmeaningtothewordgivenbelow?
Nadir
(A)Highest(B)Lowest(C)Medium(D)Integration
B,thelowestpoint
name

GATE2013_57top
Completethesentence:
Universalismistoparticularismasdiffusenessisto_______________.
(A)specificity(B)neutrality(C)generality(D)adaptation

A...Specificity.Thisisaskingforopposites.
Specificity

Diffuseness

Direct,tothepoint,purposefulin
relating
Precise,blunt,definitiveand
transparent
Principlesandconsistentmoralstands
independentofthepersonbeing
addressed

Indirect,circuitous,seemingly
"aimless"formsofrelating
Evasive,tactful,ambiguous,even
opaque
Highlysituationalmoralitydepending
uponthepersonandcontext
encountered

name

GATE2013_59top
Wereyouabird,you___________________inthesky.
http://gateoverflow.in/book

247/400

2/26/2015

GATEOverflow Book

(A)wouldfly(B)shallfly(C)shouldfly(D)shallhaveflown
A...wouldfly
name

GATE2013_60top
ChoosethegrammaticallyINCORRECTsentence:
(A)HeisofAsianorigin.
(B)TheybelongedtoAfrica.
(C)SheisanEuropean.
(D)TheymigratedfromIndiatoAustralia.

C.Shouldbe...SheisaEuropean
"Thesoundofaword'sfirstletterdetermineswhichtouse.Ifthewordstartswithavowelsound,youshouldusean.Ifitstartswithaconsonantsound,youshould
usea."
The word "European" does not start with a vowel sound, it starts with the syllable "you". The "y"-sound is in this case a consonant (or at least a halfconsonant), so the indefinite article is "a".

name

GATE2013_63top
Afterseveraldefeatsinwars,RobertBrucewentinexileandwantedtocommitsuicide.Justbeforecommittingsuicide,hecameacrossaspiderattempting
tirelesslytohaveitsnet.Timeandagain,thespiderfailedbutthatdidnotdeterittorefrainfrommakingattempts.SuchattemptsbythespidermadeBruce
curious.Thus,Brucestartedobservingthenearimpossiblegoalofthespidertohavethenet.Ultimately,thespidersucceededinhavingitsnetdespiteseveral
failures.SuchactofthespiderencouragedBrucenottocommitsuicide.Andthen,Brucewentbackagainandwonmanyabattle,andtherestishistory.
Whichoneofthefollowingassertionsisbestsupportedbytheaboveinformation?
(A)Failureisthepillarofsuccess.
(B)Honestyisthebestpolicy.
(C)Lifebeginsandendswithadventures.
(D)Noadversityjustifiesgivinguphope.
Dismyanswer.Hegaveuphopeandwantedtocommitsuicideuntilhesawthespiderinhisstrugglessonostruggleordifficultyisworthgivinguphope.
Continueon!
name

GATE20142_GA_1top
Choosethemostappropriatephrasefromtheoptionsgivenbelowtocompletethefollowingsentence.
Indiaisapostcolonialcountrybecause
(A)itwasaformerBritishcolony
(B)IndianInformationTechnologyprofessionalshavecolonizedtheworld
(C)Indiadoesnotfollowanycolonialpractices
(D)Indiahashelpedothercountriesgainfreedom

AnsisA
name

GATE20142_GA_3top
Matchthecolumns.
Column1Column2
1)eradicateP)misrepresent
2)distortQ)soakcompletely

http://gateoverflow.in/book

248/400

2/26/2015

GATEOverflow Book

3)saturateR)use
4)utilizeS)destroyutterly

(A)1:S,2:P,3:Q,4:R
(B)1:P,2:Q,3:R,4:S
(C)1:Q,2:R,3:S,4:P
(D)1:S,2:P,3:R,4:Q

AnswerisA
name

GATE20142_GA_6top
TheoldcityofKoenigsberg,whichhadaGermanmajoritypopulationbeforeWorldWar2,isnowcalledKaliningrad.Aftertheeventsofthewar,Kaliningradisnowa
RussianterritoryandhasapredominantlyRussianpopulation.ItisborderedbytheBalticSeaonthenorthandthecountriesofPolandtothesouthandwestand
Lithuaniatotheeastrespectively.Whichofthestatementsbelowcanbeinferredfromthispassage?

(A)KaliningradwashistoricallyRussianinitsethnicmakeup
(B)KaliningradisapartofRussiadespiteitnotbeingcontiguouswiththerestofRussia
(C)KoenigsbergwasrenamedKaliningrad,asthatwasitsoriginalRussianname
(D)PolandandLithuaniaareontheroutefromKaliningradtotherestofRussia

AnswerisB.
chetna

GATE20142_GA_7top
Thenumberofpeoplediagnosedwithdenguefever(contractedfromthebiteofamosquito)innorthIndiaistwicethenumberdiagnosedlastyear.Municipal
authoritieshaveconcludedthatmeasurestocontrolthemosquitopopulationhavefailedinthisregion.
Whichoneofthefollowingstatements,iftrue,doesnotcontradictthisconclusion?
(A)Ahighproportionoftheaffectedpopulationhasreturnedfromneighbouringcountrieswheredengueisprevalent
(B)MorecasesofdenguearenowreportedbecauseofanincreaseintheMunicipalOffice'sadministrativeefficiency
(C)Manymorecasesofdenguearebeingdiagnosedthisyearsincetheintroductionofanewandeffectivediagnostictest
(D)Thenumberofpeoplewithmalarialfever(alsocontractedfrommosquitobites)hasincreasedthisyear

AnswershouldbeD)

name

GATE20143_GA_1top
Whiletryingtocollectanenvelopefromunderthetable,Mr.Xfelldownand
IIIIII
waslosingconsciousness.
IV
WhichoneoftheaboveunderlinedpartsofthesentenceisNOTappropriate?
(A)I
(B)II
(C)III

http://gateoverflow.in/book

249/400

2/26/2015

GATEOverflow Book
(D)IV

AnswerD)
Whiletryingtocollectanenvelopefromunderthetable,Mr.Xfelldownandwaslosingconsciousness.
A:Mr.Xistryingtocollectanenvelopefromunderthetable(Presentcontinuoustense)
B:Mr.Xfelldown(Simplepasttense)
C:Mr.Xwaslosingconsciousness.(Pastcontinuoustense)
WhileA,BandC
WhatiswrongistheusageofsentencesBandCtogether.
"We use the pastcontinuoustense with the simplepasttense when we want to show that one thing happened in the middle of another thing."
eg-Iwastakingabathandthetelephonerang.

Hereitsays..
"Mr.Xfelldownandwaslosingconsciousness."
i.eBisdone..andCstarts.Whereastheusagesays..CshouldhavehappenedinthemiddleofB.
ItshouldhavebeenMr.Xfelldownandlostconsciousness.
Sourcehttp://www.5minuteenglish.com/nov12.htm
name

GATE20143_GA_2top
Ifshe_______________howtocalibratetheinstrument,she_______________donetheexperiment.
(A)knows,willhave
(B)knew,had
(C)hadknown,couldhave
(D)shouldhaveknown,wouldhave

Toanswertheseinormallyusethelanguage(evenenglishitself)iamfluentin.
OptionC)makesperfectsense,restdonotrelatetoeachother.
name

GATE20143_GA_3top
Choosethewordthatisoppositeinmeaningtothewordcoherent.
(A)sticky
(B)wellconnected
(C)rambling
(D)friendly

C)Rambling
coherent=Logicalandclear
Rambling=Confused

name

GATE20143_GA_6top
Adanceprogrammeisscheduledfor10.00a.m.Somestudentsareparticipatingintheprogrammeandtheyneedtocomeanhourearlierthanthestartoftheevent.
Thesestudentsshouldbeaccompaniedbyaparent.Otherstudentsandparentsshouldcomeintimefortheprogramme.Theinstructionyouthinkthatisappropriate
forthisis

(A)Studentsshouldcomeat9.00a.m.andparentsshouldcomeat10.00a.m.
(B)Participatingstudentsshouldcomeat9.00a.m.accompaniedbyaparent,andotherparentsandstudentsshouldcomeby10.00a.m.

http://gateoverflow.in/book

250/400

2/26/2015

GATEOverflow Book

(C)Studentswhoarenotparticipatingshouldcomeby10.00a.m.andtheyshouldnotbringtheirparents.Participatingstudentsshouldcomeat9.00a.m.
(D)Participatingstudentsshouldcomebefore9.00a.m.Parentswhoaccompanythemshouldcomeat9.00a.m.Allothersshouldcomeat10.00a.m.

ItwillbeB.
name

GATE20143_GA_7top
Bythebeginningofthe 20th century,severalhypotheseswerebeingproposed,suggestingaparadigmshiftinourunderstandingoftheuniverse.However,the
clinchingevidencewasprovidedbyexperimentalmeasurementsofthepositionofastarwhichwasdirectlybehindoursun.
Whichofthefollowinginference(s)maybedrawnfromtheabovepassage?
i. Ourunderstandingoftheuniversechangesbasedonthepositionsofstars
ii. Paradigmshiftsusuallyoccuratthebeginningofcenturies
iii. Starsareimportantobjectsintheuniverse
iv. Experimentalevidencewasimportantinconfirmingthisparadigmshift
(A)(i),(ii)and(iv)
(B)(iii)only
(C)(i)and(iv)
(D)(iv)only

Aparadigmshiftmeansafundamentalchangeinapproachorunderlyingassumptions.
Andachangeinparadigmhappensonlywhenwehaveanexperimentedevidence.Itiscrucialtohaveanevidence.
Inthisparatheevidencewasprovidedbytheexperimentalmeasurementsofthepositionofastarwhichwasdirectlybehindoursun.

OptionD)suitswellforthegivenpara.

name

GATE2011_56top
Whichofthefollowingoptionsistheclosestinthemeaningtothewordbelow:
Inexplicable
(A)Incomprehensible
(B)Indelible
(C)Inextricable
(D)Infallible

answeris(a)
Inexplicable=>difficultorimpossibletoexplain
Incomprehensible=>difficultorimpossibletounderstandorcomprehend=>Mostappropriate
Indelible=>impossibletoremove,eraseorwashaway=>Notappropriate
Inextricable=>unavoidable,inescapable=>Notappropriate
Infallible=>completelydependableortrustworthy=>irrelevant

name

GATE2012_57top
Choosethemostappropriatealternativefromtheoptionsgivenbelowtocompletethefollowingsentence:
Despiteseveralthemissionsucceededinitsattempttoresolvetheconflict.
(A)attempts
(B)setbacks
(C)meetings
(D)delegations
http://gateoverflow.in/book

251/400

2/26/2015

GATEOverflow Book

B...setbacks
name

GATE2012_58top
Whichoneofthefollowingoptionsistheclosestinmeaningtothewordgivenbelow?
Mitigate
(A)Diminish
(B)Divulge
(C)Dedicate
(D)Denote
A.Diminish
name

GATE2012_59top
ChoosethegrammaticallyINCORRECTsentence:
(A)TheygaveusthemoneybacklesstheservicechargesofThreeHundredrupees.
(B)ThiscountrysexpenditureisnotlessthanthatofBangladesh.
(C)ThecommitteeinitiallyaskedforafundingofFiftyLakhrupees,butlatersettledforalessersum.
(D)Thiscountrysexpenditureoneducationalreformsisveryless.
D...."isveryless"shouldbe"ismuchless".
name

GATE2012_60top
Choosethemostappropriatealternativefromtheoptionsgivenbelowtocompletethefollowingsentence:
Sureshsdogistheonewashurtinthestampede.
(A)that
(B)which
(C)who
(D)whom

A....that
Whoandwhomarepeople,notdogs.
Regardingthatandwhich...
RestrictiveClauseThat
Arestrictiveclauseisjustpartofasentencethatyoucan'tgetridofbecauseitspecificallyrestrictssomeotherpartofthesentence.Here'sanexample:
Gemsthatsparkleoftenelicitforgiveness.
Thewordsthatsparklerestrictthekindofgemsyou'retalkingabout.Withoutthem,themeaningofthesentencewouldchange.Withoutthem,you'dbe
sayingthatallgemselicitforgiveness,notjustthegemsthatsparkle.(Andnotethatyoudon'tneedcommasaroundthewordsthatsparkle.)
NonrestrictiveClauseWhich
Anonrestrictiveclauseissomethingthatcanbeleftoffwithoutchangingthemeaningofthesentence.Youcanthinkofanonrestrictiveclauseassimply
additionalinformation.Here'sanexample:
Diamonds,whichareexpensive,oftenelicitforgiveness.

name

GATE2012_61top
WantedTemporary,ParttimepersonsforthepostofFieldInterviewertoconductpersonalinterviewstocollectandcollateeconomicdata.
Requirements:HighSchoolpass,mustbeavailableforDay,EveningandSaturdaywork.Transportationpaid,expensesreimbursed.
Whichoneofthefollowingisthebestinferencefromtheaboveadvertisement?
http://gateoverflow.in/book

252/400

2/26/2015

GATEOverflow Book

(A)Genderdiscriminatory
(B)Xenophobic
(C)Notdesignedtomakethepostattractive
(D)Notgenderdiscriminatory

D.Notgender_discriminatory.Thepostmentions"persons"meaninganygender.

Xenophobicmeanshavingorshowinganintenseorirrationaldislikeorfearofpeoplefromothercountries,sodoesnotapply.
CandAdonotapply.

name

GATE2010_56top
Choosethemostappropriatewordfromtheoptionsgivenbelowtocompletethefollowingsentence:
Hisrathercasualremarksonpolitics________hislackofseriousnessaboutthesubject.
(A)masked
(B)belied
(C)betrayed
(D)suppressed

answerisoption(c)

(a)Masked:Hideunderafalseappearance=>opposite
(b)Belied:Beincontradictionwith=>notappropriate
(c)Betrayed:Revealunintentionally=>mostappropriate
(d)Suppressed:Toputdownbyforceorauthority=>irrelevent
name

GATE2010_57top
Whichofthefollowingoptionsistheclosestinmeaningtothewordgivenbelow:
Circuitous
(A)cyclic
(B)indirect

(C)confusing
(D)crooked

BIndirect
Synonymsforcircuitous
adjgoingaround,indirect

name

GATE2010_58top
http://gateoverflow.in/book

253/400

2/26/2015

GATEOverflow Book

Choosethemostappropriatewordfromtheoptionsgivenbelowtocompletethefollowingsentence:
Ifwemanageto__________ournaturalresources,wewouldleaveabetterplanetforourchildren.
(A)uphold
(B)restrain
(C)cherish
(D)conserve

DConserve
name

GATE2010_60top
Thequestionbelowconsistsofapairofrelatedwordsfollowedbyfourpairsofwords.Selectthepairthatbestexpressestherelationintheoriginalpair.
Unemployed:Worker
(A)fallow:land
(B)unaware:sleeper
(C)wit:jester
(D)renovated:house

A.Fallow:Land
Fallowislandthatisuncultivated
Unemployedisaworkerwithoutajob
name

GATE2010_63top
Modernwarfarehaschangedfromlargescaleclashesofarmiestosuppressionofcivilianpopulations.Chemicalagentsthatdotheirworksilently
appeartobesuitedtosuchwarfareandregretfully,thereexistpeopleinmilitaryestablishmentswhothinkthatchemicalagentsareusefultoolsfor
theircause.
Whichofthefollowingstatementsbestsumsupthemeaningoftheabovepassage:
(A)Modernwarfarehasresultedincivilstrife.
(B)Chemicalagentsareusefulinmodernwarfare.
(C)Useofchemicalagentsinwarfarewouldbeundesirable.
(D)Peopleinmilitaryestablishmentsliketousechemicalagentsinwar.

D.Peopleinmilitaryestablishmentsliketousechemicalagentsinwar.
name

Completethesentence:Dare__mistake.top
Dare__________mistake.
A.commit
B.tocommit
C.committed
D.commiting

commit.Noneedof"to"afterdarehere.
http://gateoverflow.in/book

254/400

2/26/2015

GATEOverflow Book

http://www.thefreedictionary.com/DARE
name

GATE20151_GA_1top
Didn'tyoubuy____whenyouwentshopping?
A.
B.
C.
D.

anypaper
muchpaper
nopaper
afewpaper

A]Anypaper
name

GATE20151_GA_2top
Whichofthefollowingoptionsistheclosestinmeaningofthesentencebelow?
Sheenjoyedherselfimmenselyattheparty.

A.
B.
C.
D.

Shehadaterribletimeattheparty
Shehadahorribletimeattheparty
Shehadaterrifictimeattheparty
Shehadaterrifyingtimeattheparty

C.Shehadaterrifictimeattheparty
name

GATE20151_GA_5top
Whichoneofthefollowingcombinationsisincorrect?
A.
B.
C.
D.

AcquiescenceSubmission
WheedleRoundabout
FlippancyLightness
ProfligateExtravagant

BWheedleRoundabout
name

GATE20151_GA_7top
Selectthealternativemeaningoftheunderlinedpartofthesentence.
Thechainsnatcherstooktotheirheelswhenthepolicepartyarrived.

A.
B.
C.
D.

Tookshelterinathickjungle
Openindiscriminatefire
Tooktoflight
Unconditionallysurrendered

CTooktoflight
name

GATE20151_GA_8top
Thegivenstatementisfollowedbysomecoursesofaction.Assumingthestatementtobetrue,decidethecorrectoption.
Statement:
Therehasbeenasignificantdropinthewaterlevelinthelakessupplyingwatertothecity.
http://gateoverflow.in/book

255/400

2/26/2015

GATEOverflow Book

Courseofaction:
I. Thewatersupplyauthorityshouldimposeapartialcutinsupplytotacklethesituation.
II. Thegovernmentshouldappealtoalltheresidentsthroughmassmediaforminimaluseofwater.
III. Thegovernmentshouldbanthewatersupplyinlowerareas.

A.
B.
C.
D.

StatementsIandIIfollow.
StatementsIandIIIfollow.
StatementsIIandIIIfollow.
Allthestatementsfollow.

StatementsIandIIarecorrectmeasures.OptionA,
name

GATE20152_GA_1top
We__________ourfriends'sbirthdayandwe_________howtomakeituptohim.

A.
B.
C.
D.

completelyforgotdon'tjustknow
forgotcompletelydon'tjustknow
completelyforgotjustdon'tknow
forgotcompletelyjustdon'tknow

answerisoptionc
naresh1845

GATE20152_GA_2top
Choosethestatementwhereunderlinedwordisusedcorrectly.

A.
B.
C.
D.

Theindustrialisthadapersonneljet.
Iwritemyexperienceinmypersonneldiary.
Allpersonnelarebeinggiventhedayoff.
Beingreligiousisapersonnelaspect.

Answer:C
Personnel:Peopleemployedinanorganizationorengagedinanorganizedundertakingsuchasmilitaryservice.
OptionA,B,Dshouldusethewordpersonal.

name

GATE20152_GA_4top
Agenerictermthatincludesvariousitemsofclothingsuchasaskirt,apairoftrousersandashirtis

A.
B.
C.
D.

fabric
textile
fibre
apparel

its'D'apparel
name

GATE20153_GA_2top
TheTamilversionof__________JohnAbrahamstarrerMadrasCafe__________clearedbytheCensorBoardwithnocutslastweek,butthefilm'sdistributor
_______notakersamongtheexhibitorsforareleaseinTamilnadu_______thisFriday.

http://gateoverflow.in/book

256/400

2/26/2015

A.
B.
C.
D.

GATEOverflow Book

Mr.,was,found,on
a,was,found,at
the,was,found,on
a,being,findat

answerisc
naresh1845

GATE20153_GA_3top
ExtremefocusonsyllabusansstudyingfortestshasbecomesuchadominantconcernofIndianstudentthattheyclosetheirmindstoanything___________to
therequirementsoftheexam.

A.
B.
C.
D.

related
extraneous
outside
useful

answerisb
naresh1845

GATE20153_GA_4top
Selectthepairofbestexpressesarelationshipsimilartothatexpressedinthepair:
Children:Pediatrician

A.
B.
C.
D.

Adult:Orthopaedist
Females:Gynaecologist
Kidney:Nephrologist
Skin:Dermatologist

itsB....Females:Gynaecologist
name

GATE20153_GA_6top
AlexanderturnedhisattentiontowardsIndia,sincehehadconqueredPersia.
Whichoneofthestatementsbelowislogicallyvalidandcanbeinferredfromtheabovesentence?

A.
B.
C.
D.

AlexanderwouldnothaveturnedhisattentiontowardsIndiahadhenotconqueredPersia.
Alexanderwasnotreadytorestonhislaurels,andwantedtomarchtoIndia.
AlexanderwasnotcompletelyincontrolofhisarmyandcouldcommandittomovetowardsIndia.
SinceAlexander'skingdomextendedtoIndianbordersaftertheconquestofPersia,hewaskeentomovefurther.

AnswershouldbeA......asotheroptionsrequiredmoreinformation
name

GATE20153_GA_7top
TheheadofnewlyformedgovernmentdesirestoappointfiveofthesixselectedmembersP,Q,R,S,TandUtoportfoliosofHome,Power,Defense,Telecom,
andFinance.UdoesnotwantanyportfolioifSgetsoneofthefive.RwantseitherHomeorFinanceornoportfolio.QsaysthatifSgetsPowerorTelecom,
thenshemustgettheotherone.TinsistsonaportfolioifPgetsone.
Whichisthevaliddistributionofportfolios?

A.
B.
C.
D.

PHome,QPower,RDefense,STelecom,TFinance
RHome,SPower,PDefense,QTelecom,TFinance
PHome,QPower,TDefense,STelecom,UFinance
QHome,UPower,TDefense,RTelecom,PFinance

http://gateoverflow.in/book

257/400

2/26/2015

GATEOverflow Book

"UdoesnotwantanyportfolioifSgetsoneofthefive"
So,SandUcannotcometogether.OptionCeliminated.
"RwantseitherHomeorFinanceornoportfolio"
So,optionsAandDeliminated.
So,answerisB.
Justtoconfirm:
QsaysthatifSgetsPowerorTelecom,thenshemustgettheotherone
InB,SgetsPowerandQgetsTelecom
"TinsistsonaportfolioifPgetsone"
InB,Tisgettingaportfolio.
name

GATE20153_GA_9top
Mostexpertsfeelthatinspiteofpossessingallthetechnicalskillsrequiredtobeabatsmanofthehighestorder,heisunlikelytobesoduetolackofrequisite
temperament. He was guilty of throwing away his wicket several time after working hard to lay a strong foundation. His critics pointed out that until he
addressedhisproblem,successatthehighestlevelwillcontinuetoeludehim.
Whichofthestatement(s)belowis/arelogicallyvalidandcanbeinferredfromtheabovepassage?
i. Hewasalreadyasuccessfulbatsmanatthehighestlevel.
ii. Hewastoimprovehistemperamentinordertobecomeagreatbatsman.
iii. Hefailedtomakemanyofhisgoodstartscount.
iv. Improvinghistechnicalskillswillguaranteesuccess.

A.
B.
C.
D.

iiiandiv
iiandiii
i,iiandiii
iionly

"possessingallthetechnicalskills"ivisfalse
"throwingawayhiswicketseveraltimeafterworkinghardtolayastrongfoundation"iiiistrue
"heisunlikelytobesoduetolackofrequisitetemperament"iiistrue
"successatthehighestlevelwillcontinuetoeludehim"iisfalse
So,B.
name

http://gateoverflow.in/book

258/400

2/26/2015

GATEOverflow Book

NumericalAbilitytop
GATE20141_GA_5top
Therootsofax2+bx+c=0arerealandpositive.a,bandcarereal.Thenax2+b|x|+c=0has
A.noroots
B.2realroots
C.3realroots
D.4realroots

Letthepositiverootsbemandn.Now,mandnwillalsosatisfytheequationax2+b|x|+c=0andhencewehave4roots.
name

GATE20141_GA_4top
If(z+1/z)2=98,compute(z2+1/z2).

Ans:(Z+1/Z)2=(z2+2(z)(1/z)+(1/z)2)=(z2+1/z2)+2=98==>>982=96isanswer..
name

GATE20141_GA_8top
Roundtripticketstoatouristdestinationareeligibleforadiscountof10%onthetotalfare.Inaddition,groupsof4ormoregetadiscountof5%onthetotal
fare.IftheonewaysinglepersonfareisRs100,agroupof5touristspurchasingroundtripticketswillbechargedRs__________

For individual , Round-trip discount 10% on TOTAL fare . So for each person (200 X 10%)=20 .
So for 5 member 100 rupees .
For 5 member group they will get 5% discount on TOTAL fare i.e. (5x200 X 5%)= 50 rupess.
Total discount is (100+50)=150 . They have to pay 850 rupees

name

GATE20141_GA_9top
Inasurvey,300respondentswereaskedwhethertheyownavehicleornot.Ifyes,theywerefurtheraskedtomentionwhethertheyownacarorscooterorboth.
Theirresponsesaretabulatedbelow.Whatpercentofrespondentsdonotownascooter?

Ownvehicle

Men

Women

Car

40

34

Scooter

30

20

Both

60

46

20

50

Donotownvehicle

NothavingscooterfromMen(40(carowner)+20(nothingowns))=60
NothavingscooterfromMen(34(carowner)+50(nothingowns))=84
percentage=(60+84)/300=.48i.e.48%
http://gateoverflow.in/book

259/400

2/26/2015

GATEOverflow Book

name

GATE20141_GA_10top
Whenapointinsideofatetrahedron(asolidwithfourtriangularsurfaces)isconnectedbystraightlinestoitscorners,howmany(new)internalplanesare
createdwiththeselines?

It is 6.
name

GATE2013_64top
Atouristcovershalfofhisjourneybytrainat60km/h,halfoftheremainderbybusat30km/handtherestbycycleat10km/h.Theaveragespeedofthetourist
inkm/hduringhisentirejourneyis
(A)36(B)30(C)24(D)18

letthetotaldistancebeDthen
avgspeed=D/totaltimetaken
Totaltimetaken=D/2*60+D/4*30+D/4*10
avgspeed120/5=24
name

GATE2013_65top
ThecurrenterectioncostofastructureisRs.13,200.Ifthelabourwagesperdayincreaseby1/5ofthecurrentwagesandtheworkinghoursdecreaseby1/24of
thecurrentperiod,thenthenewcostoferectioninRs.is
(A)16,500(B)15,180(C)11,000(D)10,120
Sincewagesperdayincreaseby1/5ofcurrentwages,newwagesperdaybecomes6/5ofcurrentwages.
Similarlynewworkinghoursare23/24ofcurrentworkinghours.
Sonewerectioncostbecomes13200*6/5*23/24=15180.
Sooption(B)iscorrect.
name

GATE20142_GA_4top
Whatistheaverageofallmultiplesof10from2to198?

(A)90
(B)100
(C)110
(D)120

a=10,l=190
s=n(a+l)/2=19(200)/2=1900
average=1900/19=100
ans.is100
aditi

GATE20142_GA_5top

http://gateoverflow.in/book

260/400

2/26/2015

GATEOverflow Book

Thevalueof12 + 12 + 12 + is

(A)3.464
(B)3.932
(C)4.000
(D)4.444

x = 12 + x

(x 4)(x + 3) = 0

x
name

= 12 + x

x 12 = 0

= 4orx = 3

GATE20143_GA_4top
Whichnumberdoesnotbelongintheseriesbelow?
2,5,10,17,26,37,50,64
(A)17
(B)37
(C)64
(D)26

Ifa1,a2,a3...anistheseriesandi=1ton,thentheseriesisdefinedasai=i^2+1.
i.etheithtermis1plusthesquareofi.
Serieswillbeasfollows:1^2+1,2^2+1,3^2+1,4^2+1....n^2+1
2,5,10,17,26,37,50,65
Hence64doesnotbelongtotheseries.
name

GATE20143_GA_10top
Considertheequation:(7526) 8

(Y )

= (4364)

,where(X) N standsforX tothebaseN .FindY .

(A)1634
(B)1737
(C)3142
(D)3162

C)
Thegivennumbersareinoctalrepresentation.Digitsrangefrom0to7.
Y=75264364
7526
4364
_______
3142
steps:1.(64)=2
2.(26),borrowa8.Now(8+26)=4
3.(513)=1(Subtractedby1becauseONE8wasborrowed)
4.(74)=3

http://gateoverflow.in/book

261/400

2/26/2015

GATEOverflow Book

name

GATE2011_57top
Iflog(P)
(A)P

(B)Q

(C)Q

(D)R

TRUE?

= (1/2) log(Q) = (1/3) log(R) ,thenwhichofthefollowingoptionsis


3

= Q R

= PR
3

= R P
2

= P Q

B.
FollowingLogformula,weget:
P=Q1/2=R1/3
so,Q2=P4=P.P3=PR.

name

GATE2011_62top
P,Q,RandSarefourtypesofdangerousmicrobesrecentlyfoundinahumanhabitat.Theareaofeachcirclewithitsdiameterprintedinbracketsrepresentsthe
growthofasinglemicrobesurvivinghumanimmunitysystemwithin24hoursofenteringthebody.Thedangertohumanbeingsvariesproportionatelywiththetoxicity,
potencyandgrowthattributedtoamicrobeshowninthefigurebelow:

Apharmaceuticalcompanyiscontemplatingthedevelopmentofavaccineagainstthemostdangerousmicrobe.Whichmicrobeshouldthecompanytargetinitsfirst
attempt?
(A)P
(B)Q
(C)R
(D)S

AnswerisD.
Asperthequestion,itisquiteclearthatthedangerofamicrobetohumanbeingwillbedirectlyproportionaltopotencyandgrowth.Atthesametimeitis
inverselyproportionaltotoxicity,definedas(moredangerouswillamicrobebeiflesserofitsmilligramisrequired).
So,
LevelOfDanger(D) Growth(G)
Potency(P)
http://gateoverflow.in/book

262/400

2/26/2015

GATEOverflow Book

1/ Toxicity(T)
D=KGP/T
whereKiscontantofproportionality.
SolevelofdangerwillbemaximumforS.
Givenby,
DS=0.8* (10)2/200
=1.256
SimilarCalculationsforDP,DQ,DRcanbedone.WhichwillconsequentlyleadtoDSbeingthemostdangerousandhencewillbetargetedfirst.
name

GATE2011_64top
Atransporterreceivesthesamenumberoforderseachday.Currently,hehassomependingorders(backlog)tobeshipped.Ifheuses7trucks,thenattheendofthe
4thdayhecanclearalltheorders.Alternatively,ifheusesonly3trucks,thenalltheordersareclearedattheendofthe10thday.Whatistheminimumnumberof
trucksrequiredsothattherewillbenopendingorderattheendof5thday?
(A)4
(B)5
(C)6
(D)7

Lettheamountofordersreceivedperdaybexandlettheamountofpendingordersbeyandlettheamountoforderscarriedbyatruckeachdaybez.
7z*4=4x+y>(1)
3z*10=10x+y(2)
(2)(1)=>2z=6x,z=3x,y=80x
Wewanttofindthenumberoftruckstofinishtheordersin5days.LetitbeA.
Az*5=5x+y
15Ax=5x+80x
A=85/15=17/3=5.67
So,minimum6trucksmustbeused.
name

GATE2011_65top
A container originally contains 10 litres of pure spirit. From this container 1 litre of spirit replaced with 1 litre of water. Subsequently, 1 litre of the mixture is again
replacedwith1litreofwaterandthisprocessisrepeatedonemoretime.Howmuchspiritisnowleftinthecontainer?
(A)7.58litres
(B)7.84litres
(C)7litres
(D)7.29litres

Quantityleftafternoperations=x(1y/x)^n
wherex=initialquantity
y=amountofmixturewithdrawneachtime(thisshouldbesameeverytime)
n=nooftimesoperationperformed
=10(11/10)^n=10(9/10)^3=10*.9*.9*.9=10*.729=7.29liters
henceoptionDiscorrect.
ReferenceVideo:https://www.youtube.com/watch?v=YYg23Fm3qW0
name

GATE2012_56top
http://gateoverflow.in/book

263/400

2/26/2015

GATEOverflow Book

Thecostfunctionforaproductinafirmisgivenby5q 2 ,whereq istheamountofproduction.Thefirmcanselltheproductatamarketpriceof50perunit.


Thenumberofunitstobeproducedbythefirmsuchthattheprofitismaximizedis
(A)5
(B)10
(C)15
(D)25
AnswerisA.TheequationforprofitisProfit=SPCP,hereSP=Q*50andCP=5Q^2sowhenafunctionattainsitsmaximumvalueitsfirstorder
differentiationiszero.Hence505*2*Q=0.thereforeQ=5.
kireeti

GATE2012_62top
Apoliticalpartyordersanarchfortheentrancetothegroundinwhichtheannualconventionisbeingheld.Theprofileofthearchfollowstheequation
2
y = 2x 0.1x wherey istheheightofthearchinmeters.Themaximumpossibleheightofthearchis
(A)8meters
(B)10meters
(C)12meters
(D)14meters

B.10
y=2x0.1x2
dy/dx=22*0.1x=>dy/dx=0=>x=10
soy=2010=10
name

GATE2012_63top
AnautomobileplantcontractedtobuyshockabsorbersfromtwosuppliersX andY .X supplies60%andYsupplies40%oftheshockabsorbers.Allshock
absorbersaresubjectedtoaqualitytest.Theonesthatpassthequalitytestareconsideredreliable.OfX sshockabsorbers,96%arereliable.OfY sshock
absorbers,72%arereliable.
Theprobabilitythatarandomlychosenshockabsorber,whichisfoundtobereliable,ismadebyY is
(A)0.288
(B)0.334
(C)0.667
(D)0.720
B.
Probability of Y given R =

Probability of Y and R
Probability of R

0.40.72
0.40.72+0.60.96

1
3

= 0.33

name

GATE2012_64top
WhichofthefollowingassertionsareCORRECT?
P:Adding7toeachentryinalistadds7tothemeanofthelist
Q:Adding7toeachentryinalistadds7tothestandarddeviationofthelist
R:Doublingeachentryinalistdoublesthemeanofthelist
S:Doublingeachentryinalistleavesthestandarddeviationofthelistunchanged
(A)P,Q
(B)Q,R
(C)P,R
(D)R,S
http://gateoverflow.in/book

264/400

2/26/2015

GATEOverflow Book

Supposewedoubleeachentryofalist

InitialMean(M I )
NewMean(M N )
=

2
n

n
i=1

xi

i=1

n
i=1

2x i

xi

So,wheneachentryinthelistisdoubled,meanalsogetsdoubled.

StandardDeviationI

i=1

(M I x i )

NewStandardDeviationN

i=1

(M N 2 x i )

i=1

(2 (M I x i ))

= 2 I

So,wheneachentryisdoubled,standarddeviationalsogetsdoubled.

Whenweaddaconstanttoeachelementofthelist,itgetsaddedtothemeanaswell.Thiscanbeseenfromtheformulaofmean.

Whenweaddaconstanttoeachelementofthelist,thestandarddeviation(orvariance)remainsunchanged.Thisisbecause,themeanalsogetsaddedbythe
sameconstantandhencethedeviationfromthemeanremainsthesameforeachelement.

So,herePandRarecorrect.
name

GATE2012_65top
Giventhesequenceofterms,ADCGFKJP,thenexttermis
(A)OV
(B)OW
(C)PV
(D)PW
A.OV
ADdifference2(B,C)
CGdifference3(D,E,F)
FKdifference4andJPdifference5
sonexttermwillhave6differnce
againeachtermstartswithprecedingterm's2ndlastletter
soJKLMNOP,nexttermwillstartwithOandhaving6differenceitwillbeOV
name

GATE2010_59top
25personsareinaroom.15ofthemplayhockey,17ofthemplayfootballand10ofthemplaybothhockeyandfootball.Thenthenumberofpersonsplayingneither
hockeynorfootballis:
(A)2

http://gateoverflow.in/book

265/400

2/26/2015

GATEOverflow Book

(B)17
(C)13
(D)3

D.3
eitherplayfootballorhockey=15+1710=22
numberofpersonsplayingneitherhockeynorfootballis=2522=3

name

GATE2010_61top
If137 + 276

= 435 howmuchis731 + 672?

(A)534
(B)1403
(C)1623
(D)1513

Answer.C.
(137)8+(276)8=(435)8
SobasicallythenumberaregiveninOctalbase.
Similarly,additionof731,672gives1623inoctal.
name

GATE2010_64top
5skilledworkerscanbuildawallin20days8semiskilledworkerscanbuildawallin25days10unskilledworkerscanbuildawallin30days.Ifateamhas2
skilled,6semiskilledand5unskilledworkers,howlongitwilltaketobuildthewall?
(A)20days
(B)18days
(C)16days
(D)15days

D.15days
1skilledpersoncando1/100ofworkin1day,so2skilledpersondo2/100ofworkinaday.
similarly,6semiskilledand5unskilledpersoncando6/200and5/300respectivelyin1day.
sotheydo1/15ofworktogetherin1day,whichgivesrequirednumberofdaytocompletethework=15.
name

Conditionalprobabilitytop

Onesideofthetossedcoinishead.So,oursamplespacenowhasonlytwopossiblecoinsHHandHTbutbotharenotequallyprobable.
Inoursamplespacewecanhave6possibleoutcomes:(HTmeansHeadturnsupandTailisonotherside)
HH,HH,HT,TH,TT,TTallofwhichareequallyprobable.
http://gateoverflow.in/book

266/400

2/26/2015

GATEOverflow Book

Now,Headturnsupmeanswenowhaveonly3eventsHH,HHandHTandonlyHTisfavorablefortheothersidebeingTail.So,requiredprobabilityis1/3.
name

GATE20151_GA_3
top
GivenSetA={2,3,4,5}andSetB={11,12,13,14,15},twonumbersarerandomlyselected,onefromeachset.Whatistheprobabilitythatthesumofthe
twonumbersequals16?
A.
B.
C.
D.

0.20
0.25
0.30
0.33

optionAbecausetotalcombinationis5*4=20andout20wehaveonly4combinationofwhichhavesum16
2,14
3.13
4.12
5,11
name

GATE20151_GA_4top
Basedonthegivenstatements,selectthemostappropriateoptiontosolvethegivenquestion.
Iftwofloorsinacertainbuildingare9feetapart,howmanystepsarethereinasetofstairsthatextendsfromthefirstfloortothesecondfloorofthebuilding?
Statements:
(I)Eachstepis3/4foothigh.
(II)Eachstepis1footwide.
A.
B.
C.
D.

StatementsIaloneissufficient,butstatementIIaloneisnotsufficient.
StatementsIIaloneissufficient,butstatementIaloneisnotsufficient.
Bothstatementstogetheraresufficient,butneitherstatementaloneissufficient.
StatementsIandIItogetherarenotsufficient.

A. StatementsIaloneissufficient,butstatementIIaloneisnotsufficient.
name

GATE20151_GA_6top
Thenumberofstudentsinaclasswhohaveansweredcorrectly,wrongly,ornotattemptedeachquestioninanexam,arelistedinthetablebelow.Themarksfor
eachquestionarealsolisted.Thereisnonegativeorpartialmarking.
QNo.
1
2
3
4
5

Marks
2
3
1
2
5

AnsweredCorrectly
21
15
11
23
31

AnsweredWrongly
17
27
29
18
12

NotAttempted
6
2
4
3
1

Whatistheaverageofthemarksobtainedbytheclassintheexamination?

A.
B.
C.
D.

2.290
2.970
6.795
8.795

Avg.mark=(21*2+15*3+11*1+23*2+31*5)/(21+17+6)
=(42+45+11+46+155)/44
=299/44
=6.795
http://gateoverflow.in/book

267/400

2/26/2015

GATEOverflow Book

name

GATE20151_GA_9top
Thepiechartbelowhasthebreakupofthenumberofstudentsfromdifferentdepartmentsinanengineeringcollegefortheyear2012.Theproportionofmaleto
femalestudentsineachdepartmentis5:4.Thereare40malesinElectricalEngineering.Whatisthedifferencebetweenthenumbersoffemalestudentsinthe
civildepartmentandthefemalestudentsintheMechanicaldepartment?

NumberoffemalestudentsinElectrical=40*4/5=32
NumberoffemalestudentsinCivil=32*30/20=48(Sinceproportionofmalestudentstofemalestudentsissame,thebreakupchartisthesamefornumber
offemalestudents)
NumberoffemalestudentsinMechanical=32*10/20=16
So,answer=4816=32
name

GATE20151_GA_10top
The probabilities that a student passes in mathematics, physics and chemistry are m,p and c respectively. Of these subjects, the students has 75% chance of
passinginatleastone,a50%chanceofpassinginatleasttwoanda40%chanceofpassinginexactlytwo.Followingrelationsaredrawninm,p,c:
I. p+m+c=27/20
II. p+m+c=13/20
III. (p)x(m)x(c)=1/10

A.
B.
C.
D.

OnlyrelationIistrue.
OnlyrelationIIistrue.
RelationsIIandIIIaretrue.
RelationsIandIIIaretrue.

Probabilityofnonpass=1Probabilityofatleastonepass=10.75=0.25
(1m)(1p)(1c)=0.25
(1+mpmp)(1c)=0.25
1+mpmpcmpc+mc+pc=0.25
m+p+cmppcmc+mpc=0.75(1)

Probabilityofexactly2pass=0.4
mp(1c)+pc(1m)+mc(1p)=0.4
mp+pc+mc3mpc=0.4
mp+pc+mc2mpc=0.5(2)(Addingtheprobabilityofallpasstoprobabilityofexactly2passgivesprobabilityofatleast2pass)
http://gateoverflow.in/book

268/400

2/26/2015

GATEOverflow Book

So,mpc=0.1,(3)
From(2)and(3),
mp+pc+mcmpc=0.6(4)
From(1)and(4)
m+p+c=0.75+06
m+p+c=1.35=135/100=27/20
So,Doption
name

GATE20152_GA_5top
Basedonthegivenstatements,selectthemostappropriateoptiontosolvethegivenquestion.
Whatwillbethetotalweightof10poleseachofsameweight?
Statements:
I. Onefourthoftheweightofthepoleis5Kg.
II. Thetotalweightofthesepolesis160Kgmorethanthetotalweightoftwopoles.

A.
B.
C.
D.

StatementIaloneisnotsufficient.
StatementIIaloneisnotsufficient.
EitherIorIIaloneissufficient.
BothstatementsIandIItogetherarenotsufficient.

AnsC
name

GATE20153_GA_1top
IfROADiswrittenasURDG,thenSWANshouldbewrittenas:

A.
B.
C.
D.

VXDQ
VZDQ
VZDP
UXDQ

optionB..VZDQ
(everyletterisreplacedbythirdletterinalphabeticalorder)
name

GATE20153_GA_5top
Afunctionf (x) islinearandhasavalueof29atx

= 2

and39atx

= 3

.Finditsvalueatx

= 5

A.
B.
C.
D.

59
45
43
35

f(x)islinearmeansitisoftheformax+b
givenf(2)andf(3)
solvetheequationandfindoutvalueforaandb.thenfindf(5).itwillbe43
name

GATE20153_GA_8top
Choosethemostappropriateequationforthefunctiondrawnasthickline,intheplotbelow.
http://gateoverflow.in/book

269/400

2/26/2015

GATEOverflow Book

A.
B.
C.
D.

x = y |y|
x = (y |y|)
x = y + |y|
x = (y + |y|)

Whenyis1,xis2.
Whenyispositivexis0.
So,x =
name

(y |y|)

GATE20153_GA_10top
Theexportsandimports(incroresofRs.)ofacountryfromtheyear2000to2007aregiveninthefollowingbarchart.Inwhichyearisthecombined
percentageincreaseinimportsandexportsthehighest?

2000
2001
2002
2003
2004
2005
2006
2007

Exports+Imports
90
110
130
130
150
160
220
230

Increase

20
20
0
20
10
60
10

%Increase=(Increase/Value)*100

18.18
15.38
0
13.33
6.25
27.27
4.35

So,2006.
name

http://gateoverflow.in/book

270/400

2/26/2015

GATEOverflow Book

MathematicalLogictop
GATE2012_1top
Considerthefollowinglogicalinferences.

I 1 :Ifitrainsthenthecricketmatchwillnotbeplayed.
Thecricketmatchwasplayed.
Inference:Therewasnorain.
I 2 :Ifitrainsthenthecricketmatchwillnotbeplayed.
Itdidnotrain.
Inference:Thecricketmatchwasplayed.

WhichofthefollowingisTRUE?

(A)BothI 1 andI 2 arecorrectinferences


(B)I 1 iscorrectbutI 2 isnotacorrectinference
(C)I 1 isnotcorrectbutI 2 isacorrectinference
(D)BothI 1 andI 2 arenotcorrectinferences
I 1 isacorrectinference.I 2 isnotacorrectinferenceasitwasnotmenitonedwhatwouldhavehappenedifithadn'trainedTheymayhaveplayedorthey
maynothaveplayed.
name

GATE2012_13top
Whatisthecorrecttranslationofthefollowingstatementintomathematicallogic?
Somerealnumbersarerational
(A)x(real(x) rational(x))
(B)x(real(x) rational(x))
(C)x(real(x) rational(x))
(D)x(rational(x) real(x))
Meaningofeachchoices:
(A):Thereexistsanumberwhichiseitherrealorrational
(B):Ifanumberisrealitisrational
(C):Thereexistsanumberwhichisrealandrational
(D):Thereexistsanumbersuchthatifitisrational,itisreal
So,(C)istheanswer.
name

GATE2013_47top
WhichoneofthefollowingisNOTlogicallyequivalenttox(y() z()) ?

(A)x(z()

y())

(B)x(z()

y())

(C)x(y()

z())

(D)x(y()

z())

Ausefulrule:
x() = (x)()

i.e.Ifsomepropertyistrueforallx ,thenitisequivalentotsaythatnox existssuchthatpropertydoesnotholdforit.


http://gateoverflow.in/book

271/400

2/26/2015

GATEOverflow Book

Startingwithchoices:
A:x(z()

y())

x(z() y())

x(z() y())

x(z() y())

x(z() y())

So,Aisnotmatchingwiththelogicalstatementinquestion.
B:x(z()

y())

x(z() y())

x(z() y())

x(z() y())

x(z() y())

Hencematcheswiththegivenstatement.
C.x(y()

z())

x(y() z())

x(y() z())

x(y() z())

x(y() z())

Hencematcheswiththegivenstatement.
D:x(y()

z())

x(y() z())

x(y() z())

x(y() z())

x(y() z())

x(y() z())

So,Disnotmatchingwiththelogicalstatementinquestion.
ThusbothAandDarenotlogicallyequivalenttothegivenstatement.
InGATE2013marksweregiventoallforthisquestion
name

logicaldeductiontop

Itistoldinthequestion"Ifthepeoplesuffer,thegovernmentwillbeunpopular".And"governmentwillnotbeunpopular"means,peoplewillnotsuffer.
ItislikeA>Bistrueand~Bisgiven.So,~Amustbetrue.
http://gateoverflow.in/book

272/400

2/26/2015

GATEOverflow Book

So,(a)isvalid(alwaystrue).
LetstaketheEnglishmeaning
Governmentwillnotbeunpopular

Peoplewillnotsuffer
Eithernoinflationorgovernmentregulatesit
Ifnoregulationthennoinflation
ifnoregulationthennowageorpricerise

So,(b)and(d)arevalid(alwaystrue)and(c)and(e)arenotvalid.
name

GATE1992_92,xvtop
Whichofthefollowingpredicatecalculusstatementsis/arevalid?
(1)((x))P (x) ((x))Q(x)

((x))(P (x) Q(x))

(2)((x))P (x) ((x))Q(x)

((x))(P (x) Q(x))

(3)((x))(P (x) Q(x))


(4)((x))(P (x) Q(x))

((x))P (x) ((x))Q(x)

((x))P (x) ((x))Q(x)

(1)ThecorrespondingEnglishmeaning:IfP (x) istrueforallx ,orifQ(x) istrueforallx ,thenforallx ,eitherP (x) istrueorQ(x) istrue.Thisis
alwaystrueandhencevalid.Tounderstanddeeply,considerX = {3, 6, 9, 12} .ForLHSofimplicationtobetrue,eitherP (x) mustbetrueforall
elementsinX orQ(x) mustbetrueforallelementsinX .Ineithercase,ifwetakeeachelementx inX ,eitheroneofP (x) orQ(x) willbetrue.Hence,
thisimplicationisalwaysvalid.
(Ifstillindoubt,letP (x) meanx isamultipleof3 andQ(x) meansx isamultipleof2 )
(2)ThecorrespondingEnglishmeaning:IfP (x) istrueforatleastonex ,andifQ(x) istrueforatleastonex ,thenthereisatleastonex forwhichboth
P (x) andQ(x) aretrue.ThisisnotalwaystrueasP (x) canbetrueforonex andQ(x) canbetrueforsomeotherx .Tounderstanddeeply,consider
X = {3, 6, 9, 12} .LetP (x) bex isamultipleof9 andQ(x) bex isamultipleof6 .Now,LHSofimplicationistrue,sinceP (x) istrueforx = 9 ,
andQ(x) istrueforx = 6 .ButRHSofimplicationisnottrueasthereisnox forwhichbothP (x) andQ(x) holds.Hence,thisimplicationisnotvalid.
(3)Ifthereisatleastonex forwhicheitherP (x) istrueorQ(x) istruethenP (x) istrueforallx orQ(x) istrueforallx .Justonereadisenoughto
seethisisaninvalidimplication.
(4)Ifthereisatleastonex forwhicheitherP (x) orQ(x) istruetheneitheritisnotthecasethatP (x) istrueforallx orQ(x) istrueforatleastonex .
ThisisclearlyinvalidasLHSofimplicationbecomestrueifP (x) istrueforsomex andQ(x) isnottrueforanyx ,butRHSwillbefalse.
Alittlemodificationtothestatementisenoughtomakeitvalid:
(x)(P (x) Q(x))

((x) P (x)) (x)Q(x)

whichmeansifthereisatleastonex forwhicheitherP (x) orQ(x) istruethen


eitheritisnotthecasethat P (x) istrueforallx (whichmeansP(x)istrueforsomex )orQ(x) istrueforsomex .
Note
DeMorgan'slawisapplicableinfirstorderlogicandisquiteuseful:
(x)(P (x)) (x)(P (x))

ThisisalogicalreasoningstatementwhichmeansifP (x) istrueforallx ,thentherecanneverexistanx forwhichP (x) isnottrue.Thisformulaisquite


usefulinprovingvalidityofmanystatementsasisitsconversegivenbelow:
(x)(P (x)) (x)(P (x))

gatecse

GATE2008_31top
P

andQ aretwopropositions.Whichofthefollowinglogicalexpressionsareequivalent?

I.P Q
II.(P Q)
III.(P Q) (P
IV.(P Q) (P

Q) (P Q)
Q) (P Q)

(A)OnlyIandII
http://gateoverflow.in/book

273/400

2/26/2015

GATEOverflow Book

(B)OnlyI,IIandIII
(C)OnlyI,IIandIV
(D)AllofI,II,IIIandIV
(B)OnlyI,IIandIII.Drawtruthtabletocheck,evaluatingindividualexpressionwillconsumelotoftimewithunguarantedanswer.
name

GATE2001_1.3top
Considertwowellformedformulasinpropositionallogic
F 1 : P P

F 2

: (P P ) (P P )

Whichoneofthefollowingstatementsiscorrect?
(A)F1issatisfiable,F2isvalid
(B)F1unsatisfiable,F2issatisfiable
(C)F1isunsatisfiable,F2isvalid
(D)F1andF2arebothsatisfiable
F1:P=>P
=PVP
=PcanbetruewhenPisfalse(AtleastoneThencesatisfiable)
F2:(P=>P)V(P=>P)
=PV(PVP)
=PVP
=T
VALID
OptionA
name

GATE2009_23top
Whichoneofthefollowingisthemostappropriatelogicalformulatorepresentthestatement?
"Goldandsilverornamentsareprecious".

Thefollowingnotationsareused:
isagoldornament
isasilverornament
x isprecious

G(x) : x
S (x) : x
P (x) :

(A)x(P (x) (G(x) S (x)))

(B)x((G(x) S (x)) P (x))

(C)x((G(x) S (x)) P (x))

(D)x((G(x) S (x)) P (x))

AnswerisD.

name

http://gateoverflow.in/book

274/400

2/26/2015

GATEOverflow Book

GATE2002_1.8top
"IfXthenYunlessZ"isrepresentedbywhichofthefollowingformulasinprepositionallogic?(" "isnegation," "isconjunction,and""isimplication)
A.
B.
C.
D.

(X Z ) Y
(X Y ) Z
X (Y Z )
(X Y ) Z

while(notz){
if(X)then
Y
}
or
unless(z){
if(X)then
Y
}

thisiswhatitmeansinprogramming.ifyouwanttoexecutestatementYthenXmustbeTrueandZFalse,
whichisequivalentto(XANDNOTZ)>Y
optionA
name

GATE2003_32top
Whichofthefollowingisavalidfirstorderformula?(Hereand arefirstorderformulaewithxastheironlyfreevariable)
(A)((x)[](x)[])(x)[]
(B)((x)[](x)[]
(C)((x)[](x)[])(x)[]
(D)(x)[]((x)[])(x)[])
(D)istheanswer.
(A)LetX={3,6,9,8}.Letdenotemultipleof3anddenotemultipleof4.(x)[]becomesfalseas8isnotamultipleof3,andso(x)[](x)[]
becomesTRUE.Now,thiswon'timply(x)[]asmultipleof3doesn'timplymultipleof4for3,6or9.
(B)LetX={3,6,9}.Letdenotemultipleof3anddenotemultipleof4.NowLHSisTRUEbutRHSisfalseasnoneofthexinX,isamultipleof4.
(C)LetX={3,6,9,7}.Letdenotemultipleof3anddenotemultipleof4.Now(x)[]becomesfalseandhenceLHS=((x)[](x)[])
becomestrue.ButRHSisfalseas7isnotamultipleof3.
(D)Thisisvalid.LHSissayingthatifisholdingforanyx,thenalsoholdsforthatx.RHSissayingifisholdingforallx,thenalsoholdsforallx.
ClearlyLHS RHS(butRHSdoesnotimplyLHS).
Forexample,letX={4,8,12},denotemultipleof2anddenotemultipleof4.LHS=(x)[],isTRUE.RHSisalsotrue.Ifweadd'3'toX,then
LHSistrue,firstpartofRHSbecomesfalseandthusRHSalsobecomesTRUE.ThereisnowaywecanmakeLHStrueandRHSfalsehere.Butifweadd2
and3toX,RHSwillbetrueandLHSwillbefalse.So,wecan'tsayRHSimpliesLHS.
name

GATE2003_33top
ConsiderthefollowingformulaanditstwointerpretationsI 1 andI 2 .
: (x)[Px (y)[Q xy Q yy ]] (x)[Px ]

I1

:Domain:thesetofnaturalnumbers
Px

='xisaprimenumber'
='ydividesx'

Q xy
I2

:sameasI 1 exceptthatPx ='xisacompositenumber'.

http://gateoverflow.in/book

275/400

2/26/2015

GATEOverflow Book

Whichofthefollowingstatementsistrue?
(A)I 1 satisfies,I 2 doesnot(B)I 2 satisfies,I 1 doesnot
(C)NeitherI 1 norI 2 satisfies(D)BothI 1 andI 2 satisfies
inwords:
LHSimpliesRHS,whereforI 1

LHS=Ifforallx,xisprimeifandonlyifforally,yisafactorofxifandonlyifydoesnotdivideitself.Inotherwords,forallx,ifxisprime,xcannot
haveanyfactorandifxisnothavinganyfactorthenxisprime.
RHS=Allxarenonprime
HereLHSisalwaysTRUEbutRHSisnottrueasdomainofxissetofnaturalnumbersandhencexcannotbealwaysnotprime.So,isnotsatisfiablefor
I1 .
NowforI 2 ,
LHS=Ifforallx,xiscompositeifandonlyifforally,yisafactorofxifandonlyifydoesnotdivideitself.Inotherwords,forallx,ifxiscomposite,x
cannothaveanyfactorandifxisnothavinganyfactorthenxiscomposite.
RHS=Allxarenoncomposite
Here,LHScanneverbetrue.xcaneitherbeprimeorcomposite.Ifxiscomposite,P (x) istruebuttherightsideofdoubleimplicationisfalse.Ifxis
prime,P (x) isfalse,butrightsideofdoubleimplicationistrue.So,thedoubleimplicationneverreturnsTRUEmakingLHSofalwaysFALSE.So,
becomesTRUEirrespectiveofRHSandI 2 issatisfiable.
name

GATE2010_30top
SupposethepredicateF(x,y,t)isusedtorepresentthestatementthatpersonxcanfoolpersonyattimet.whichoneofthestatementsbelowexpressesbestthe
meaningoftheformula
xyt(F (x, y, t))

?
(A)Everyonecanfoolsomepersonatsometime
(B)Noonecanfooleveryoneallthetime
(C)Everyonecannotfoolsomepersonallthetime
(D)Noonecanfoolsomepersonatsometime
Bisthecorrectanswer.thetrickisbringthenegatesigntotheextremeleft..formasentencewithouusingnegateandjustnegatethat
name

GATE2005_41top
Whatisthefirstorderpredicatecalculusstatementequivalenttothefollowing?
"Everyteacherislikedbysomestudent"
(A)(x)[teacher(x)(y)[student(y)likes(y,x)]]
(B)(x)[teacher(x)(y)[student(y)likes(y,x)]]
(C)(y)(x)[teacher(x)[student(y)likes(y,x)]]
(D)(x)[teacher(x)(y)[student(y)likes(y,x)]]

InsimplerwaywecansayIfXisateacherthenthereexistssomeYwhicharestudentsandlikesX
that'swhyit'sB
name

GATE2007_22top
LetGraph(x) beapredicatewhichdenotesthatx isagraph.LetC onnected(x) beapredicatewhichdenotesthatx isconnected.Whichofthefollowing
firstorderlogicsentencesDOESNOTrepresentthestatement:
"Noteverygraphisconnected"?

(A)x(Graph(x)

C onnected(x))

(B)x(Graph(x) C onnected(x))
(C)x(Graph(x) C onnected(x))
x(Graph(x) C onnected(x))

http://gateoverflow.in/book

276/400

2/26/2015

GATEOverflow Book

(D)x(Graph(x)

C onnected(x))

Dsays"allgraphsarenotconnected"buttheqssays"noteverygraphisconnected".i.e"thereexistsatleastonegraphwhichisnotconnected".Hencethe
answerisD
name

GATE1998_1.5top

AonlyifB=>A>B
A="Istay"
B="Yougo"
converseofA>BisB>A
"IfyougothenIstay"
A
name

GATE20141_53top
WhichoneofthefollowingpropositionallogicformulasisTRUEwhenexactlytwoofp, q andr areTRUE?
(A)((p
(B)(

q) r) (p q r)

(p q) r) (p q r)

(C)((p

q) r) (p q r)

(D)(

(p q) r) (p q r)

IthinkBshouldbetruebecause
A.willbetrueifP,Q,Raretrue,((pq)r) will return true
C. if r is only true and p and q are false, first part itself will result in true
D. if r is false will always return in false so r should always be true

name

GATE20143_1top
Considerthefollowingstatements:
P:Goodmobilephonesarenotcheap
Q:Cheapmobilephonesarenotgood

L:PimpliesQ
M:QimpliesP
N:PisequivalenttoQ
WhichoneofthefollowingaboutL,M,andNisCORRECT?
(A)OnlyLisTRUE.

http://gateoverflow.in/book

277/400

2/26/2015

GATEOverflow Book
(B)OnlyMisTRUE.
(C)OnlyNisTRUE.
(D)L,MandNareTRUE.

D)
Letsbreakthegivencompoundstatementsintoatomicstatements.
A:Goodmobilephones.
B:Cheapmobilephones.

P:A>~B<=>~Av~B
Q:B>~A<=>~Bv~A<=>~Av~B(Disjunctioniscommutative)
HenceP<=>Q(PisequivalenttoQ,whichmeansPimplesQ,andQimpliesP)
name

GATE20143_53top
TheCORRECTformulaforthesentence,"notallRainydaysareCold"is
(A)d(Rainy(d) ~Cold(d))
(B)d(~Rainy(d)

Cold(d))

(C)d(~Rainy(d)

Cold(d))

(D)(Rainy(d) ~Cold(d))

Notallrainydaysarecold.
Inotherwordsitsays"Somerainydaysarecold"or"Somerainydaysarenotcold"

Givenstatementis
~Vd[R(d)>C(d)]
<=>~Vd[~R(d)VC(d)]
<=>d[R(d)^~C(d)]
D)

name

GATE1997_3.2top

C)POR(P>Q)=POR(NOTPORQ)
=(PORNOTP)ORQAssociativityrule
=TORQ
=T
name

GATE1993_8.2top

OPTION(B)
name

http://gateoverflow.in/book

278/400

2/26/2015

GATEOverflow Book

GATE1994_3.13top

p
0
0
1
1

q
0
1
0
1

p<=>q
1
0
0
1

p>~q
1
1
1
0

~[(p<=>q)=>(p>~q)]
0
0
0
1

So,"doesnotimply"isdefinitelyFALSE.
name

GATE1996_2.3top

OPTIOND...whenx=F&y=F
name

GATE2008IT_22top
Whichofthefollowingisthenegationof[x,(y,(u,v,y))]

A. [x,(y,(u,v,y))]
B. [x,(y,(u,v,y))]
C. [x,(y,(u,v,y))]
D. [x,(y,(u,v,y))]

[x,(y,(u,v,y))]=[x,v(y,v(u,v,y))]
Now,doingcomplementgives(complementofisandviceversawhilepropagatingnegationinwardsasx(P)=x(P)andx(P)
=x(P))
[x,(y,(u,v,y))]
Dchoice

name

GATE2006IT_21top
ConsiderthefollowingfirstorderlogicformulainwhichRisabinaryrelationsymbol.
xy(R(x,y)=>R(y,x))
Theformulais

A)
B)
C)
D)

satisfiableandvalid
satisfiableandsoisitsnegation
unsatisfiablebutitsnegationisvalid
satisfiablebutitsnegationisunsatisfiable
Thegivenrelationisnothingbutsymmetry.Wehavebothsymmetricrelationspossibleaswellasantisymmetricbutneitheralwaysholdsforallsets.So

http://gateoverflow.in/book

279/400

2/26/2015

GATEOverflow Book

theybotharenotvalidbutaresatisfiable.Boption.
name

Assumethefollowingpredicateandconstantsymbols:top
Assumethefollowingpredicateandconstantsymbols:
W(x,y):xwrotey
L(x,y):xislongerthany
N(x):xisanovel
a:Amith:Harshal
Whichofthefollowingpredicatelogicformularepresentsthesentence:
"HarshalwroteanovelwhichislongerthananyoftheAmit'snovels"
A.
B.
C.
D.

xy(L(x, y) W (x, y) W (a, x))

L(x, y))
N (y) W (a, y) L(x, y))
x(N (x) W (h, x) y(N (y) W (a, y) L(x, y)))
xy(W (h, x) W (a, y)
xy(N (x) W (h, x)

(A)Foreverybookifthereexistsashorterbook,thenharshalhaswrittentheshorteroneandamitthelongerone.
(B)EverybookwrittenbyHarshalislongerthaneverybookwrittenbyAmit.
(C)ThereexistsanxsuchthatifxisanovelwrittenbyHarshal,thenallnovelswrittenbyAmitareshorterthanx.
(D)ThereexistsanxsuchthatxisanovelwrittenbyHarshalandallnovelswrittenbyAmitareshorterthanx.
So,(D)istheanswer
name

Usequantifierstoexpress:>Thereisexactlyonepersonwhomeverybodylovestop
LetL(x,y)bethestatement"xlovesy,"wherethedo
mainforbothxandyconsistsofallpeopleintheworld.
Usequantifierstoexpress:
Q>Thereisexactlyonepersonwhomeverybodyloves.
Esome||Aforall||
Answer>Ex(AyL(y,x)^Az((AwL(w,z))>z=x))
Cananyoneexplaintheanswerandhowtosolvethesequestions
imeanhowtoanalyzethesequestions??

Firstofallwehaveonlytwoquantifiersexistsandforall.So,firsttrytoconvertthegivensentenceintoasentencecontainingthose(itsjustEnglish)
Thereisexactlyonepersonwhomeverybodyloves
Thiscanberewrittenas
Thereissomeonewhoislovedbyeveryone,andthereisnooneelsewhoislovedbyeveryone
Againtranslatedas:
Thereissomeone,x,whoislovedbyeveryone,andifthereisanotherone,y,whoislovedbyeveryoneelse,meansxandyarethesameperson.
Thiscanbetranslatedintofirstorderlogic(firstorderlogicisjustpropositionallogicwithand)
x(y(y,x)(z(w(w,x))(z=x)))
(Inthegivenanswerinquestionzisusedinplaceofzwhichiswrong)
Hereactuallyinplaceofw,wecanuseyasthelifeofyexpiresimmediatelyaftery(y,x)this.Usingwinsteadofyisstrictlynotneeded.
Youcanalsotrytoexpress"Thereisatmostonepersonwhomeverybodyloves"
Now,thetranslationsIdidisbasedonmyknowledgeabouttheexpressivepowersoffirstorderlogic.Thatsisfirstorderlogiccan'tbeusedforallstatement
formswefirstneedtoconvertitintoasuitableform.Luckilythereareonlyafewcases,whichyouwillgetexperiencedbysolvingpreviousyearquestions
inthistopic.Youcanseethebelow3questionsandtheyshouldcoveralmostanytypeofquestionfromthistopic.
http://gateoverflow.in/256/gate1992_92xv
http://gateoverflow.in/923/gate2003_33
http://gateoverflow.in/922/gate2003_32
http://gateoverflow.in/book

280/400

2/26/2015

GATEOverflow Book

name

GATE2002_5btop
Determinewhethereachofthefollowingisatautology,acontradiction,orneither(" "isdisjunction," "isconjunction,""isimplication," "isnegation,
and""isbiconditional(ifandonlyif).

A.
B.
C.

A (A A)
(A B) B
A ((A B))

ThiscanbesolvedbyTruthtable.Butthereissomethingelsewhichcanbedonequickly.Seewhateachformulameans:
1.A(AA)ItsaysifAthen(AorA)andif(AorA)thenA.Alwaysatautology
2.(AB)BIfAorBthenB.NoguaranteethatifonlyAistrue,Bneedtobetrue.Henceneithertautologynorcontradiction
3.A((AB))WhenAistrue(AB)willbefalse.So,thisformulaisacontradiction
name

Commenton(R,*)group/commutative/monoidtop
Whichofthefollowingtrueabout(R,*)?
1)Groupbutnotcommutative
2)Acommutativegroup
3)Notasemigroup
4)Notamonoid
Itsamonoid.
Closure,associativity,IdentityaredefinedforRealnumbers.ButinverseisnotdefinedasRcanbezeroalso.So(R,*)isneitherGroupnor
Abelian(commutative),butMonoid.
name

Whichofthefollowingisatautology?top

P>Q=~PQ
~Q>~P=Q~P
Hence,Discorrect.
Cchoiceisambiguous.Wecan'tsayitisatautologyunlessweknowtheassociativityof>andtheprecedenceofand>
((P>Q)(Q>R))>(P>R)

http://gateoverflow.in/book

281/400

2/26/2015

GATEOverflow Book

Thisisatautology.
name

Howmanysolutionsaretheretotheequationx+y+z=17?Theyarenonnegativeintegerstop
Howmanysolutionsaretheretotheequationx+y+z=17 ?They are non-negative integers
A)120B)171C)180D)121
No.ofsolutionstotheequationx+y+z=17isgivenbyformula
C(n+r1,n1)=C(3+171,31)=C(19,2)=171
Ans(B)
name

GATE20152_3top
Considerthefollowingtwostatements.
S1:Ifacandidateisknowntobecorrupt,thenhewillnotbeelected
S2:Ifacandidateiskind,hewillbeelected
WhichoneofthefollowingstatementsfollowsfromS1andS2aspersoundinferencerulesoflogic?

A.
B.
C.
D.

Ifapersonisknowntobecorrupt,heiskind
Ifapersonisnotknowntobecorrupt,heisnotkind
Ifapersoniskind,heisnotknowntobecorrupt
Ifapersonisnotkind,heisnotknowntobecorrupt

optionc...Ifapersoniskind,heisnotknowntobecorrupt
name

GATE20151_14
top
WhichoneofthefollowingisNOTequivalenttopq?
A.
B.
C.
D.

(pq)(pq)
(pq)(qp)
(pq)(pq)
(pq)(pq)

pq
=(pq)(qp)
=(pq)(qp)(Aspq=pq)
=(pq)(qp)
=(pq)(pq)
So,answerC
Priya_das

GATE20153_24top
Inaroomthereareonlytwotypesofpeople,namelyType1andType2.Type1peoplealwaystellthetruthandType2peoplealwayslie.Yougiveafaircoin
toapersoninthatroom,withoutknowingwhichtypeheisfromandtellhimtotossitandhidetheresultfromyoutillyouaskforit.Uponaskingtheperson
repliesthefollowing
"TheresultofthetossisheadifandonlyifIamtellingthetruth"
Whichofthefollowingoptionsiscorrect?

A. Theresultishead
B. Theresultistail
C. IfthepersonisofType2,thentheresultistail
http://gateoverflow.in/book

282/400

2/26/2015

GATEOverflow Book

D. IfthepersonisofType1,thentheresultistail
whateverType2personsaysshouldbefalse.
SoifResultishead,thenthestatement"TheresultofthetossisheadifandonlyifIamtellingthetruth"isfalseisconsistentwithlying.
SoithinkanswerisA
ifapersonisType2weknowhelying>heisnottellingtruth>Resultishead
overtomanu

http://gateoverflow.in/book

283/400

2/26/2015

GATEOverflow Book

Probabilitytop
GATE2013_2top
Supposep isthenumberofcarsperminutepassingthroughacertainroadjunctionbetween5PMand6PM,andp hasaPoissondistributionwithmean3 .
Whatistheprobabilityofobservingfewerthan3carsduringanygivenminuteinthisinterval?
(A)8/(2e3 )
(B)9/(2e3 )
(C)17/(2e3 )
(D)26/(2e3 )
PoissonProbabilityDensityFunction(withmean)=
Wehavetosumtheprobabilitydensityfunctionfork

/(e

= 0, 1

k!)

and2 and=3(thusfindingthecumulativemassfunction)

=(1/e3 ) + (3/e3 ) + (9/2e3 )


=17/(2e3 )
name

randomvariableX

+ Y

> 1 top

accordingtomeitshouldbe4Pi
EDIT:(4Pi)/4....istheanswer
name

GATE2008_27top
Aishwaryastudieseithercomputerscienceormathematicseveryday.Ifshestudiescomputerscienceonaday,thentheprobabilitythatshestudiesmathematics
thenextdayis0.6.Ifshestudiesmathematicsonaday,thentheprobabilitythatshestudiescomputersciencethenextdayis0.4.GiventhatAishwaryastudies
computerscienceonMonday,whatistheprobabilitythatshestudiescomputerscienceonWednesday?
(A)0.24(B)0.36(C)0.4(D)0.6
answerC
probofstudyingCSonTue=0.4
probofstudyingCSonWedgiventhatitwasstudiedonTue=0.4x0.4=0.16
probofstudyingMathonTue=0.6
probofstudyingCSonWedgiventhatMathwasstudiedonTue=0.6x0.4=0.24
prob=0.16+0.24=0.4
name

GATE2000_1.1top
Theminimumnumberofcardstobedealtfromanarbitrarilyshuffleddeckof52cardstoguaranteethatthreecardsarefromsamesuitis
(a)3(b)8(c)9(d)12

http://gateoverflow.in/book

284/400

2/26/2015

GATEOverflow Book

Thereare4setsofcards.So,uptill8cardsthereisachancethatnomorethan2cardsarefromagivenset.But,oncewepickthe9thone,itshouldmake3
cardsfromanyoneofthesets.So,(C)istheanswer.
gatecse

GATE2000_2.2top
E1andE2areeventsinaprobabilityspacesatisfyingthefollowingconstraints:
Pr(E1)=Pr(E2)
Pr(E1E2)=1
E1andE2areindependent
ThevalueofPr(E1),theprobabilityoftheeventE1,is
A.
B.
C.
D.

answerD
letprobabilityofEventE1=x=probofE2
prob(E1unionE2)=prob(E1)+prob(E2)prob(E1intersectE2)
1=x+xx2(prob(E1intersectE2)=prob(E1)*prob(E2)aseventsareindependent)
x=1
name

GATE2001_2.4top
Seven(distinct)caraccidentsoccurredinaweek.Whatistheprobabilitythattheyalloccurredonthesameday?
(a)

1
7

(b)

1
7

(c)

1
2

(d)

7
2

answerB[EDIT]
foreverycaraccidentwecanpickadayin7ways
totalnumberofwaysinwhichaccidentscanbeassignedtodays=77
probabilityofaccidentshappeningonaparticularday=1/77
wecanchooseadayin7ways
henceprobability=7/77=1/76

name

GATE1995_1.18top
Theprobabilitythatanumberselectedatrandombetween100and999(bothinclusive)willnotcontainthedigit7is:
(a)16/25
(b)(9/10)3
http://gateoverflow.in/book

285/400

2/26/2015

GATEOverflow Book

(c)27/75
(d)18/25

Firstdigitcanbechosenin8waysfrom19excluding7
Seconddigitcanbechosenin9waysfrom09excluding7andsimilarlythethirddigitin9ways.
So,totalno.ofwaysexcluding7=899
Totalno.ofwaysincluding7=91010
So,ans=(899)/(91010)=18/25
gatecse

GATE2002_2.10top
ConsiderthefollowingalgorithmforsearchingforagivennumberxinanunsortedarrayA[1..n]havingn distinctvalues:
1. Chooseaniatrandomfrom1..n
2. IfA[i]=x,thenStopelseGoto1
AssumingthatxispresentinA,whatistheexpectednumberofcomparisonsmadebythealgorithmbeforeitterminates?
(A)n
(B)n 1
(C)2n
(D) n2

Whyisthethirdterm

,andnot

ThewayIseeit,theprobabilityofgettingitin2ndtryis:Probabilityoffailingatfirsttrialtimesprobabilityofsucceedingin2ndtrial.
It'snotlikeweareremovingoneelementfromthelistafterthefirsttrial.

Hereismycalculationandproof:

http://gateoverflow.in/book

286/400

2/26/2015

GATEOverflow Book

name

GATE2002_2.16top
Fourfaircoinsaretossedsimultaneously.Theprobabilitythatatleastoneheadandonetailturnupis

A. 16
1

B. 18
C. 78
D. 15
16

answerC
probabilityofgettingallheads=1/16
probabilityofgettingalltails=1/16
probabilityofgettingatleastoneheadandonetail=11/161/16=7/8
name

GATE2006_21top
Foreachelementinasetofsize2n ,anunbiasedcoinistossed.The2n cointossesareindependent.Anelementischosenifthecorrespondingcointosswasa
head.Theprobabilitythatexactlyn elementsarechosenis
(A)
(B)
(C)

2n

Cn

2n

Cn

1
2n

Cn

(D) 12

answerA
waysofgettingnheadsoutof2ntries=2nCn
probabilityofgettingexactlynheadsandntails=(1/2n)(1/2n)
numberofways=2nCn/4n
http://gateoverflow.in/book

287/400

2/26/2015

GATEOverflow Book

name

GATE2004_25top

answerA
outof4times2timesheadshouldbepresent
waysofselectingthese2places4C2
probabilityofgetting2headsand2tails=(1/22)(1/22)
probability=4C2/24=3/8
name

GATE2004_78top

answerA
therenbinarydigitsthatcandifferbutonlydshoulddiffereinthiscase
waysofchoosingtheseddigitsnCd
probabilityofddigitsdifferandnddigitsdonotdiffer=(1/2)d(1/2)(nd)
noofways=nCd/2n
name

GATE2010_27top
Whatistheprobabilitythatdivisorof1099 isamultipleof1096 ?
(A)1/625(B)4/625(C)12/625(D)16/625
Primefactorizationof10 = 2 5 .
So,1099 = 2 99 5 99 and
No.ofpossiblefactorsfor1099 = No.ofwaysinwhichprimefactorscanbecombined
= 100 100 (1extrapossibilityforeachprimenumberasprimefactorraisedto0isalsopossibleforafactor)
10

99

= 10

96

1000

So,no.ofmultiplesof1096 whichdivides1099
= 4 4( 1000 = 2

No.ofpossiblefactorsof1000

5 )

= 16

So,requiredprobability=
=

16
10000

1
625

name

GATE2005_52top
http://gateoverflow.in/book

288/400

2/26/2015

GATEOverflow Book

Arandombitstringoflengthnisconstructedbytossingafaircoinntimesandsettingabitto0or1dependingonoutcomesheadandtail,respectively.The
probabilitythattwosuchrandomlygeneratedstringsarenotidenticalis:
(A) 2 (B)1
1

1
n

(C) n! (D)1
1

1
2

answerD
supposetherearekplaceswithinnbitstringwheremismatchhasoccoured
probabilityofthisoccouringisnCk(prob.ofmismatch)k(prob.ofmatch)(nk)=nCk(1/2)k(1/2)(nk)=nCk(1/2)n
kcanrangefrom1tonhencerequiredprobabilitysum(nCk(1/2)n)wherekrangesfrom1ton
hence(1/2n)(2n1)
Alternatively
Probabilityofmatchingatgivenplace1/2
therearenplaceshenceprobabilityofmatching1/(2n)
henceprobabilityofmismatch11/(2n)

name

GATE1999_2.1top

answerC
ifeventsE1andE2areindependentthenP[E1andE2]=P[E1]xP[E2]whichnotthecasehere
name

GATE2013_24top
Consideranundirectedrandomgraphofeightvertices.Theprobabilitythatthereisanedgebetweenapairofverticesis1/2.Whatistheexpectednumberof
unorderedcyclesoflengththree?
(A)1/8(B)1(C)7(D)8

Acycleoflength3requires3vertices.
Numberofwaysinwhichwecanchoose3verticesfrom8=8C3=56.
Probabilitythat3verticesformacycle=Probabilityofedgebetweenvertices1and2*Probabilityofedgebetweenvertices2and3*Probabilityofedge
betweenvertices1and3
=1/2*1/2*1/2=1/8
So,expectednumberofcyclesoflength3=56*1/8=7
name

GATE1998_1.1top
Adieisrolledthreetimes.Theprobabilitythatexactlyoneoddnumberturnsupamongthethreeoutcomesis

http://gateoverflow.in/book

289/400

2/26/2015

GATEOverflow Book

(a) 6
1

(b) 8
3

(c) 8
1

(d) 12
answerB
therearetotal8possiblecombinationsforthreerollsofthedie
outofthemonly3willhaveexactlyoneoddnumber{OEE,EOE,EEO}
probability=3/8
name

GATE1998_3atop
Twofriendsagreetomeetataparkwiththefollowingconditions.Eachwillreachtheparkbetween4:00pmand5:00pmandwillseeiftheotherhasalready
arrived.Ifnot,theywillwaitfor10minutesortheendofthehourwhicheverisearlierandleave.Whatistheprobabilitythatthetwowillnotmeet?
Wearegiventhatbothwillbereachingtheparkbetween4:00and5:00.
Probabilitythatonefriendarrivesbetween4:00and4:50=5/6
Probabilitythatonefriendarrivesbetween4:00and4:50andmeetstheotherarrivinginthenext10minutes=5/6*1/6*2=10/36=5/18
(Foranytimeofarrivalbetween4:00and4:50,wehavea10minuteintervalpossibleforthesecondfriendtoarrive,and2casesasforchoosingwhichfriend
arrivesfirst)
Probabilitythatbothfriendarrivesbetween4:50and5:00=1/6*1/6=1/36
Thiscoversallpossibilityofameet.So,requiredprobabilityofnonmeet
=1(5/18+1/36)
=111/36
=25/36
name

GATE20141_2top
Supposeyoubreakastickofunitlengthatapointchosenuniformlyatrandom.Thentheexpectedlengthoftheshorterstickis________.

Lengthofshorterstickcanbefrom0to0.5(becauseifitisgreaterthan0.5,itisnolongerashorterstick).ThisrandomvariableL(lengthofshorterstick)
followsauniformdistribution,andhenceprobabilitydensityfunctionofLis

foralllengthsinrange0to0.5.

NowexpectedvalueofL=
name

GATE20141_48top
Fourfairsixsideddicearerolled.Theprobabilitythatthesumoftheresultsbeing22is

X
1296

.ThevalueofX is_______

Thereareonlytwopossiblesetswhoseelementssumto22:{6,6,6,4},{6,6,5,5}
Numberofpermutationsfor1stset:4!/3!=4
Numberofpermutationsfor2ndset:4!/(2!*2!)=6
Sototalnumberofwaystosum22=10
SoX=10.
name

GATE20142_1top
http://gateoverflow.in/book

290/400

2/26/2015

GATEOverflow Book

ThesecuritysystematanITofficeiscomposedof10computersofwhichexactlyfourareworking.Tocheckwhetherthesystemisfunctional,theofficialsinspectfour
ofthecomputerspickedatrandom(withoutreplacement).Thesystemisdeemedfunctionalifatleastthreeofthefourcomputersinspectedareworking.Letthe
probabilitythatthesystemisdeemedfunctionalbedenotedbyp.Then100p=_____________.

InitiallyP(workingcomputer)=4/10,P(nonworkingcomputer)=6/10.
Case1:threecomputersarefunctional:Thereare4subcasesWWWN,WWNW,WNWW,NWWW,whereWmeansworking,Nmeansnonworking,but
P(WWWN)=P(WWNW)=P(WNWW)=P(NWWW),becauseforexample

Inallother3subcases,wegetsamenumeratorsanddenominators(indifferentorder),sototalprobinthiscaseis4*144/5040=576/5040.
Case2:all4areworking

P(atleast3areworking)=600/5040
So100*p=11.90
name

GATE20142_2top
EachoftheninewordsinthesentenceT he quick brown f ox jumps over the lazy dog iswrittenonaseparatepieceofpaper.Theseninepiecesof
paperarekeptinabox.Oneofthepiecesisdrawnatrandomfromthebox.Theexpected lengthoftheworddrawnis_____________.(Theanswershouldbe
roundedtoonedecimalplace.)

Eachoftheninewordshaveequalprobability.So,expectedlength
= 3
=

1
9

+ 5

1
9

+ 5

1
9

+ 3

1
9

+ 5

1
9

+ 4

1
9

+ 3

1
9

+ 4

1
9

+ 3

1
9

35
9

= 3.9

name

GATE20142_48top
Theprobabilitythatagivenpositiveintegerlyingbetween1and100(bothinclusive)isNOTdivisibleby2,3or5is______.

answer0.26
noofintegersdivisibleby2=50
noofintegersdivisibleby3=33
noofintegersdivisibleby5=20
noofintegersdivisibleby2and3=16
noofintegersdivisibleby2and5=10
noofintegersdivisibleby3and5=6
noofintegersdivisibleby2and3and5=3
totalnumbersdivisibleby2or3or5=50+33+2016106+3=74
totalnumbernotdivisibleby2or3or5=26
probability=0.26[EDIT]
name

GATE20143_48top
LetS beasamplespaceandtwomutuallyexclusiveeventsA andB besuchthatA B
valueofP (A)P (B) is_____.

= S

.IfP (. ) denotestheprobabilityoftheevent,themaximum

1/2*1/2=1/4
P(A)+P(B)=1,sincebotharemutuallyexclusiveandAB=S.
http://gateoverflow.in/book

291/400

2/26/2015

GATEOverflow Book

Whensumisaconstant,productoftwonumbersbecomesmaximumwhentheyareequal.So,P(A)=P(B)=1/2
Saumya

GATE2011_3top
Iftwofaircoinsareflippedandatleastoneoftheoutcomesisknowntobeahead,whatistheprobabilitythatbothoutcomesareheads?
(A)1/3
(B)1/4
(C)1/2
(D)2/3

answerA
prob(atleastonehead)=3/4
prob(bothheads)=1/4
usingbayes'theorem=(1/4)/(3/4)=1/3
name

GATE2011_33top
ConsiderafinitesequenceofrandomvaluesX = [x 1 , x 2 , x n ] .Let x bethemeanand x bethestandarddeviationofX .Letanotherfinitesequence Y of
equal length be derived from this as y i = a x i + b, where a and b are positive constants. Let y be the mean and y be the standard deviation of this
sequence.WhichoneofthefollowingstatementsisINCORRECT?
(A)IndexpositionofmodeofX inX isthesameastheindexpositionofmodeofY inY
(B)IndexpositionofmedianofX inX isthesameastheindexpositionofmedianofY inY
(C) y

= a

(D) y

= a x + b

+ b

answerD
mean,medianandmodearelinearfunctionsoverarandomvaiable.
somultiplyingbyconstantsoraddingconstantswontchangetheirrelativeposition.
standarddeviationisnotalinearfunctionoverarandomvariable.
name

GATE1994_1.4top

(a)istrueonlyifeventsareindependent.
(b)istrueonlyifeventsaremutuallyexclusivei.e.
(c)isfalseeverywhere
(d)isalwaystrueas
Since

name

GATE1994_2.8top
http://gateoverflow.in/book

292/400

2/26/2015

GATEOverflow Book

P(A)=0.8 P(A')=1.8=.2
P(B)=0.5 P(A')=1.8=.5
P(C)=0.3 P(A')=1.8=.7
P(Noeventwilloccur):=.2*.5*.7=.07
P(atleast1eventwilloccur):1.07=.93
name

GATE1995_2.14top

answerC
probabilityoffirstballwhiteandsecondoneblack=(10/25)x(15/24)
probabilityoffirstballblackandsecondonewhite=(15/25)x(10/24)
probabilty=sumofabovetwoprobabilities=1/2
name

GATE1996_1.5top

1(no6inboththedice)=1(5/6*5/6)=11/36
name

GATE1996_2.7top

Thereare52cardsincluding4acessotheprobabilitmustbe4/52*3/51
name

GATE2006IT_22top
Whenacoinistossed,theprobabilityofgettingaHeadisp,0<p<1.LetNbetherandomvariabledenotingthenumberoftossestillthefirstHeadappears,
includingthetosswheretheHeadappears.Assumingthatsuccessivetossesareindependent,theexpectedvalueofNis

A)
B)

1/P
1/(1P)

C)

1/P2

D)

1/(1P2)
E=p*1+(1p)p*2+(1p)(1p)p*3+....
multiplybothsidewith(1p)andsubtract:

http://gateoverflow.in/book

293/400

2/26/2015

GATEOverflow Book

E(1p)E=p*1+(1p)p+(1p)(1p)p+....=p/(1(1p))=1(becauseit'snowformingaGP)
=>(11+p)E=1
=>E=1/P

So,Option(A)...
name

AandBarefriends.Theydecidetomeetbetween1:00pmand2:00pmonagivenday.top
AandBarefriends.Theydecidetomeetbetween1:00pmand2:00pmonagivenday.Thereisaconditionthatwhoeverarrivesfirstwillnotwaitfortheother
formorethan15minutes.Theprobabilitythattheywillmeetonthatdayis
A.
B.
C.
D.

1/4
1/16
7/16
9/16

Meetingoccursifthefirstpersonarrivesbetween1:00and1:45andthesecondpersonarrivesinthenext15minutesorifboththepersonsarrivebetween
1:45and2:00.
Case1:
45/60arefavourablecasesandhenceprobabilityoffirstpersonarrivingbetween1:00and1:45is3/4.
Probabilityofsecondpersonarrivinginthenext15minutes=15/60=1/4
So,probabilityofonepersonarrivingbetween1:00and1:45andmeetingtheother=3/4*1/4*2=3/8(2forchoosingthefirstarrivingfriend)
Case2:
Bothfriendsmustarrivebetween1:45and2:00.So,probability=1/4*1/4=1/16
So,probabilityofameet=3/8+1/16=7/16
name

Afaircoinistossed100times.TheProbabilityofgetting50headsisclosetooneofthefollowing
numbers:a)0.001b)0.1c)0.3d)0.4top
Assumingweneedexactly50heads
100C

501/2500.1

501/2

name

BayesTheoremtop

ProbabilityofUrn3giventheballsarewhiteandgreen
=P(Urn3andwhite+Urn3andgreen)/P(whiteandgreen)
=P(Urn3andwhite+Urn3andgreen)/[P(Urn3andwhite+Urn3andgreen)+P(Urn2andwhite+Urn2andgreen)+P(Urn1andwhite+Urn1and
green)]
=1/3*(4/12*3/11*2C1)/[1/3*(4/12*3/11*2C1)+1/3*(2/4*1/3*2C1)+1/3*(1/6*3/5*2C1)]
=(2/33)/(2/33+1/9+1/15)
=(2/33)/(30+55+33)/495
=2*15/118
=15/59
(2C1ismultipliedbecausethe2ballscouldbedrawnin2C1ways)
name
http://gateoverflow.in/book

294/400

2/26/2015

GATEOverflow Book

GATE20151_29top
ConsideraLANwithfournodesS1,S2,S3andS3.Timeisdividedintofixedsizeslots,andanodecanbeginitstransmissiononlyatthebeginningofaslot.A
collisionissaidtohaveoccurredifmorethanonenodetransmitinthesameslot.TheprobabilitiesofgenerationofaframeinatimeslotbyS1,S2,S3andS4
are0.1,0.2,0.3and0.4respectively.Theprobabilityofsendingaframeinthefirstslotwithoutanycollisionbyanyofthesefourstations
is__________________.
P=P(S1)P(~S2)P(~S3)P(~S4)+P(~S1)P(S2)P(~S3)P(~S4)+P(~S1)P(~S2)P(S3)P(~S4)+P(~S1)P(~S2)P(~S3)P(S4)
=0.1*0.8*0.7*0.6
+0.9*0.2*0.7*0.6
+0.9*0.8*0.3*0.6
+0.9*0.8*0.7*0.4
=0.4404
name

GATE20153_37top
SupposeX i fori

areindependentandidenticallydistributedrandomvariableswhoseprobabilitymassfunctionsare
1
fori = 1, 2, 3 .DefineanotherrandomvariableY = X 1 X 2 X 3 ,where denotesXOR.Then
2
= ______.

= 1, 2, 3

P r[X i = 0] = P r[X i = 1] =
P r[Y = 0 X 3 = 0]

Answeris0.75

AsX3=0isgiven,tohaveY=0,X1X2shouldbe0,meaning(X1,X2)shouldbeoneof{(0,0)(0,1)(1,0)}....
so,requiredprobability=3*(1/2)*(1/2)=0.75......
name

http://gateoverflow.in/book

295/400

2/26/2015

GATEOverflow Book

SetTheory&Algebratop
GATE2013_1top
Abinaryoperation onasetofintegersisdefinedasx y

= x

+ y

.Whichoneofthefollowingstatementsis**TRUE**about ?

(A)Commutativebutnotassociative
(B)Bothcommutativeandassociative
(C)Associativebutnotcommutative
(D)Neithercommutativenorassociative
Answeris(A)Commutativebutnotassociative.
y x = y

+ x

(x y) z = (x

= x y

+ y

x (y z) = x (y

So,((x y) z)
name

.Hence,commutative.

) z = (x

+ z

) = x

(x (y z))

+ y

+ (y

+ z

+ z

,hencenotassociative.

numberofsymmetricfuntionstop

Firstweneedtofinddifferentnumberofinputsforfgiventhatpermutaionsareequivalent.

Nowgiventwobinarystringx,y:xisapermutaionofyiffxhassamenumberofonesandzerosasy.

Sothetotalnumberofdifferentinputsisn+1(namelyinputwithzero0's,one0's...n0's)

Foreachoftheseinputswecanhaveeither1or0asoutput,sotwochoices.

Therefore,numberofchoicesis2x2x2.....(n+1)times.

Sothetotalnumberoffunctionsis2 n+1
name

GATE2009_1top
WhichoneofthefollowingisNOTnecessarilyapropertyofaGroup?
(A)Commutativity
(B)Associativity
(C)Existenceofinverseforeveryelement
(D)Existenceofidentity
GrupoidclosurepropertySemigroupclosure,associativeMonoidclosure,associative,identityGroupclosure,associative,identity,inverseAbeliangroup
groupproperty+commutativeSoansshouldbeA..
sonu

GATE2009_4top
ConsiderthebinaryrelationR = {(x, y), (x, z), (z, x), (z, y)}ontheset{x, y, z} .
WhichoneofthefollowingisTRUE?
(A)R issymmetricbutNOTantisymmetric
R

http://gateoverflow.in/book

296/400

2/26/2015

GATEOverflow Book

(B)R isNOTsymmetricbutantisymmetric
(C)R isbothsymmetricandantisymmetric
(D)R isneithersymmetricnorantisymmetric

AnswerisD.

name

GATE2006_24top
GivenasetofelementsN={1,2,...,n}andtwoarbitrarysubsetsANandBN,howmanyofthen!permutations fromNtoNsatisfymin( (A))=min(
(B)),wheremin(S)isthesmallestintegerinthesetofintegersS,and (S)isthesetofintegersobtainedbyapplyingpermutation toeachelementofS?
(A)(n|AB|)|A||B|(B)(|A|

+ |B| )n

(C)n!

|AB|
|AB|

(D)

|AB|
n

C |AB|

min((N))=1,sinceinapermutationofnelementsfrom1..n,someelementmustget1.
Similarly,inanysubsetsAandB,min((A))=min((B))onlyifAandBhasacommonelementanditspermutationisthesmallestofalltheotherelements
inAandB.
(WiththisunderstandingitselfwecaneliminateoptionsAandB)
Nowwehaven!totalpermutationsandwehavetoseethenumberofpermutationssatisfyingthegivencondition.IfA=B,allofthen!permutationssatisfy
thegivencondition.(ThisisenoughtogettheanswerasC).Otherwise,thefractionofthen!permutationssatisfyingthegivencondition
=|AB|/|AB|
Thisisbecausewithoutthegivenrestriction,thesmallestelement(amongthe|AB|elements)canbeanyoneofthe|AB|elements,andwiththe
restriction,thesmallestelementmustbeoneofthe|AB|elements.
So,answerisC.
name

GATE2010_3top
Whatisthepossiblenumberofreflexiverelationsonasetof5elements?
(A)2 10 (B)2 15 (C)2 20 (D)2 25

Arelationconsistsofsetoforderedpairs(a, b) .Herea canbechoseninn waysandsimilarly b canbechosenin n ways.So,totally n 2 possibleordered


pairsarepossibleforarelation.Noweachoftheseorderedpaircaneitherbepresentintherelationornot2possibilitiesforeachofthe n 2 pair.So,total
numberofpossiblerelations=
2

(n )

.
Now,forarelation R tobereflexive,orderedpairs {(a, a) a S } ,mustbepresentin R .i.e.therelationset R musthave n orderedpairsfixed.So,
numberoforderedpairspossibleisn 2 n andhencetotalnumberofreflexiverelationsisequalto
2

(n n)

.
name

GATE2005_13top
Theset{1, 2, 4, 7, 8, 11, 13, 14} isagroupundermultiplicationmodulo15.theinversesof4and7arerespectively:
http://gateoverflow.in/book

297/400

2/26/2015

GATEOverflow Book

(A)3and13(B)2and11(C)4and13(D)8and14
Optionc.
Identityelementhereis1.
4*4mod15=1
7*13mod15=1.
anshu

GATE2005_42top
LetRandSbeanytwoequivalencerelationsonanonemptysetA.WhichoneofthefollowingstatementsisTRUE?
(A)RS,RSarebothequivalencerelations.
(B)RSisanequivalencerelation.
(C)RSisanequivalencerelation.
(D)NeitherRSnorRSareequivalencerelations.
RUSmightnotbetransitive.Say(a,b)bepresentinRand(b,c)bepresentinSand(a,c)notpresentineither,RUSwillcontain,(a,b)and(b,c)butnot(a,
c)andhencenottransitive.
optionc.
anshu

GATE2007_3top
WhatisthemaximumnumberofdifferentBooleanfunctionsinvolvingn Booleanvariables?
n

(A)n 2 (B)2 n (C)2 2 (D)2 n

answerC
sizeofdomain=numberofdifferentcombinationsofinputs=2n
sizeofcodomain=2({0,1})
numberoffunctions=(sizeofcodomain)(sizeofdomain)
name

GATE1999_3top

LetsetAbe{1,2,3},andletarelationRonAbe

Risbothsymmetricandtransitive,butnotreflexive.ThekeypointhereisthattheremaybesomeelementinsetAwhichisnotrelatedtoanyoftheelement
inR,buttobereflexive,allelementsmustberelatedtothemselves.

name

GATE1998_1.6top
SupposeA isafinitesetwithn elements.ThenumberofelementsinthelargestequivalencerelationofAis
(a)n
http://gateoverflow.in/book

298/400

2/26/2015

GATEOverflow Book

(b)n 2
(c)1
(d)n + 1
AnsB
name

GATE20141_50top
Letdenotethesetofallfunctions
S
f

: {0, 1}

{0, 1} .DenotebyN thenumberoffunctionsfrom

Stotheset{0, 1} .Thevalueoflog2 log2 N is_______.

ForafunctionfromsetAtosetB,weneedtohaveamappingforallelementsofAandmappingmustbeunique.
LetnumberofelementsinAbem andthatinBben
So,ifweconsideranelementfromA,itcanbemappedtoanyoftheelementfromB.i.e.,ithasn possibilitieswhenafunctionisformed.Similarly,forall
othermembersalsotherearen possibilitiesasoneelementfromAcanbemappedtoonlyasingleelementinB(thoughreverseneednottrue).So,forn
elementsinA,wetotallyhaven n = n m possiblefunctions.

mtimes

InthequestionNumberofelements(functions)inf is2 2 as{0, 1} contains2 4 elements.So,numberoffunctionsfromS to{0, 1} willbe2 2 .So,


log 2 log 2 N = 2

= 16.

name

GATE20142_5top
Anonzeropolynomialf (x) ofdegree3hasrootsatx

(A)f (0)f (4)


(B)f (0)f (4)

= 1 ,x = 2 andx = 3 .WhichoneofthefollowingmustbeTRUE?

< 0
> 0

(C)f (0) + f (4)

> 0

(D)f (0) + f (4)

< 0

Therootsarex=1,x=2,andx=3.
Sopolynomialisf(x)=(x1)(x2)(x3)
f(0)=6,f(4)=6
Sof(0)f(4)<0.
name

GATE20143_2top
LetX andY befinitesetsandf

: X Y

beafunction.WhichoneofthefollowingstatementsisTRUE?

(A)ForanysubsetsA andB ofX, |f A B|

= |f (A)| + |f (B)|

(B)ForanysubsetsA andB ofX, f (A B)


(C)ForanysubsetsA andB ofX, |f (A B|
(D)ForanysubsetsS andT ofY , f

= f (A) f (B)
= min{|f (A)|, |f (B)|}

(S T ) = f

(S ) f

(T )

D)
3outof4optionscanbeeliminatedwiththehelpofacounterexample.
Letx={a,b,c}andy={1,2}
AFunctionfmapseachelementofxto1iny.
f(a)=1,f(b)=1,f(c)=1
A={a,b}B={b,c}
A)
|f(AuB)|=|f({a,b,c})|=3
|f(A)|+|f(B)|=2+2=4,LHS!=RHS.
http://gateoverflow.in/book

299/400

2/26/2015

GATEOverflow Book

B)
f(AB)=f({b})={1}
f(A) f(B) = { 1 , 1 } { 1 , 1 } = { 1 , 1 }
LHS!=RHS

C)

|f(AB)|=|f({b})|=|{1}|=1
min{|f(A)|,|f(B)|}=min(2,2)=2
LHS!=RHS
D)Itseasytoseethatthisistruebecauseinafunctionavaluecanbemappedonlytoonevalue.

name

GATE20143_49top
Considerthesetofallfunctionsf
statements:

: {0, 1, , 2014} {0, 1, , 2014}

.Foreachsuchfunctionitmustbethecasethatforeveryi, f (i)

= i

.Foreachsuchfunctionitmustbethecasethatforsomei, f (i)

= i

.Eachfunctionmustbeonto.

suchthatf (f (i))

= i

,forall0

i 2014

.Considerthefollowing

WhichoneofthefollowingisCORRECT?
(A)P , QandR aretrue
(B)OnlyQ andR aretrue
(C)OnlyP andQ aretrue
(D)OnlyR istrue

Letf (i)
Whenj

= j

= i

.Now,wehavef (j)

= i

,asperthegivenconditionf (f (i))

= i

,theconditionholdsandsincedomainandcodomainofthefunctionsdointersect(actuallysame),Q isdefinitelytrue.

Sincef (i) = j andf (j) = i ,andsince0 i 2014 i musttakeall2015possiblevalues(sincef isafunction,itmusthaveavalueforanyelementin


thedomain).Wecaneasilyseethatf (i)cannotbethesamefortwodifferenti sbecausesupposef (2) = 5 ,andf (3) = 5 .Nowaspergivencondition,
f (5) = 2 andf (5) = 3 ,whichisnotallowedinafunction.So,allf (i)valuesareunique codomain=rangeasthereareonly2015valuesinco
domain.So,Ristrue.
Anidentityfunctionsatisfiesthegivenconditions.ButthatalonecantprovethatPistrue.Wecanalsohaveadifferentfunctionwhereallevennumbers
mapstothenextoddnumberandalloddnumbersmaptothepreviousevennumberwhichsatisfiesthegivenconditions.i.e.,
f (0) = 1, f (1) = 0, f (2) = 3, f (3) = 2 f (2015) = 2014 .Thisproves,Pisfalse.
So,(B)istheanswer.
name

GATE20143_50top
Therearetwoelementsx,
isknownthat

inagroup(G, ) suchthateveryelementinthegroupcanbewrittenasaproductofsomenumberofx 'sandy 'sinsomeorder.It

x x = y y = x y x y = y x y x = e

wheree istheidentityelement.Themaximumnumberofelementsinsuchagroupis____.

http://gateoverflow.in/book

300/400

2/26/2015

GATEOverflow Book

Andsotheansweris4.
name

GATE1997_6.1top
ApartialorderisdefinedonthesetS={x,a1,a2,...an,y}asxaiforalliandaiyforalli,wheren1.ThenumberoftotalordersonthesetSwhich
containthepartialorderis
A.
B.
C.
D.

n!
n+2
n
1

Tomakethispartialorderatotalorder,weneedtherelationtoholdforeverytwoelementofthepartialorder.Currentlybetweenanyaiandaj,thereisno
relation.So,foreveryai,aj,wehavetoaddeither(ai,aj)or(aj,ai)intotalorder.So,thistranslatestogivinganorderingfornelementsbetweenxandy,
whichcanbedoneinn!ways.So,answeris(a).

http://gateoverflow.in/book

301/400

2/26/2015

GATEOverflow Book

Thebottomfigureisforatotalorder.Wecanpermutetheaifromi=1ton,andeachpermutationwillalsobeatotalordercontainingthegivenpartial
order.
name

GATE1996_2.1top
LetR denotethesetofrealnumbers.Let f
givenby
(a)f 1 (x, y)

= (

(b)f 1 (x, y)

= (x y, x + y)

(c)f 1 (x, y)

= (

(d)f 1 (x, y)

= [2(x y), 2(x + y)]

1
x+y

x+y
2

1
xy

xy
2

: R R R R

beabijectivefunctiondefinedbyf (x, y)

= (x + y, x y)

.Theinversefunctionof f is

tofindinverseofthefunctiontake
z1=x+y
z2=xy
onsolvingthiseq.wecangetvalueofx=z1+z2/2&y=z1z2/2
soinverseoffunctionintermsofxandyisf1(x,y)={x+y/2,xy/2}
nehapawar
http://gateoverflow.in/book

302/400

2/26/2015

GATEOverflow Book

Onasetofnelements,howmanyrelationsaretherethatarebothirreflexiveandantisymmetric?top
Onasetofnelements,howmanyrelationsaretherethatarebothirreflexiveandantisymmetric?
Pleaseexplainhowtocalculate.

OnasetS withn elementshowmanyrelationsarethere?


Arelationconsistsofsetoforderedpairs(a, b) .Herea canbechoseninn waysandsimilarly b canbechosenin n ways.So,totally n 2 possibleordered
pairsarepossibleforarelation.Noweachoftheseorderedpaircaneitherbepresentintherelationornot2possibilitiesforeachofthe n 2 pair.So,total
numberofpossiblerelations=
2

(n )

.
Now,forarelation R tobereflexive,orderedpairs {(a, a) a S } ,mustbepresentin R .i.e.therelationset R musthave n orderedpairsfixed.So,
numberoforderedpairspossibleisn 2 n andhencetotalnumberofreflexiverelationsisequalto
2

(n n)

.
Numberofirreflexiverelationsissameasnumberofreflexiverelations.Inreflexiverelationswealwaysincluded n orderedpairsfor {(a, a) a S } ,
whileinirreflexiverelationwealwaysomitthosen orderedpairs.So,thenumberoforderedpairstochoosefortherelationisthesameforbothreflexiveas
wellasirreflexiverelationswhichis
2

(n n)

Arelationbecomessymmetric,iffororderedpair(a, b) inR ,orderedpair(b, a) isalsopresentinR .So,here,thetotalnumberoforderedpairspossibleis


reducedfrom
n + n + + n

to

n + n 1 + n 2 + + 1 =

n(n+1)
2

So,totalnumberofpossiblesymmetricrelations=
n(n+1)

)
2

.
Arelationbecomesantisymmetriciffortheorderedpairs (a, b) and (b, a) in R , a
therelationunlessa = b .

= b

.i.e.,thepairs (a, b) and (b, a) cannotbesimultaneouslybein

Forthen pairs(a, a) inR ,theycanbeeitherpresentinrelationorabsent.So,2possibilitiesforeachgiving2 n possiblerelations.


Numberofpairs(a, b) inR suchthata

equalsnumberofwaysofselecting2numbersfromn withoutrepetition,equals

n(n1)
2

Now,foreachofthesepairs(a, b) ,thereare3possibilities
1. (a, b) and(b, a) notinR
2. (a, b) inR but(b, a) notinR
3. (a, b) notinR but(b, a) inR
n(n1)

So,totalnumberofpossibilitiesforallsuchpairs=3

)
2

Andtotalnumberofantisymmetricrelationsonasetofn elementsbecomes
n(n1)

)
2

Finally,comingtoyourquestion,numberofrelationsthatarebothirreflexiveandantisymmetricwhichwillbesameasthenumberofrelationsthatareboth
reflexiveandantisymmetricis
http://gateoverflow.in/book

n(n1)

303/400

2/26/2015

GATEOverflow Book
n(n1)

)
2

Wejusthavetoalwaysexcluden pairsbeingconsideredfor(a, a) whilecalculatingthepossiblerelationsforantisymmetriccase.

name

GATE2008IT_26top
ConsiderthefieldCofcomplexnumberswithadditionandmultiplication.Whichofthefollowingform(s)asubfieldofCwithadditionandmultiplication?
(S1)thesetofrealnumbers
(S2){(a+ib)|aandbarerationalnumbers}
(S3){a+ib|(a2+b2)1}
(S4){ia|aisreal}

1)
2)
3)
4)

onlyS1
S1andS3
S2andS3
S1andS2

Afieldisanalgebricstructureovertwooperations+and*if:
1.Itisclosedunderboth+and*.
2.+and*arebothcommutativeandassociative.(+and*inthisquestionarealreadycommutativeandassociative,sononeedtocheck).
3.Existenceofadditiveidentity(0)andmultiplicativeidentity(1)
4.Existenceofadditiveandmultiplicativeinversesforeachnonzeroelement.
5.Distributivepropertyof*over+(Thisisalsosatisfiedinquestion)
Soforeachoption,wehavetocheckonlyproperties1,3,and4.
(S1):setofallrealnumbers
1.Closed:Yes,real+real=real,real*real=real
3.Additiveandmultiplicativeidentity:Yes,0and1arerealnumbers
4.Additiveandmultiplicativeinverseforeachnonzeroelement:Yes,foranyrealnumbera,additiveinverseisa,whichisalsoarealnumber,and
multiplicativeinverseis1/a,whichisalsoarealnumber.
(S2):{(a+ib)|aandbarerationalnumbers}
1.Closed:Yes,rational+rational=rational,rational*rational=rational
3.Additiveandmultiplicativeidentity:Yes,0+0i(additiveidentity)and1+0i(multiplicativeidentity)belongtogivenset.
4.Additiveandmultiplicativeinverseforeachnonzeroelement:Additiveinverseisaib,whichbelongstogivenset.Multiplicativeidentityis
,whichalsobelongstogivenset.
(S3):{a+ib|(a2+b2)1}
1.Closed:No,forexample:(0.3+0.4i)+(0.7+0.6i)=1+i.Herebothcomplexnumberswhichwereaddedwereinthegivenset,butresultantcomplex
numberisnot.
(S4):{ia|aisreal}
Herethissetdoesn'tcontain1(multiplicativeidentity)
So(S1)and(S2)aresubfieldsofC.Sooption4)iscorrect.
name

GATE2007IT_76top
Considerthesequence

http://gateoverflow.in/book

definedbytherecurrencerelation

,where

304/400

2/26/2015

GATEOverflow Book

Supposethereexistsanonempty,openinterval
thevalue?

suchthatforall

satisfying

,thesequenceconvergestoalimit.Thesequenceconvergesto

A)
B)
C)
D)

Sinceitconverges,wecanwrite:

or

Solvingforx:

SobothA)andB)canbethevalues.
name

GATE2005IT_31top
LetfbeafunctionfromasetAtoasetB,gafunctionfromBtoC,andhafunctionfromAtoC,suchthath(a)=g(f(a))forallaA.Whichofthefollowing
statementsisalwaystrueforallsuchfunctionsfandg?

A)
B)
C)
D)

gisonto=>hisonto
hisonto=>fisonto
hisonto=>gisonto
hisonto=>fandgareonto

Lethbeonto(ontomeanscodomain=range).So,hmapstoeveryelementinCfromA.Sinceh(a)=g(f(a)),gshouldalsomaptoallelementsinC.So,gis
alsoonto>option(C).

name

GATE2005IT_33top
LetAbeasetwithnelements.LetCbeacollectionofdistinctsubsetsofAsuchthatforanytwosubsetsS1andS2inC,eitherS1S2orS2S1.Whatisthe
maximumcardinalityofC?

1)
2)

n
n+1

3)

2n1+1
n!

4)
Let'stakeanexampleset{a,b,c}

Nowletstrytocreatetherequiredsetofsubsets,sayS.
Let'sstartbyaddingsetsofsize1toS.Wecanonlyaddoneofthesets{a},{b},{c}.
Letssayweadd{a},soSnowbecomes{{a}}
Nowletsaddsetsofsize2toS.Againweseethatwecanonlyaddoneof{a,b},{a,c}or{b,c},andwecannotadd{b,c}sincewealreadyadded{a}.
http://gateoverflow.in/book

305/400

2/26/2015

GATEOverflow Book

Continuingthiswayweseewecanaddonlyonesetforaallsizetilln.
Sotheawnsershouldbe2)n+1(includetheemptyset)
name

Noofsurjectivefunctionstop

Wehave4elementsinsetBand5elementsinsetAandsurjectionmeanseveryelementinBmustbemappedto.So,thisproblemreducestodistributing5
distinctelements(r=5)among4distinctbins(n=4)suchthatnobinisempty,whichisgivenbyn!S(r,n),whereS(r,n)isStirling'snumberof2ndkind.
So,hereweneedS(5,4).
WehaveS(r+1,n)=n*S(r,n)+S(r,n1)
1
11
131
1761
11525101
So,S(5,4)=10and4!=24giving,numberofsurjectivefunctions=24*10=240

Ref:SeeTheorem9:
http://www.cse.iitm.ac.in/~theory/tcslab/mfcs98page/mfcshtml/notes1/partset.html
name

maths_mock_test3top

Totalnumberofsubsetsofasetofsizeofn=nC0+nC1+.......+nCn
Totalnumberofsubsetsofsizek(0<=k<=n)=nCk
Totalnumberof(A,B)pairssuchthat|B|isequaltok=allpossiblesubsetsofB*totalnumberofsubsetsofsizek
=2k*nCk=nCk*2k
Totalnumberof(A,B)pairs=nC020+nC121+.......+nCn2n=3n

name

maths_mock_test4top
http://gateoverflow.in/book

306/400

2/26/2015

GATEOverflow Book

2 is correct answer. fig 2, b and c have {f,g} as upperbound. but for the graph to be a lattice it should have a least upper
bound. Since b and c have two upper bounds they cannot have a least upper bound<which is always unique for a pair for
vertices>. In other words we cannot say which one is least one out of the pair {f,g}. therefore it is not a join
semilattice(every pair of element should have a least upper bound). henceforth it is also not a lattice
name

GATE20151_5top
Ifg(x)

= 1 x

A.

h(x)

B.

C.

g(x)

D.

andh(x)

x
x1

,then

g(h(x))
h(g(x))

is:

g(x)

h(x)
x
(1x)

optionc)iscorrect.
g(h(x))=g(x/x1)
=1x/1x1
=(1x/x)
h(g(x))=h(1x)
=1(x/x1)
=1/x1
=1/1x
g(h(x))/h(g(x))=(1x/x)/(1/1x)
=(1x)^2/x
optionC)
g(x)/h(x)=1x/(x/x1)
=(1x)^2/x
name

GATE20152_GA_3top
Considerafunctionf (x)

= 1 |x|on 1 x 1

.Thevalueofx atwhichthefunctionattainsamaximum,andthemaximumvalueofthefunctionare:

A. 0,1
http://gateoverflow.in/book

307/400

2/26/2015

GATEOverflow Book

B. 1,0
C. 0,1
D. 1,2
Answer:C
Putthevalueofxofalltheoptionsinf(x)andfindvalueoff(x).
name

GATE20152_GA_9top
Ifp,q,r,saredistinctintegerssuchthat:
f (p, q, r, s) = max(p, q, r, s)

g(p, q, r, s) = min(p, q, r, s)

h(p, q, r, s) = remainder of(p q)/(r s)if(p q) > (r s)


or remainder of(r s)/(p q)if(r s) > (p q)

Alsoafunctionf gh(p, q, r, s) = f (p, q, r, s) g(p, q, r, s) h(p, q, r, s)


Alsothesameoperationsarevalidwithtwovariablefunctionsoftheformf (p, q)
Whatisthevalueoff g(h(2, 5, 7, 3), 4, 6, 8) ?

Itisgiventhat

remainderof
remainderof

if

orremainderof

if

Again,itisgiventhat
Also,

max

and
max

min
andmin

Answer:
name

GATE20152_9top
Thenumberofdivisorsof2100is____.

Answer:36
2100=7*3*22*52
Hence,totalnumberoffactorswillbe=(1+1)*(1+1)*(2+1)*(2+1)=2*2*3*3=36,
becauseanyfactorisobtainedbymultiplyingtheprimefactorszeroormoretimes.(oneextraforzero)
name

GATE20152_16top
LetRbetherelationonthesetofpositiveintegerssuchthataRbandonlyifa andb aredistinctandlethaveacommondivisorotherthan1.Whichoneofthe
followingstatementsaboutR istrue?

A.
B.
C.
D.

issymmetricandreflexivebutnottransitive
isreflexivebutnotsymmetricnottransitive
R istransitivebutnotreflexiveandnotsymmetric
R issymmetricbutnotreflexiveandnottransitive
R
R

http://gateoverflow.in/book

308/400

2/26/2015

GATEOverflow Book

Answer:D
Take(3,6)and(6,2)elementsofR.Fortransitivity(3,2)mustbeelementofR,but3and2don'thaveacommondivisorandhencenotinR.
Foranypositiveintegern,(n,n)isnotelementofRasonlydistinctmandnareallowedfor(m,n)inR.So,notreflexivealso.
name

GATE20152_18top
Thecardinalityofthepowersetof{0, 1, 2, , 10} is_______

Answer:2048
Numberofelementsinset=11.
Therefore,cardinalityofpowerset=211=2048.
name

GATE20152_26top
Letf (x)
TRUE?

= x

(1/3)

andA denotetheareaofregionboundedbyf (x) andtheXaxis,whenx variesfrom1to1.Whichofthefollowingstatementsis/are

I. f iscontinuousin[1,1]
II. f isnotboundedin[1,1]
III. A isnonzeroandfinite

A.
B.
C.
D.

IIonly
IIIonly
IIandIIIonly
I,IIandIII

Answer:C
I.False.
II.True.
III.True.Anareaisalwayspositive,whilethedefiniteintegralmightbecomposedofseveralregions,somepositiveandsomenegative.Adefiniteintegral
getsyouthenetarea,becauseanypartofthegraphthatisbelowthexaxiswillgiveyouanegativearea.So,adefiniteintegralisnotnecessarilythearea
underthecurve,butthevalueoftheareaabovethexaxislesstheareaunderthexaxis.So,Aisnonzeroandfinite.
name

GATE20152_40top
Thenumberofontofunctions(surjectivefunctions)fromsetX

tosetY

= {1, 2, 3, 4}

= {a, b, c}

is______.

Wehave3elementsinsetBand4elementsinsetAandsurjectionmeanseveryelementinBmustbemappedto.So,thisproblemreducestodistributing4
distinctelements(r=4)among3distinctbins(n=3)suchthatnobinisempty,whichisgivenbyn!S(r,n),whereS(r,n)isStirling'snumberof2ndkind.
So,hereweneedS(4,3).
WehaveS(r+1,n)=n*S(r,n)+S(r,n1)
So,Stirlingnumbersofsecondkindcanbegeneratedasfollows:
1
11
131
1761
So,S(4,3)=6and3!=6giving,numberofsurjectivefunctions=6*6=36

Ref:SeeTheorem9:
http://www.cse.iitm.ac.in/~theory/tcslab/mfcs98page/mfcshtml/notes1/partset.html
http://gateoverflow.in/book

309/400

2/26/2015

GATEOverflow Book

name

GATE20151_28top
Thebinaryoperatorisdefinedbythefollowingtruthtable.
p
0
0
1
1

q
0
1
0
1

pq
0
1
1
0

Whichoneofthefollowingistrueaboutthebinaryoperator?
A.
B.
C.
D.

Bothcommutativeandassociative
Commutativebutnotassociative
Notcommutativebutassociative
Neithercommutativenorassociative

optionA:asitisXORoperation
GATERush

GATE20151_16
top
ForasetA ,thepowersetofA isdenotedby2 A .IfA
I. 2
II. 2 A
III. {5, {6}}
IV. {5, {6}}

= {5, {6}, {7}}

,whichofthefollowingoptionsareTRUE?

A.
B.
C.
D.

IandIIIonly
IIandIIIonly
I,IIandIIIonly
I,IIandIVonly

PowersetofAconsistsofallsubsetsofAandfromthedefinitionofasubset,isasubsetofanyset.So,IandIIareTRUE.
5and{6}areelementsofAandhence{5,{6}}isasubsetofAandhenceanelementof2A.
{5,{6}}isanelementof2A.So,{{5,{6}}}2A.
So,optionC.
name

GATE20151_26top

99
x=1

1
1.2

1
x(x+1)

+ +

2.3

= 1
= 1

name

=__________________.

1
2

1
100

1
2

1
99.100

1
3

1
3

1
4

+ +

1
99

1
100

= 0.99

GATE20152_54top
LetX andY denotethesetscontaining2and20distinctobjectsrespectivelyandF denotethesetofallpossiblefunctionsdefinedfromX toY .Letf be
randomlychosenfromF .Theprobabilityoff beingonetooneis______.
Forafunction,thefirstelementinXhas20choices(tomapto)andthesecondelementalsohas20choices.Foraonetoonefunctionthesecondelementhas
only19choicesleftafter1beingtakenbythefirst.So,requiredprobability
=20*19/(20*20)=0.95
name
http://gateoverflow.in/book

310/400

2/26/2015

GATEOverflow Book

GATE20151_34top
SupposeL

= {p, q, r, s, t}

isalatticerepresentedbythefollowingHassediagram:

Foranyx, y L ,notnecessarilydistinct,x yandx yarejoinandmeetofx, y ,respectively.LetL3 = {(x, y, z) :


orderedtripletsoftheelementsofL.Letp r betheprobabilitythatanelement(x, y, z) L3 chosenequiprobablysatisfies
x (y z) = (x y) (x z) .Then
A.
B.
C.
D.

x, y, z L}

bethesetofall

pr = 0
pr = 1
0 < pr
1
5

1
5

< pr < 1

NumberofelementsinL3=Numberofwaysinwhichwecanchoose3elementsfrom5withrepetition=5*5*5=125.
Now,whenwetakex=t,thenalsothegivenconditionissatisfiedforanyyandz.Here,yandzcanbetakenin5*5=25ways.
Takex=r,y=p,z=p.Herealso,thegivenconditionissatisfied.So,pr>25/125>1/5.
Forx=p,y=r,z=t,thegivenconditionisnotsatisfied.So,pr1.
So,Dchoice.

name

GATE20151_39top
Considertheoperations
f (X, Y, Z) = X'YZ + XY' + Y'Z'

andg (X, Y, Z) = X'YZ + X'YZ' + XY

Whichoneofthefollowingiscorrect?
A.
B.
C.
D.

Both{f} and{g} arefunctionallycomplete


Only{f} isfunctionallycomplete
Only{g} isfunctionallycomplete
Neither{f} nor{g} isfunctionallycomplete

gispreserving0aswhenallinputsarezero,outputisalways0andsogcannotbefunctionallycomplete.
fisnotpreserving0.
fisnotpreserving1.(whenallinputsare1,outputis0).
fisnotlinearasinXY'onlyone(odd)inputneedstobe1andinX'YZtwoinputs(even)needstobe1.
fisnotmonotoneaschangingYfrom0to1,cantakeffrom1to0.
fisnotselfdualasf(X,Y,Z)~f(~X,~Y,~Z)
So,fsatisfiesall5conditionsrequiredforfunctionalcompletenessandhenceBistheanswer.
http://cs.ucsb.edu/~victor/ta/cs40/postscriterion.pdf
name

GATE20153_2top
Let#bethebinaryoperatordefinedas
X#Y=X'+Y'whereXandYareBooleanvariables.
Considerthefollowingtwostatements.
(S1)(P#Q)#R=P#(Q#R)
http://gateoverflow.in/book

311/400

2/26/2015

GATEOverflow Book

(S2)Q#R=(R#Q)
Whicharethefollowingis/aretruefortheBooleanvariablesP,QandR?

A.
B.
C.
D.

OnlyS1istrue
OnlyS2istrue
BothS1andS2aretrue
NeitherS1norS2aretrue

Answer=B
(P#Q)#R=(P'+Q')#R
=P.Q+R'
whereas
P#(Q#R)=P'+(Q#R)'
=P'+(Q'+R')'
=P'+QR
overtomanu

GATE20153_5top
Thenumberof4digitnumbershavingtheirdigitsinnondecreasingorder(fromlefttoright)constructedbyusingthedigitsbelongingtotheset{1,2,3}is
________.
youcanarriveatasolutionbyconstructingagraphforeachstartingdigit.forexampleroot3meansstartingwith3itcanhave3child1,2,3andthe
constructiongoes
3canthreechildren1,2,3
2canhavetwochildren1,2
1canhaveonly1aschild.Graphneedtobedonetillthreelevels
andfinallycounttotalnumberofleaves
name

GATE20153_23top
SupposeU isthepowersetofthesetS = {1, 2, 3, 4, 5, 6} .ForanyT U ,let|T | denotethenumberofelementsinT andT denotethecomplementof
T .ForanyT , R U letT R bethesetofallelementsinT whicharenotinR .Whichoneofthefollowingistrue?

A.
B.
C.
D.

X U , (|X| = |X |)
X U , Y U , (|X| = 5, |Y | = 5
X U , Y U , (|X| = 2, |Y | = 3
X U , Y U , (XY = Y

andX Y = )
andXY = )

X )

AnswerD
AsXandYU,XandYaresubsetsofS
OptionAiswrongconsiderX={1,2}thereforeX'={3,4,5,6}|X|=2and|X'|=4
OptionBiswrongasanytwopossiblesubsetsofSwith5elementsshouldhaveatleast4elementsincommon.HenceXintersectionYnotnull
OptionCiswrong,considerX={1,2}y={3,4,5}andX\Y={1,2}whichisnotnull
overtomanu

GATE20153_41top
LetR bearelationonthesetoforderedpairsofpositiveintegerssuchthat((p, q), (r, s))
trueaboutR?

ifandonlyifp s

= q r

.Whichoneofthefollowingis

A. Bothreflectiveandsymmetric
http://gateoverflow.in/book

312/400

2/26/2015

GATEOverflow Book

B. Reflectivebutnotsymmetric
C. Notreflectivebutsymmetric
D. Neitherreflectivenorsymmetric

Thekeytrickhereistorealizethattherelationisoftheform:
{orderedpair,orderedpair}andnotsimplyorderedpair.
Ok,soforreflexive

(notpossibleforanypositiveintegersbanda)
butthatisacontradictionhenceitisnotreflexive.
now,forsymmetric

soitissymmetric.
henceCisthecorrectoption.

name

http://gateoverflow.in/book

313/400

2/26/2015

GATEOverflow Book

Combinatorytop
GATE2008_24top
LetP

1i2k

andQ

1i2k

i odd

(A)P
(B)P
(C)P
(D)P

,wherek isapositiveinteger.Then

i even

= Q k
= Q + k
= Q
= Q + 2k

Substitutek=3thenwegetp=9andq=12onverifyingwegetoptionA.
kireeti

GATE2002_13top
a. Inhowmanywayscanagivenpositiveintegern 2beexpressedasthesumof2positiveintegers(whicharenotnecessarilydistinct).Forexample,for
n = 3thenumberofwaysis2,i.e.,1+2,2+1.Giveonlytheanswerwithoutanyexplanation.
b. Inhowmanywayscanagivenpositiveintegern 3beexpressedasthesumof3positiveintegers(whicharenotnecessarilydistinct).Forexample,for
n = 4,thenumberofwaysis3,i.e.,1+2+1,2+1+1.Giveonlytheanswerwithoutexplanation.
c. Inhowmanywayscanagivenpositiveinteger n k beexpressedasthesumofkpositiveintegers(whicharenotnecessarilydistinct).Giveonlythe
answerwithoutexplanation.

a.n=2(1+1)n=3(1+2,2+1)n=4(1+3,3+1,2+2)n=5(1+4,4+1,2+3,3+2)
sox1+x2=n,x1,x2>0(no.ofintegralsol)
Thisissameasnumberofwaysofputtingn2(aswecan'thave0foreitherx1orx2)identicalballsintotwodistinctbins,whichisobtainedbyputtinga
divideracrossn2ballsandtakingallpossiblepermutationswithn2beingidentical.i.e.,(n2+1)!/(n2)!=(n1).Wecanalsousethefollowingformula
n2+21C

n1
21= C1

b.n=3(1+1+1)n=4(1+1+2,1+2+1,2+1+1)n=5(1+1+3,1+3+1,3+1+1,2+2+1,2+1+2.,1+2+2)
sox1+x2+x3=n,x1,x2,x3>0(no.ofintegralsol)
Here,wecanpermuten3itemswith2dividerswhichwillgive(n3+2)!/(n3)!2!
=(n1)!/(n12)!2!
=n1C2
c.nk+k1Ck1=n1Ck1
name

GATE2003_4top
LetAbeasequenceof8distinctintegerssortedinascendingorder.Howmanydistinctpairsofsequences,BandCaretheresuchthat
(i)eachissortedinascendingorder,
(ii)Bhas5andChas3elements,and
(iii)theresultofmergingBandCgivesA?
(A)2(B)30(C)56(D)256

answerC
selectany3elementsfromgiven8elements8C3
name

GATE2003_5top
ncouplesareinvitedtoapartywiththeconditionthateveryhusbandshouldbeaccompaniedbyhiswife.However,awifeneednotbeaccompaniedbyher
http://gateoverflow.in/book

314/400

2/26/2015

GATEOverflow Book

husband.Thenumberofdifferentgatheringspossibleatthepartyis
(A)2n C n

(B)3 n (C)

(2n)!
2

(D)2n C n

Possibleoutcome:onlywifecomes
bothcome
nonecome
so3x3x3x...ntime=3^n
name

GATE2005_35top

answerB
numberofdistinctBSTs=2nCn/(n+1)

name

GATE20141_49top
Apennantisasequenceofnumbers,eachnumberbeing1or2.Ann pennantisasequenceofnumberswithsumequalton .Forexample,(1, 1, 2) isa4
pennant.Thesetofallpossible1pennantsis(1) ,thesetofallpossible2pennantsis(2), (1, 1) andthesetofall3pennantsis(2, 1), (1, 1, 1), (1, 2) .Note
thatthepennant(1, 2)isnotthesameasthepennant(2, 1).Thenumberof10pennantsis________

Letwedenotenumberofnpennantsbyf(n),sof(10)isnumberof10pennants.
A10pennantmeanssumofnumbersinsequenceis10.Ifwelookatany9pennent,wecanmakeita10pennantbyadding1intothatsequence.Similarly,
wecanmakeany8pennanta10pennantbyadding2intothatsequence.
Soall10pennantscanbeformedby8pennantsand9pennants,andnootherpennant(sincewecanaddonly1or2intoasequence)
Sof(10)=f(9)+f(8)
Thisisinfactafibonaccisequence,inwhichF(1)=1,f(2)=2,sothissequencebecomes
1,2,3,5,8,13,21,34,55,89,..
Sof(10)=89.
name

GATE20142_49top
Thenumberofdistinctpositiveintegralfactorsof2014is_____________

Firstdoprimefactorizationof201421x191x531
Nowtogetafactorof2014,wecanchooseanycombinationoftheprimefactorsincluding0.i.e20and21arepossibleandsimilarlyforotherprimefactors
also,thereare2possibilities.So,totalnumberofpositiveintegralfactors
= 2 2 2 = 8

(Whenallthepowersofprimefactorsare0,weget1andwhenallthepowersaremaximum,wegetthegivennumber.)
name

GATE2011_29top
Wearegivenasetofn distinctelementsandanunlabeledbinarytreewithn nodes.Inhowmanywayscanwepopulatethetreewiththegivensetsothatit

http://gateoverflow.in/book

315/400

2/26/2015

GATEOverflow Book

becomesabinarysearchtree?
(A)0
(B)1
(C)n!
1

(D) n+1

2n

Cn

Givenbinarytreeisunlabeled.Soasitisgivenwearenotallowedtochangetheformationoftree.ThenTomakeitBSTwecanuseatmost1way.Asfor
particularstructurewecannotusen!arrangementofnodes(BecasuetheyarelebeledanditisBSTnotBT)
name

GATE1994_1.15top

no.ofsubstringsoflengthnis1
no.ofsubstringsoflengthn1is2
no.ofsubstringsoflengthn2is3
son(n+1)/2
name

GATE2008IT_24top
Theexponentof11intheprimefactorizationof300!is

1)
2)
3)
4)

27
28
29
30
300!is1*2*3*...*300
Nowthereare27multiplesof11from1to300,sotheywillinclude11asaprimefactoratleastonce.
Only121willcontainanextra11,allotherwillcontain11asafactoronlyonce.
Sototalnumberof11's=27+1=28.
Soexponentof11is28i.e.option2)
name

GATE2008IT_25top
Inhowmanywayscanbblueballsandrredballsbedistributedinndistinctboxes?

1)
2)
3)

(n+b1)! (n+r1)!
(n1)! b! (n1)! r!
(n+(b+r)1)!
(n1)! (n1)! (b+r)!
n!
b! r!
(n+(b+r)1)!

4)

n! (b+r1)

rredballscanbedistributedintondistinctboxesinC(n+r1,r)=.(n+r1)!/(n1)!r!

http://gateoverflow.in/book

316/400

2/26/2015

GATEOverflow Book

bblueballscanbedistributedinC(n+b1,b)=(n+b1)!/(n1)!b!
Byproductruletotalwaysare(n+b1)!(n+r1)!/(n1)!b!(n1)!r!
SOTHEANSWERISA.

name

GATE2005IT_46top
AlineLinacircuitissaidtohaveastuckat0faultifthelinepermanentlyhasalogicvalue0.SimilarlyalineLinacircuitissaidtohaveastuckat1faultif
thelinepermanentlyhasalogicvalue1.Acircuitissaidtohaveamultiplestuckatfaultifoneormorelineshavestuckatfaults.Thetotalnumberofdistinct
multiplestuckatfaultspossibleinacircuitwithNlinesis

A)

3N

B)

3N1

C)

2N1
2

D)
Answershouldbe3^N1.

Thisisbecausethetotalpossiblecombinations(i.ealinemayeitherbeatfault(in2waysi.estuckatfault0or1)oritmaynotbe,sothereareonly3
possibilitiesforaline)is3^N.Inonlyonecombinationthecircuitwillhavealllinestobecorrect(i.enotatfault.)Hence3^N1.(asithasbeensaidthat
circuitissaidtohavemultiplestuckupfaultifoneormorelineisatfault)
PleaseComment,ifanyonefindsitwrong.
name

Aprofessorwrites20multiplechoicequestions,eachwiththepossibleanswera,b,c,ord,fora
discretemathematicstest.Ifthenumberofquestionswitha,b,c,anddastheiransweris8,3,4,and
5,respectively,howmanydifferentanswerkeysarepossible,ifthequestionscanbeplacedinany
order?top
Wehavetoarrange8a's,3b's,4c'sand5d's..i.ePermutationtofindpossiblenumberofanswerkeysthatarepossible=20!butthealla'sareidentical,b's
areidentical,c'sareidenticalandd'sareidentical,thereforeAnsweris=20!/(8!.3!.4!.5!)=3491888400
name

Themaximumnumberofdistinctsubwordsoftheword"AXIOMATIZABLE"is:a)183b)111c)92
d)88top
Subwordsmeanslettersmustbeconsecutiveasintheword.Since,thegivenwordhas13letterswecanhave
13subwordsof1letter
12subwordsof2letters
11subwordsof3letters
....
1subwordof13letters
So,totalnumberofsubwords=13+12+...+1=13*7=91
Notwoconsecutivelettersarerepeatinginthegivenword.Butthereare3A's,and2I's.So,3subwordsoflength1arecountedextra.So,totalnumberof
distinctsubwords=913=88.
gatecse

http://gateoverflow.in/book

317/400

2/26/2015

GATEOverflow Book

GraphTheorytop
GATE2012_17top
LetG beasimpleundirectedplanargraphon10verticeswith15edges.IfG isaconnectedgraph,thenthenumberof<b>bounded</b>facesinany
embeddingofG ontheplaneisequalto
(A)3
(B)4
(C)5
(D)6
Foranyplanargraph,
n(no.ofvertices)e(no.ofedges)+f(no.offaces)=2
f=1510+2=7
numberofboundedfaces=no.offaces1
=71
=6
So,thecorrectanswerwouldbe(**D**).
Anonymous

directedgraphtop

Letn bethenumberofvertices.
Totalnumberofincomingedges=

7 n

Thisshouldbeequaltothetotalnumberofoutgoingedges.So,eitherallverticesmusthave7edgesleavingorsomeshouldhavemorethan7leavingwhile
otherscouldhavelessthan7leaving.But,itisguaranteedthatsomevertexwillhaveatleast7verticesleavingit.
So,(c)isthecorrectanswer.
Onlyifwerestrictn to8,exactlysevenedgesneedtoleaveeveryvertex.
name

Thenumberofdistinctsimplegraphswithuptothreenodesaretop
Thenumberofdistinctsimplegraphswithuptothreenodesare
A)15
B)10
C)7
D)9
Thenumberofmaxedgesasimplegraphcanhaveisn (n 1)/2 .
So,foragraphwith3 nodesthemaxnumberofedgesis3 .
Nowtherecanbe0 edges,1 edge,2 edgesor3 edgesina3 nodesimplegraph.
Sothetotalnumberofunlabledsimplegraphson3nodeswillbe4 .
Similarlyfortwonodegraphwehaveoptionof0 or1 edge.
Sothetotalnumberofsimplegraphsuptothreenodesare:
4 + 2 + 1 = 7

http://gateoverflow.in/book

318/400

2/26/2015

GATEOverflow Book

name

GATE2012_38top
LetGbeacompleteundirectedgraphon6vertices.IfverticesofGarelabeled,thenthenumberof
distinctcyclesoflength4inGisequalto
(A)15(B)30(C)90(D)360

From6verticeswecanselect4distinctverticesin6C4=15ways.
Now,with4vertices,wecanformonly3distinctcycles.[Seebelow]
So,totalno.ofdistinctcyclesoflength4=15*3=45.
No.ofcyclicpermutationsofnobjects=(n1)!andforn=4,weget3!=6ways.Butnumberofdistictcyclesinagraphisexactlyhalfthenumberofcyclic
permutationsasthereisnoleft/rightorderinginagraph.Forexampleabcdandadcbaredifferentpermutationsbutinagraphtheyformthesame
cycle.
Since,45wasnotinthechoice,marksweregiventoallinGATE.
gatecse

GATE2002_1.25top
Themaximumnumberofedgesinannodeundirectedgraphwithoutselfloopsis
A.
B.
C.
D.

n(n1)
2

n 1
(n+1)(n)
2

Inagraphofnverticesyoucandrawanedgefromavertexton1vertexwewilldoitfornverticessototalnumberofedgesisn(n1)noweachedgeis
countedtwicesotherequiredmaximumnumberofedgesisn(n1)/2
name

GATE2003_36top
Howmanyperfectmatchingarethereinacompletegraphof6vertices?
(A)15(B)24(C)30(D)60

Note:Tounderstandthesolutionpleasegothroughthedefinitionsofperfectmatching
Thecompletegraphknhaveaperfectmatchingonlywhenniseven..Soletn=2m.
LettheverticesbeV1,V2,......,V2m.
v1canbejoinedtoanyother2m1vertices
v2canbejoinedtoanyother2m3vertices
SimilarlygotillV2mwhichwillhaveonlyonevertextobejoinedwith..
NoofPerfectmatches=(2m1)(2m3)(2m5).....(3)(1)
Intheabovequestion2m=6
SoNo.ofperfectmatches=5*3*1=15
Hunaif

GATE2003_40top
AgraphG

= (V , E)

satisfies|E|

3|V | 6

.ThemindegreeofG isdefinedasminvV {degree(v)} .Therefore,mindegreeofG cannotbe

(A)3(B)4(C)5(D)6
LetthemindegreeofGisx.thenGhasatleast|v|*x/2edges.
|v|*x/2<=3*|v|6
http://gateoverflow.in/book

319/400

2/26/2015

GATEOverflow Book

forx=6,weget0<=6,Therefore,mindegreeofGcannotbe6.
Correctansweris(D).
name

GATE2004_77top

Themaxdegreeofthevertexis4soweneedatleast5colourstocolourthegraph
name

GATE2005_11top
LetGbeasimplegraphwith20verticesand100edges.ThesizeoftheminimumvertexcoverofGis8.then,thesizeofthemaximumindependentsetofGis:
(A)12(B)8(C)lessthan8(D)morethan12
Vertexcover:Asetofverticessuchthateachedgeofthegraphisincidenttoatleastonevertexoftheset.

Therefore,removingalltheverticesofthevertexcoverfromthegraphresultsinanisolatedgraphandthesamesetofnodeswouldbetheindependentsetin
theoriginalgraph.
sizeofminimumvertexcover=8
sizeofmaximumindependentset=208=12
Therefore,correctanswerwouldbe(A).
name

GATE2013_25top
Whichofthefollowingstatementsis/areTRUEforundirectedgraphs?
P:Numberofodddegreeverticesiseven.
Q:Sumofdegreesofallverticesiseven.
(A)Ponly(B)Qonly(C)BothPandQ(D)NeitherPnorQ
Botharecorrect
P:sumofodddegree+sumofevendegree=2*noofedges
sumofodddegree=2*noofedgessumofevendegree
Therighthandsidemustbeevenasthedifferenceof2evennumbersisalwayseven.
Q:eachedgeiscountedtwicesosumofdegreeisalwayseven
name

GATE2006_71,72,73top
CommonDataforQuestions71,72,73:
The2 n verticesofagraphGcorrespondstoallsubsetsofasetofsizen ,forn
intersectinexactlytwoelements.

.TwoverticesofGareadjacentifandonlyifthecorrespondingsets

71.ThenumberofverticesofdegreezeroinGis:
(A)1
(B)n
(C)n + 1
2

http://gateoverflow.in/book

320/400

2/26/2015

GATEOverflow Book

(D)2 n

72.ThemaximumdegreeofavertexinGis:
(A)(

n/2
2

)2

n/2

(B)2 n2
(C)2 n3

(D)2 n1
73.ThenumberofconnectedcomponentsinGis:

(A)n
(B)n + 2
(C)2 n/2
(D) 2n
n

71.C.no.ofverticeswithdegreezero=no.ofsubsetswithsize<=1=n+1,asedgesarethereforeveryvertexwithtwoormoreelementsaswehavea
vertexforallsubsetsofn.
72C.max(kC2.2(nk))=3C2.2(n3)=3.2(n3).
Letthevertexhavingthemaxdegreecontainkelements.Now,asperthegivencondition,itcanhaveedgestoallverticeshavingteocommonelements
(exactly2common).So,wecanchoosethe2commonelementsinkC2ways.Now,foreachofthese2pairofelements,itcanhaveanedgetoavertex
containingnkelements+the2commonelements.Thiswillbeequalto2nkpossiblesubsetsasthe2commonelementsmustalwaysbepresentandotherk
elementsmustalwaysbeabsent.So,wegetthedegreeas
kC *2(nk)
2

Now,ouranswerwillbethemaximumvalueforthis.Wecandifferentiatethis(w.r.tk)andequateto0.Butinotherwaywecantrydifferentvaluesfork
startingwith2.Asweseeifweincreasekfrom2onwards,the2(nk)termgetsdividedby2.TheothertermiskC2,whichgoeslike1,3,6,10...fork=2,3,
4,5,....So,wegetthemax.degreefork=3or4andthiswillbe3*2(n3).
73.B.n+1(subsetsofsize<2arealldisconnected)+1(subsetsofsize>=2areallconnected)=n+2
name

GATE20141_51top
ConsideranundirectedgraphG whereselfloopsarenotallowed.ThevertexsetofG is{(i, j)
and(c, d) if|a c| 1 and|b d| 1.Thenumberofedgesinthisgraphis______.

1 i 12, 1 j 12} .Thereisanedgebetween(a, b)

Ifyouthinkofa12*12grid(likeachessboardofsize12*12),theneacheachpoint(i,j),whichisinithrowandjthcolumn,isavertex(i,j).
Nowweareallowedtoconnectonlythosepointswhichareatmost1distanceapart(inbothhorizontalandverticaldirection).Sowewillconnectonly
horizontalneighbours,verticalneighbours,anddiagonalneighbours.
Sohorizontaledgesoneachroware11i.e.11*12=132horizontaledges.Similarlywehave132verticaledges.
Tocountdiagonaledges,thinkof1*1squareboxesinwhichdiagonalsmeeteachother.Thereare11*11suchsquareboxes,andeachboxcontains2
diagonals,sototaldiagonals=242.
Sototaledges=132+132+242=506.
name

GATE20141_52top
Anorderedn tuple(d1 , d2 , . . . . , dn ) withd1 d2 . . . dn iscalledgraphicifthereexistsasimpleundirectedgraphwithn verticeshavingdegrees
d 1 , d 2 , . . . , d n respectively.Whichoneofthefollowing6tuplesisNOTgraphic?
(A)(1, 1, 1, 1, 1, 1)
(B)(2, 2, 2, 2, 2, 2)
(C)(3, 3, 3, 1, 0, 0)
(3, 2, 1, 1, 1, 0)

http://gateoverflow.in/book

321/400

2/26/2015

GATEOverflow Book
(D)(3, 2, 1, 1, 1, 0)

Thiscanbesolvedusinghavelhakimitheorem.
Theideaissimple:Removeavertex,whichresultsintodecreaseofdegreeby1ofeachvertexwhichwasconnectedtoit.Keepremovinglikethis,andifwe
getanynegativedegree,thedegreesequencewasnotpossible.
Weneednotcheck(A)and(B)astheyareclearlygraphs:(A)is3disconnectededges,(B)is2disconnectedtriangles.
For(C),weremovefirstvertexofdegree3,andthusdecreasedegreeby1ofnext3vertices,soweget(2,2,0,0,0),thenweremovevertexofdegree2,and
decreasedegreeofnext2verticestoget(1,1,0,0).Sincewegetnegativedegree,originaldegreesequenceisimpossible.
For(D):(3,2,1,1,1,0)>(1,0,0,1,0).Nowsincethislistisnotsorted(whichisrequiredtoapplyfurtherstepsofalgorithm),wesortittoget(1,1,0,0,0).Then
wecontinueouralgorithmonthislisttoget(0,0,0,0),whichisvalid(4isolatedvertices).
So(C)isanswer.
name

GATE20142_3top
Themaximumnumberofedgesinabipartitegraphon12verticesis____

Maximumno.ofedgesoccurinacompletebipartitegraphi.e.wheneveryvertexhasanedgetoeveryoppositevertex.
Numberofedgesinacompletebipartitegraphismn,wheremandnareno.ofverticesoneachside.Thisquantityismaximumwhenm=ni.e.whenthere
are6verticesoneachside,soansweris36.
name

GATE20142_51top
Acycleonn verticesisisomorphictoitscomplement.Thevalueofn is_____.

itsn=5only.
onlyC5isisomorphictoitscomplement.

name

GATE20143_3top
LetG beagroupwith15elements.LetLbeasubgroupofG .ItisknownthatL

andthatthe

sizeofLisatleast4 .ThesizeofLis__________.

Lagrangestheorem:ForanyfinitegroupG,theorder(numberofelements)ofeverysubgroupLofGdividestheorderofG.
Ghas15elements.
Factorsof15are1,3,5,and15.
SincegiventhesizeofLisatleast4(1and3eliminated)andnotequaltoG(15eliminated),theonlysizeleftis5.
SizeofLis5.

name
http://gateoverflow.in/book

322/400

2/26/2015

GATEOverflow Book

GATE20143_51top
IfG istheforestwithn verticesandk connectedcomponents,howmanyedgesdoesG have?
(A)n/k
(B)n/k
(C)n k
(D)n k + 1

Aforestisanacyclicgraph(withnocycle),i.eallthesecomponentsareatree.Withkcomponentstherearekroots.Andwheneveranewnodeisaddedtoatree
onlyasingeedgeisintroduced.
Withkroots,remainingnodesare(nk)eachofwhichintroducesanedge.Hencethereare(nk)*1=(nk)edges.

name

GATE2011_17top
K4andQ3aregraphswiththefollowingstructures.

WhichoneofthefollowingstatementsisTRUEinrelationtothesegraphs?
(A)K4isaplanarwhileQ3isnot
(B)BothK4andQ3areplanar
(C)Q3isplanarwhileK4isnot
(D)NeitherK4norQ3isplanar

(B)Bothareplannargraphs
Bothgraphscanbedrawnonaplanewithouthavinganycrossededges.
name

GATE1994_2.5top
Thenumberofedgesinaregulargraphofdegreedandnverticesis____________
inacompletegraphwhichis(n1)regular(wherenisthenoofvertices)hasedgesn(n1)/2
nverticesareadjacentton1verticesandanedgecontributestwodegreesodividingby2.
soindregulargraphNoofedgeswillben*d/2
name

GATE1995_1.25top
Theminimumnumberofedgesinaconnectedcyclicgraphonn verticesis:
(a)n 1
(b)n
(c)n + 1
(d)Noneoftheabove
B.
Formakingacyclicgraph,theminimumnumberofedgeshavetobeequaltothenumberofvertices.
name

http://gateoverflow.in/book

323/400

2/26/2015

GATEOverflow Book

GATE1995_24top
Provethatinfinitegraph,thenumberofverticesofodddegreeisalwayseven.
Inanyfinitegraph,
Sumofdegreeofallthevertices=2*numberofegdes
sumofdegreeofallthevericeswithevendegree+sumofdegreeofallthevericeswithodddegree=2*numberofegdes
evennumber+sumofdegreeofallthevericeswithodddegree=evennumber
ItispossibleiffNumbeofodddegreeverticesareeven.
name

GATE2008IT_27top
Gisasimpleundirectedgraph.SomeverticesofGareofodddegree.AddanodevtoGandmakeitadjacenttoeachodddegreevertexofG.Theresultant
graphissuretobe

1)
2)
3)
4)

regular
complete
Hamiltonian
Euler
Inanysimpleundirectedgraph,totaldegreeofallverticesiseven(sinceeachedgecontributes2degrees).Sonumberofverticeshavingodddegreesmustbe
even,otherwisetheirsumwouldhavebeenodd,makingtotaldegreealsoodd.
NowSinglevertexvisconnectedtoalltheseevennumberofvertices(whichhaveodddegrees).Sodegreeofvisalsoeven.Moreover,nowdegreeofall
verticeswhichareconnectedtovisincreasedby1,henceverticeswhichhadodddegreeearliernowhaveevendegree.
Sonow,allverticesingraphhaveevendegree,whichisnecessaryandsufficientconditionforeulergraph.So4)iscorrect.
name

GATE2004IT_37top
Whatisthenumberofverticesinanundirectedconnectedgraphwith27edges,6verticesofdegree2,3verticesofdegree4andremainingofdegree3?

A)
B)
C)
D)

10
11
18
19
sumofdegreeofallthevertices=2*numberofedges
2*6+4*3+3*x=27*2
x=10.
Numberofvertices=6+3+x=19
Thecorrectansweris(D).
name

GATE2005IT_56top
LetGbeadirectedgraphwhosevertexsetisthesetofnumbersfrom1to100.Thereisanedgefromavertexitoavertexjiffeitherj=i+1orj=3i.The
minimumnumberofedgesinapathinGfromvertex1tovertex100is

A)
B)
C)
D)

http://gateoverflow.in/book

4
7
23
99

324/400

2/26/2015

GATEOverflow Book

Edgesetconsistsofedgesfromitojusingeither
1)j=i+1OR
2)j=3i.
Secondoptionwillhelpusreachfrom1to100rapidly.
Thetricktosolvethisquestionistothinkinreverseway.Insteadoffindingapathfrom1to100,trytofindapathfrom100to1.
Theedgesequencewithminimumnumberofedgesis13910113399100whichconsistsof7edges.
Theanswerisoption2.
Shridhar

Maxnoofedgesindisconnectedgraphtop
Inasimpleundirectedgraphwithnverticeswhatismaximumnoofedgesthatyoucanhavekeepingthegraphdisconnected?
A)nC21
B)nC2
C)n1C2
Dn1C21

AnsisC)....Pleaseexplainhow?

Maximumnumberofedgesinacompletegraph=nC2
Sincewehavetofindadisconnectedgraphwithmaximumnumberofedgeswithnvertices.Thereforeourdisconnectedgraphwillhaveonlytwopartions
becauseasnumberofpartitionincreasesnumberofedgeswilldecrease.
NowassumethatFirstpartitionhasxverticesandsecondpartitionhas(nx)vertices.
totalnumberofedges=xC2+(nx)C2
=1/2*(2x22nx+n2n),where,1<=x<=n1
Itwouldbemaximumatbothextreme(atx=1orx=n1).
Therefore,totalnumberofedges=nC2(n1)=n1C2
name

Numberofdistinctgraphstop
Numberofdistinctgraphswithpverticesandqedges(pnotequaltoq)isalwaysequalto
a)p
b)q
c)min(p,q)
d)max(p,q)
e)noneofthis
Ithink,Noneofthisshouldbeanswerforthisquestion.totalnoofdistinctgraphswillbe
p(p1)/2Cq
name

GATE20152_28top
Agraphisselfcomplementaryifitisisomorphictoitscomplement.Forallselfcomplementarygraphsonn vertices,n is

A.
B.
C.
D.

Amultipleof4
Even
Odd
Congruentto0mod4,or,1mod4.

http://gateoverflow.in/book

325/400

2/26/2015

GATEOverflow Book

AnsD

E(G) + E(G ) =

n(n1)
2

,whereE(G)denotestheno.ofedgesinG .(G + G willbeacompletegraph)

forselfcomplementarygraphs,E(G)
E(G) =

= E(G )

n(n1)

name

GATE20152_50top
Inaconnectedgraph,abridgeisanedgewhoseremovaldisconnectsthegraph.Whichoneofthefollowingstatementsistrue?

A.
B.
C.
D.

Atreehasnobridges
Abridgecannotbepartofasimplecycle
Everyedgeofacliquewithsize3isabridge(Acliqueisanycompletesubgraphofagraph)
Agraphwithbridgescannothavecycle

AnsB
Inacycleifweremoveanedge,itwillstillbeconnected.So,bridgecannotbepartofacycle.
name

GATE20151_54top
LetGbeaconnectedplanargraphwith10vertices.Ifthenumberofedgesoneachfaceisthree,thenthenumberofedgesinGis_______________.

ByEulerformulaforconnectedplanargraph,
ne+f=2
103f/2+f=2(Anedgeispartoftwofaces)
f/2=8
f=16
e=3f/2=24
http://www.personal.kent.edu/~rmuhamma/GraphTheory/MyGraphTheory/planarity.htm
name

http://gateoverflow.in/book

326/400

2/26/2015

GATEOverflow Book

LinearAlgebratop
GATE2012_11top
LetAbethe2 2matrixwithelementsa_11

= a12 = a_21 = +1

anda_22

= 1

.ThentheeigenvaluesofthematrixA19 are

(A)1024 and1024
(B)10242 and10242
(C)42 and42
(D)5122 and5122

CharacteristicEquationisA I

= 0
1

1
1

= 0

(1

)(1 ) 1

++

= 0

1 = 0

2 = 0

= +2

and2

soaccordingtopropertiesofEigenvalues,
eigenvaluesofA19 =(eigenvalueofA)19
=(2 )

19

and(2 )

19

=option(D)
name

GATE2007_25top
LetAbea4 4matrixwitheigenvalues5,2,1,4.Whichofthefollowingisaneigenvalueofthematrix

,whereI isthe4 4identitymatrix?


A)5B)7C)2D)1

Ansis(C)2
Ax = x

,whereistheeigenvalueofA .Hence(A I )x

= 0

or

|A I | = 0

So,forourgivenmatrix,wehave

Thisisa2 2blockmatrixwherethefirstandlastandthesecondandthirdelementsarethesame.So,applyingtheformulafordeterminantofa
blockmatrixasgivenhere(secondlastcase)https://en.wikipedia.org/wiki/Determinant#Block_matricesweget

|A I I | |A I + I | = 0

|A ( + 1)I | |A ( 1)I | = 0

EachoftheeigenvalueofA isthesolutionoftheequation|A I | = 0 (beingtheeigenvalueofA ).So,wecanequate + 1 and 1 toanyof


theeigenvalueofA ,andthatwillgetourvalueof.Ifwetake = 1 ,weget = 2,andthatisoneofthechoice.Fornootherchoice,thisequation
holds.So,(c)2istheanswer.

http://gateoverflow.in/book

327/400

2/26/2015

GATEOverflow Book

name

GATE2003_41top
Considerthefollowingsystemoflinearequations

12

Noticethatthesecondandthethirdcolumnsofthecoefficientmatrixarelinearlydependent.Forhowmanyvaluesof,doesthissystemofequationshave
infinitelymanysolutions?
(A)0 (B)1
(C)2 (D)3

Determinant=0.Thereforeapplyreductionmethodon(A|B)

R R

22

1,

R ,R

30.5

31.5

obtaintheresultantmatrix

orinfinitelymanysolutions,wemusthave2+1.5a=0i.e.,a=4/3soforonly1valueofa,thissystemhasinfinitelymanysolutions.Sooption(B)iscorrect.

name

GATE2004_27top
LetA,B,C,Dbenxnmatrices,eachwithnonzerodeterminant.IfABCD=I,thenB1is
A.
B.
C.
D.

D1C1A1
CDA
ADC
Doesnotnecessarilyexist

Given
ABCD=I
multiplylhs,rhsbyA1
A1ABCD=A1I(positionofA1onbothsidesshouldbeleft)
=>BCD=A1
=>BCDD1=A1D1
=>BC=A1D1
=>BCC1=A1D1C1
=>B=A1D1C1
NowB1=(A1D1C1)1
B1=CDA
name

GATE2013_3top
http://gateoverflow.in/book

328/400

2/26/2015

GATEOverflow Book

WhichoneofthefollowingdoesNOTequal
1

2
2

?
(A)
1

x(x + 1)

x + 1

y(y + 1)

y + 1

z(z + 1)

z + 1

(B)
1

x + 1

y + 1

z + 1

+ 1

+ 1

+ 1

(C)
0

x y

y z

x + y

y + z

x
y

y
z
z

(D)
x
y

+ y
+ z
z

Answer is A.

name

GATE1998_1.2top

Therearenosolutions.
Ifwemultiply1stequationby4,weget
4x+8y=20
But2ndequationsays
4x+8y=13
Clearly,therecannotbeanypairof(x,y),whichsatisfiesbothequations.
name

http://gateoverflow.in/book

329/400

2/26/2015

GATEOverflow Book

GATE1998_2.1top

AnsD
name

GATE1998_2.2top

AnswerisB
R2>R2R1
R3>R3R2
youwillgtdet=(ab)*(ac)*(b+c)
inmatrixoperations,youcannotmultiplyrowsorcolumns.Thatwillnotyieldthesamematrix.Soabcisnotcorrect
name

GATE20142_47top
Theproductofthenonzeroeigenvaluesofthematrixis____

LetEigenvaluebeX.Now,equatingthedeterminantofthefollowingto0givesusthevaluesforX.TofindXinthefollowingmatrix,wecanequatethe
determinantto0.Forfindingthedeterminantwecanuserowandcolumnadditionsandmakethematrixatriangularone.Thendeterminantwilljustbethe
productofthediagonalswhichshouldequateto0.

1X
0
0
0
1

0
1X
1
1
0

0
1
1X
1
0

0
1
1
1X
0

1
0
0
0
1X

R1R1+R5,R4R4R3
2X
0
0

0
1X
1

http://gateoverflow.in/book

0
1
1X

0
1
1

2X
0
0
330/400

2/26/2015

GATEOverflow Book

0
1

0
0

X
0

X
0

0
1X

TakingXoutfromR4,2XfromR1,(so,X=2isoneeigenvalue)
1
0
0
0
1

0
1X
1
0
0

0
1
1X
1
0

0
1
1
1
0

1
0
0
0
1X

R2R2R3,R5R5R1
1
0
0
0
0

0
X
1
0
0

0
X
1X
1
0

0
0
1
1
0

1
0
0
0
X

0
X
2X
0
0

0
0
1
1
0

1
0
0
0
X

C3C3+C4
1
0
0
0
0

0
X
1
0
0

TakingXoutfromR2
1
0
0
0
0

0
1
1
0
0

0
1
2X
0
0

0
0
1
1
0

1
0
0
0
X

0
1
3X
0
0

0
0
1
1
0

1
0
0
0
X

R3R3+R2
1
0
0
0
0

0
1
0
0
0

Now,wegotatriangularmatrixanddeterminantofatriangularmatrixisproductofthediagonal.
So(3X)(X)=0=>X=3orX=0.So,X=3isanothereigenvalueandproductofnonzeroeigenvalues=2*3=6.
https://people.richland.edu/james/lecture/m116/matrices/determinant.html
name

GATE20143_5top
IfV1 andV2 are4 dimensionalsubspacesofa6 dimensionalvectorspaceV ,thenthesmallestpossibledimensionofV1

V2 is_____.

A6dimensionalvectorspace{a1,a2,a3,a4,a5,a6}
LetV1be{a1,a2,a3,a4}
andV2be{a3,a4,a5,a6}
V1V2 = {a3,a4}
This is the smallest possible dimension, which is 2.

Thelargestpossibledimensionwillbe4,whenV1=V2
name

GATE2011_40top
Considerthematrixasgivenbelow.

http://gateoverflow.in/book

331/400

2/26/2015

GATEOverflow Book

WhichoneofthefollowingoptionsprovidestheCORRECTvaluesoftheeigenvaluesofthematrix?
(A)1,4,3
(B)3,7,3
(C)7,3,2
(D)1,2,3

AnswerisA.

name

GATE1997_1.3top

Asit'suppertraingularmatrix...Sodeterminantwillbeproductofmaindiagonalelement.
det(A)=6*2*4*1=48.
Similarconceptcanbeappliead,ifMatrixislowertriangularorDiagonalMatrix
durgesh

GATE2008IT_29top
IfMisasquarematrixwithazerodeterminant,whichofthefollowingassertion(s)is(are)correct?
(S1)EachrowofMcanberepresentedasalinearcombinationoftheotherrows
(S2)EachcolumnofMcanberepresentedasalinearcombinationoftheothercolumns
(S3)MX=0hasanontrivialsolution
(S4)Mhasaninverse

1)
2)
3)
4)

S3andS2
S1andS4
S1andS3
S1,S2andS3

SinceMhaszerodeterminant,itsrankisnotfulli.e.ifMisofsize3*3,thenitsrankisnot3.Sothereisalinearcombinationofrowswhichevaluatesto0
i.e.

andthereisalinearcombinationofcolumnswhichevaluatesto0i.e.

NowanyrowRicanbewrittenaslinearcombinationofotherrowsas:

Similaristhecaseforcolumns.
NowMX=0alwayshasonesolution:X=0(whichiscalledtrivialsolution).Nowif|M|=0,thenMX=0hasnontrivialsolutionsalso.

http://gateoverflow.in/book

332/400

2/26/2015

GATEOverflow Book

So(S1),(S2),and(S3)aretrue.Sooption4)iscorrect.
name

GATE2004IT_6top
Whatvaluesofx,yandzsatisfythefollowingsystemoflinearequations?

12

A)
B)
C)
D)

x=6,y=3,z=2
x=12,y=3,z=4
x=6,y=6,z=4
x=12,y=3,z=0
Correctansweris(C).Itcanbeeasilyverifiedbykeepingthevalueofvariablesintheequations.
name

GATE2004IT_36top
IfmatrixX

= [

a
a

+ a 1

1 a

andX

X + I = O

(I istheidentitymatrixandO isthezeromatrix),thentheinverseofX is

A)

B)

C)

D)

1 a
a

1 a
a

a + 1

a
a
a

+ a 1

a + 1
1

1 a
a

1 a

It'saverysimplequestion,Weneedtocalculatetheinverseofa2x2matrix,
InverseofamatrixA=A^1=Adjoint(A)/determinantofA
adjointofA=[cofactorsofA]^T,butfor2x2matrixwehavedirectforumla:

A=ab
cdisa2x2matrixthen
AdjointofA=db
ca
|A|=adbc
soansweris(B)
name

GATE20152_5top
Thelargerofthetwoeigenvaluesofthematrix[

is_______.

ForfindingtheEigenValuesofaMatrixweneedtobuildtheCharacteristicequationwhichisoftheform,

WhereAisthegivenMatrix.
isaconstant
Iistheidentitymatrix.
We'llhaveaLinearequationaftersolving
http://gateoverflow.in/book

.Whichwillgiveus2rootsfor .
333/400

2/26/2015

GATEOverflow Book

(4 )(1 )10=0
45 + 2=10
25

6=0

( 6)( +1)=0
So =1,6.
6islargerandhenceistheAnswer.

name

GATE20152_27top
Performthefollowingoperationsonthematrix

45

105

13

195

i. Addthethirdrowtothesecondrow
ii. Subtractthethirdcolumnfromthefirstcolumn.
Thedeterminantoftheresultantmatrixis_____.
AnsZero,rowandcolumntransformationsdoesn'taffectdeterminant.
name

GATE20151_18
top
IntheLUdecompositionofthematrix[

,ifthediagonalelementsofU areboth1,thenthelowerdiagonalentryl22 ofLis_________________.

5
L11=2
L11*U12=2
Solving,U12=1
L21=4
L21*U12+L22=9
Solving,L22=5
GATERush

GATE20151_36top
Considerthefollowing2 2matrixA wheretwoelementsareunknownandaremarkedbya andb .Theeigenvaluesofthismatrixare1and7.Whatarethe
valuesofa andb ?
A = (

A.
B.
C.
D.

b a

a = 6, b = 4
a = 4, b = 6
a = 3, b = 5
a = 5, b = 3

As,weknowproductofeigenvaluesofamatrixisequaltodeterminantofthatmatrix.
so,
(1)7
=det(A)
=(1a)(4b)
http://gateoverflow.in/book

334/400

2/26/2015

GATEOverflow Book

so,a4b=7(1)
also,trace(sumofthediagonalelements)ofamatrixisequaltosumofeigenvaluesofthematrix.
so,1+a=1+7=6
so,a=5(2)
fromequation(1)and(2)
b=3
So,answerisD

Priya_das

http://gateoverflow.in/book

335/400

2/26/2015

GATEOverflow Book

NumericalMethodstop
GATE20142_46top
IntheNewtonRaphsonmethod,aninitialguessofx0

= 2

ismadeandthesequencex0 , x1 , x2
0.75x

2x

isobtainedforthefunction

2x + 4 = 0

Considerthestatements
I. x3 = 0
II. Themethodconvergestoasolutioninafinitenumberofiterations.
WhichofthefollowingisTRUE?
(A)OnlyI
(B)OnlyII
(C)BothIandII
(D)NeitherInorII

x n+1 = x n

f (x) = 0.75x

f (x) = 2.25x

So,x1

(x n )

2x

forNewtonRaphsonmethod(Seethelinkbelow)
2

2x + 4

4x 2

f (2) = 9 8 2 = 1
2

= 2

x2 = x1

Sincex2
So,x3

f (2) = 2

f (x n )
f

f (x 1 )
f

= x0

= 0

(x 1 )

= 2 2 = 0

= 0

4
2

,wewillgetx3

= 2

= x1 = 0

,andthemethodneverconverges.Achoice.

https://www.math.ubc.ca/~anstee/math104/104newtonmethod.pdf
name

GATE2008IT_30top
Considerthefunctionf(x)=x22x1.SupposeanexecutionoftheNewtonRaphsonmethodtofindazerooff(x)startswithanapproximationx0=2ofx.
Whatisthevalueofx2,theapproximationofxthatalgorithmproducesaftertwoiterations,roundedtothreedecimalplaces?

1)
2)
3)
4)

2.417
2.419
2.423
2.425

Innewtonmethod,ifcurrentguessisxcur,thennewguessxnewis
xnew=xcurf(xcur)/f'(xcur)
NowInitially,xcur=2,soafter1stiteration,
xnew=2(1)/2=2.5
Nowxcurbecomes2.5,soafter2nditeration,
xnew=2.5(0.25)/3=2.417
name
http://gateoverflow.in/book

336/400

2/26/2015

GATEOverflow Book

GATE20153_50top
Thevelocityv(inkilometer/minute)ofamotorbikewhichstartsformrest,isgivenatfixedintervalsoftimet(inminutes)asfollows:
t
v

2
10

4
18

6
25

8
29

10
32

12
20

14
11

16
5

18
2

20
0

Theapproximatedistance(inkilometers)roundedtotwoplacesofdecimalscoveredin20minutesusingSimpson's1/3 rd ruleis________.

Thetotaldistancecoveredisgivenbytheareaunderthespeedcurveandcanbecalculatedbyintegratingthespeedcurveequationinthegivenrange.Inthe
question,exactspeedfunctionisnotgiven,butthespeedatdifferenttimeinstantsisgiven.
Questionisaskingthedistancecoveredin20minutes.Accordingtothequestion,themotionstartsatt=0andendsatt=20.Sothespeedfunctionhastobe
integratedintheranget=0tot=20.Thereforeanadditionalpoint(t=0)hastobeconsideredwhileintegrating.Afteraddingt=0,numberofpointswillbe11
andnumberofintervalswillbe10.Andtheanswerwillbe309.33.
Distance
S =

(ba)
3n

[f (0) + 4(f (2) + f (6) + f (10) + f (14) + f (18))

+ 2(f (4) + f (8) + f (12) + f (16) + f (20))]

2
3

[0 + 4(10 + 25 + 32 + 11 + 2)

+ 2(18 + 29 + 20 + 5)]
= 309.33

Ref:http://www.saylor.org/site/wpcontent/uploads/2011/11/ME2057.2TEXT2.pdf
ashishacm

http://gateoverflow.in/book

337/400

2/26/2015

GATEOverflow Book

Calculustop
GATE2012_9top
Considerthefunctionf (x)

= sin(x)

intheintervalx

= [/4, 7/4]

.Thenumberandlocation(s)ofthelocalminimaofthisfunctionare

(A)One,at/2
(B)One,at3/2
(C)Two,at/2 and3/2
(D)Two,at/4 and3/2
Sinefunctionincreasestill/2 andsofortheconsideredinterval/4 wouldbealocalminimum.From/2 ,valueofsinekeepsondecresingtill3/2
andhence3/2 wouldbeanotherlocalminima.So,(D)isthecorrectanswerhere.
gatecse

GATE2009_25top

/4
0

(1 tanx)/(1 + tanx) dx

(A)0
(B)1
(C)ln2
(D)1/2ln2

AnswerisD.
name

GATE1998_8top
(a)Findthepointsoflocalmaximaandminima,ifany,ofthefollowingfunctiondefinedin0
x

6x

x 6

+ 9x + 15

(b)Integrate

x cos xdx

http://gateoverflow.in/book

338/400

2/26/2015

GATEOverflow Book

(a)
so
Now
f''(1)<0,sox=1ispointoflocalmaxima,f''(3)>0,sox=3ispointoflocalminima.
Alsotheendpoints0and6arecriticalpoints.0ispointoflocalminima,becauseitistotheleftofx=1(whichispointofmaxima).Similarlyx=6ispoint
oflocalmaxima.
(b)Sincexcosxisanoddfunction,bythepropertiesofdefiniteintegration,answeris0.

name

GATE20141_47top
Afunctionf (x) iscontinuousintheinterval[0, 2].Itisknownthatf (0)
(A)Thereexistsay intheinterval(0, 1)suchthatf (y)

= f (2) = 1 andf (1) = 1 .Whichoneofthefollowingstatementsmustbetrue?

= f (y + 1)

(B)Foreveryy intheinterval(0, 1),f (y) =f (2 y)


(C)Themaximumvalueofthefunctionintheinterval(0, 2)is1
(D)Thereexistsay intheinterval(0, 1)suchthatf (y) =f (2 y)

Let'sdefineanewfunctiong,
g(y)=f(y)f(y+1)
Sincefunctionfiscontinuousin[0,2],thereforegwouldbecontinuousin[0,1]
g(0)=2,g(1)=2
sincegiscontinuousandgoesfromnegativetopositivevaluein[0,1].thereforeatsomepointgwouldbe0in(0,1).
g=0=>f(y)=f(y+1)forsomeyin(0,1).

Therefore,correctanswerwouldbe(A).
name

GATE20143_47top
Thevalueoftheintegralgivenbelowis

cos x dx

(A)2
(B)
(C)
(D)2

ansisA

name
http://gateoverflow.in/book

339/400

2/26/2015

GATEOverflow Book

GATE2011_31top
/2

Giveni

= 1 ,whatwillbetheevaluationofthedefiniteintegral

cos x+i sin x


cos xi sin x

dx ?

(A)0
(B)2
(C)i
(D)i

AnswerisD.

name

GATE1996_3top
Letf beafunctiondefinedby

forx 1
2

f (x) = ax + bx + c

x + d

for1 < x 2
forx > 2

Findthevaluesfortheconstantsa ,b ,c andd sothatf iscontinuousanddifferentiableeverywhereontherealline.

fisdifferentiableat1if

=>2=2a+b(1)
fisdifferentiableat2if

=>4a+b=1(2)
Solving(1)and(2),weget
a=0.5,b=3
Nowfhastobecontinouson1also,so

=>1=a+b+c
=>c=1.5
Similarlyfhastobecontinouson2also,so

=>4a+2b+c=2+d
=>d=0.5
Soa=0.5,b=3,c=1.5,d=0.5
name
http://gateoverflow.in/book

340/400

2/26/2015

GATEOverflow Book

GATE20151_4top
1

limx x

is

A.
B. 0
C. 1
D. Notdefined

Applyanexponentialofalogarithmtotheexpression.

Sincetheexponentialfunctioniscontinuous,wemayfactoritoutofthelimit.

Logarithmicfunctionsgrowasymptoticallyslowerthanpolynomials.
Since

growsasymptoticallyslowerthanthepolynomial as approaches

Evaluate .
:
Answer:
name

GATE20151_44top

2/
1/

cos(1/x)
x

dx

=__________________________.

Fortheintegrand

,substitute

Thisgivesanewlowerbound

and

andupperbound

Switchtheorderoftheintegrationboundsof
Multiplytheintegrandby

sothattheupperboundislarger.

Applythefundamentaltheoremofcalculus.
http://gateoverflow.in/book

341/400

2/26/2015

GATEOverflow Book

Theantiderivativeof

is

Evaluatetheantiderivativeatthelimitsandsubtract.

Answer:
name

GATE20153_9top
Thevalueoflimx (1 + x2 )

is

A.
B.
C.
D.

0
1
2

Applyanexponentialofalogarithmtotheexpression.

Sincetheexponentialfunctioniscontinuous,wemayfactoritoutofthelimit.

Thenumeratorof
Since

growsasymptoticallyslowerthanitsdenominatoras approaches
growsasymptoticallyslowerthan as approaches

.
:

Evaluate .
:
Answer:
name

GATE20153_45top
Iffornonzerox,

af (x) + bf (

1
x

) =

1
x

25

whereaa

bthen

2
1

f (x)dx

is

A.

1
2

a b

B.

1
2

a b

C.

1
2

a b

D.

1
2

a b

[ a(ln 2 25) +

47b
2

[ a(2 ln 2 25)
[ a(2 ln 2 25) +
[ a(ln 2 25)

http://gateoverflow.in/book

47b
2
47b
2

47b
2

]
]

342/400

2/26/2015

GATEOverflow Book

Integratingbothsides,

Replacing by in

,weget

Integratingbothsides,weget

Eliminate

between

and

bymultiplying

by and

by andsubtracting

Answer:A.
name

http://gateoverflow.in/book

343/400

2/26/2015

GATEOverflow Book

Programmingtop
GATE2013_42top
Whatisthereturnvalueoff(p,p),ifthevalueofpisinitializedto5beforethecall?Notethatthefirstparameterispassedbyreference,whereasthesecond
parameterispassedbyvalue.

int f (int &x, int c) {


c = c - 1;
if (c==0) return 1;
x = x + 1;
return f(x,c) * x;
}

InGATE2013marksweregiventoallasthesamecodeinC/C++producesundefinedbehavior.Thisisbecause*isnotasequencepointinC/C++.The
correctcodemustreplace
returnf(x,c)*x
with
res=f(x,c)
returnres*x
Inthiscode,therewillbe4recursivecallswithparameters(6,4),(7,3),(8,2)and(9,1).Thelastcallreturns1.Butduetopassbyreference,xinallthe
previousfunctionsisnow9.Hence,thevaluereturnedbyf(p,p)willbe9*9*9*9*1=6561.
name

Ihavebeenstrugglingwithpointersinmultidimensionalarrays.Pleasehelpmewiththiscode:top
Explaintheoutput:
intb[3][4]={{1,2,3,4},{5,6,7,8},{9,10,11,12}}
int**p
p=(int**)b
cout<<(long)*p<<"\t"<<(long)(*p+1)<<"\t"<<(long)(*p+2)
//longisusedtoprinttheoutputindecimalformatinsteadofhex

Here,bisa2Darrayanditcontains3*4=12elements.Supposeaddressofbstartsfrom1000.Nowtheelementswillbestoredas:
10003:1
10047:2
100811:3
101215:4
101619:5
....
104548:12
Now,wedeclarepasint**andinitializeitto1000,thebaseaddressofb.
So,*pwillhave1.(assuminga32bitarchitecture,on64bitarchitecture*pwillbe8bytesandthearrayelementbeingintisonly4bytes)
Now,*p+1,ispointerarithmetic.Itwilladd1*sizeof(int)to*p.So,*p+1willgive1+4=5.(This5isnottheelement5inthearray)
Similarly,*p+2,willadd2*sizeof(int)=2*4=8to*p.So,*p+2willgive1+8=9.
Theseareallvalidonlyona32bitcompiler.Ona64bitcompiler,ifweuse
(long)*p
Itwilltrytoread8bytesfromthestartofthearray.
Since,
10003:1
10047:2
From1000,thecontentofmemorywillbe(assumingalittleendianmachine)
00000001000000000000000000000000|00000010000000000000000000000000
Thisvalueinbinarywillbe
0000001000000000000000000000000000000001
33

=2 + 1
=8589934593

http://gateoverflow.in/book

344/400

2/26/2015

GATEOverflow Book

So,theoutputwillbe8589934593,8589934597and8589934601
Thisoutputisentirelyimplementationdependentasitdependsonthesizeof(int)andsizeofpointerandalsodependsontheendiannessofthemachine(ifsizeof
(int)isdifferentfromsizeofpointer).
Formoredetailsaboutpointerarithmeticyoucanseehere:

http://gatecse.in/wiki/Chapter_3:_Pointers#Pointer_Arithmetic

name

Parameterpassingtechniquetop
Variousparameterpassingmechanismshavebeeninusedindifferentprogramminglanguages.Whichofthefollowingstatementsistrue?
(a)CallbyvalueresultisusedinlanguageAda
(b)Callbyvalueresultisthesameascallbyname.
(c)Callbyvalueisthemostrobust.
(d)Callbyreferenceisthesameascallbyname.
(e)Callbynameisthemosteffi
cient.
(a)istrue.Adasupportsinoutparameterpassing,whichisnothingotherthancallbyvalueresult(butAdainGATEsyllabus?)
(b)Nottrue.
(c)Mostrobust?Idon'tknowwhatismeantbyrobusthere.
(d)Nottrue.
(e)Nottrue.Becauseincallbyname,theparameterisreevaluatedateveryoccurrenceoftheformalparamaterandhenceefficiencywillonlybeless.
Reference:
http://courses.cs.washington.edu/courses/cse341/03wi/imperative/parameters.html
gatecse

GATE1994_1.20top
Inwhichofthefollowingcasesisitpossibletoobtaindifferentresultsforcallbyreferenceandcallbynameparameterpassingmethods?

(a)Passingaconstantvalueasaparameter
(b)Passingtheaddressofanarrayasaparameter
(c)Passinganarrayelementasaparameter
(d)Passinganarray

(c)Passinganarrayelementasaparameteristheanswer.
Considerthisfunctioncall

....
a[] = {0,1,2,3,4};
i = 0;
fun(a[i]);
print a[0];

fun(int x)
{
int i = 1;
x = 8;
}

Output:
callbyreference:8
callbyname:0
InCallbyname,eachoccurenceoftheformalparameterisreplacedbytheactualargumenttext.So,thefunctionfunwillbeexecutedlike:

int i = 1;

http://gateoverflow.in/book

345/400

2/26/2015
}

GATEOverflow Book
a[i] = 8; //a[1] is changed to 8 and not a[0]

Averygoodread:http://courses.cs.washington.edu/courses/cse341/03wi/imperative/parameters.html
name

GATE2008_61top

Hereweareusingthe'='operatorwhichhaslessprioritythan'!='operator.So(c=getchar())hastobeinbracketsandafterreversingthestringweuse
functionputchar(c)forprintingthecharacterSooption(d)istherightanswer
name

GATE1991_09,a,btop
(a)Considerthefollowingpseudocode(alldataitemsareoftypeinteger):
procedure P(a, b, c);
a := 2;
c := a + b;
end {P}
begin
x := 1;
y := 5;
z := 100;
P(x, x*y, z);
Write ('x = ', x, 'z = ', z);
end

Determineitsoutput,iftheparametersarepassedtotheProcedurePby
i. value
ii. reference
iii. name
(b)Forthefollowingcode,indicatetheoutputif
i. staticscoperules
ii. dynamicscoperules
areused
var a,b : integer;
procedure P;
a := 5;
b := 10;
end {P};
procedure Q;

http://gateoverflow.in/book

346/400

2/26/2015

GATEOverflow Book

var a, b : integer;
P;
end {Q};
begin
a := 1;
b := 2;
Q;
Write ('a = ', a, 'b = ', b);
end

(a)
1.Passbyvalue:Functioncannotmodifyavariableinthecallingfunction.So,
x=1,z=100
2.Passbyreference:Analiasofthevariable(adifferentnamebuthavingsamememorylocation)isusedtopassthevariabletoafunction.So,whatever
changeoccursforthevariableinthecalledfunctionisreflectedinthecallingfunction.
x=2,z=7(2+5)
3.Passbyname:Theexpressionusedtocallafunctioniscopypastedforeachformalparameter.So,thebodyofPbecomes,
x := 2;
z := x + x*y;

So,printedvaluewillbe
x=2,z=12
(b)Instaticscoping,ifavariableisnotfoundinthelocalscope,itslookeduponinglobalscope.Indynamicscoping,ifavariableisnotfoundinlocalscope,
itslookeduponinthefunctionwhichcalledthecurrentexecutingone.
1.a=5,b=10
2.a=1,b=2
(ThemodificationinQ,happenstothevariablesinPbutinmainweusetheglobalvariables)
name

GATE2000_1.11top
ThefollowingCdeclarations
struct node {
int i:
float j;
};
struct node *s[10];
definestobe

a. Anarray,eachelementofwhichisapointertoastructureoftypenode
b. Astructureof2fields,eachfieldbeingapointertoanarrayof10elements
c. Astructureof3fields:aninteger,afloat,andanarrayof10elements
d. Anarray,eachelementofwhichisastructureoftypenode

(a)istheanswer.[]hasgreaterprecedencethan*inC.So,sbecomesanarrayofpointers.
gatecse

GATE2000_1.17top
ConsiderthefollowingCdeclaration
struct (
short x[5];
union {
float y;
long z;
} u;
)t;

Assumethattheobjectsofthetypeshort,floatandlongoccupy2bytes,4bytesand8bytes,respectively.Thememoryrequirementforvariablet,ignoring
alignmentconsideration,is

http://gateoverflow.in/book

347/400

2/26/2015

A.
B.
C.
D.

GATEOverflow Book

22bytes
14bytes
18bytes
10bytes

answeris(c)
Herestructurecreatesthememoryfor'arrayandunion',butuniononlycreatesthememoryforonly'longz'whichisthelargestsizedatatypeinsideit.
hence,
shortx[5]=5*2=10bytes[shortstake2bytes]
longz=8bytes
so(10+8)=18bytes
name

GATE2001_2.17top
WhatisprintedbytheprintstatementsintheprogramP1assumingcallbyreferenceparameterpassing?
Program P1()
{
x = 10;
y = 3;
func1(y,x,x);
print x;
print y;
}
func1(x,y,z)
{
y = y + 4;
z=x+y+z
}

A.
B.
C.
D.

10,3
31,3
27,7
Noneoftheabove

ansisB.
here,variablexoffunc1pointstoaddressofvariabley.
andvariableyandzoffunc1pointstoaddressfvariablex.
thereforey=y+4=>y=10+4=14
andz=x+y+z=>z=14+14+3=31
zwillbestoredbackinxhencex=31andywillremainasitishencey=3
ansis31,3
name

GATE2001_2.18top
ConsiderthefollowingthreeCfunctions:
[P1]
int *g(void)
{
int x = 10;
return (&x);
}

[P2]
int *g(void)
{
int *px;
*px = 10;
return px;
}

http://gateoverflow.in/book

348/400

2/26/2015

GATEOverflow Book

[P3]
int *g(void)
{
int *px;
px = (int*) malloc (sizeof(int));
*px = 10;
return px;
}

Whichoftheabovethreefunctionsarelikelytocauseproblemswithpointers?
A.
B.
C.
D.

OnlyP3
OnlyP1andP3
OnlyP1andP2
P1,P2andP3

[P1]maycauseanerrorbecausefunctionisreturningtheaddressoflocallydeclaredvariable.
[P2]willcauseaproblembecausepxisanintpointerthatisnotassignedwithanyaddressandwearedoingdereferencing.
[P3]willworkbecausememoryinbytesofsizeofintwillbereservedanditsaddresswillbestoredinpxthatcanbefurtheruse,oncefunctionexecution
completes,thism/mwillstillexistinHeapuntilwefreeitusingfree()function.
henceanswerisC
name

GATE2002_1.16top
Signextensionisastepin
A.
B.
C.
D.

floatingpointmultiplication
signed16bitintegeraddition
arithmeticleftshift
convertingasignedintegerfromonesizetoanother

(d)istheanswer.Signextension(fillingtheupperbitsusingthesignbit)isneededwhileincreasingthenumberofbitsforrepresentinganumber.For
positivenumbers,0isextendedandfornegativenumbers1isextended.
gatecse

GATE2002_1.17top
IntheClanguage
A. Atmostoneactivationrecordexistsbetweenthecurrentactivationrecordandtheactivationrecordforthemain
B. The number of activation records between the current activation record and the activation records fro the main depends on the actual function calling
sequence.
C. Thevisibilityofglobalvariablesdependsontheactualfunctioncallingsequence
D. Recursionrequirestheactivationrecordfortherecursivefunctiontobesavedinadifferentstackbeforetherecursivefunctioncanbecalled.
(A)EachfunctioncallstartsanewactivationrecordandsinceCallowsnestedfunctioncallsmorethanonceactivationrecordcanexistbetweenthecurrent
activationrecordandmain.
(B)TRUE
(C)Since,Cusesstaticscoping,theactualfunctioncallingsequencehasnoimpactonthevisibilityofglobalvariables.Ifavariableisnotfoundinthe
currentactivationrecord,itislookedinglobaladdressspaceandthisisindependentofthecallingsequence.
(D)Allfunctioncallswhetherrecursiveornotusesthesamestackforsavingtheactivationrecord.ThereisnoneedforadifferentstackasforCcompilera
recursivefunctioncallandanormalfunctioncallmakenodifference.
name

GATE2002_2.8top
ConsiderthefollowingdeclarationofatwodimensionalarrayinC:
chara[100][100]
Assumingthatthemainmemoryisbyteaddressableandthatthearrayisstoredstartingfrommemoryaddress0,theaddressofa[40][50]is
A.
B.
C.
D.

4040
4050
5040
5050

http://gateoverflow.in/book

349/400

2/26/2015

GATEOverflow Book

answeris(b)

Formulatoevaluate2darray'slocationis:
loc(a[i][j])=BA+[(ilb1)*NC+(jlb2))*c
whereBA=BaseAddress
NC=no.ofcolumns
C=memorysizeallocatedtodatatypeofarray
a[lb1.....ub1][lb2.....ub2]
hereBA=0,NC=100,c=1,a[0.....99][0......99]solb1=0,lb2=0
loc(a[40][50])=0+[(400)*100+(500)]*1
=0+[4000+50]*1=4050
name

GATE2003_89top
ConsidertheCprogramshownbelow:
#include<stdio.h>
#define print(x) printf("%d", x)
int x;
void Q(int z)
{
z+=x;
print(z);
}
void P(int *y)
{
int x = *y + 2;
Q(x);
*y = x - 1;
print(x);
}
main(void) {
x = 5;
P(&x);
print(x);
}

Theoutputofthisprogramis
(A)1276
(B)221211
(C)1466
(D)766

main: x = 5; //Global x becomes 5

P: int x = *y + 2; //local x in P becomes 5+2 = 7

Q: z+=x; //local z in Q becomes 7 + 5 = 12


Q:print(z)//prints12

P:*y=x1//contentofaddressoflocalvariabley(sameasglobalvariablex)becomes71=6

http://gateoverflow.in/book

350/400

2/26/2015

GATEOverflow Book

P:print(x)//printslocalvariablexinP=7

main:print(x)//printstheglobalvariablex=6

name

GATE2004_1top
Thegoalofstructuredprogrammingisto
A.
B.
C.
D.

havewellindentedprograms
beabletoinfertheflowofcontrolfromthecompiledcode
beabletoinfertheflowofcontrolfromtheprogramtext
avoidtheuseofGOTOstatements

Answeris(c)Thegoalofstructuredprogrammingistoabletoinfertheflowofcontrolfromtheprogramtext.Itmeansusercanexecutethecodeaccording
tohisrequirement.CandPascalaregoodexampleofstructuredprogramming.Instructuredprogrammingcontrolpassesoneinstructiontoanother
instructioninsequentialmanner.
AvoidingtheuseofGOTOstatementsisnotthegoalofstructuredprogramming,it(avoidingtheuseofGOTO)isoneoftherequirementsforaprogramto
bestructured.
name

GATE2004_31top
ConsiderthefollowingCfunction:
int f(int n)
{
static int i = 1;
if(n >= 5) return n;
n = n+i;
i++;
return f(n);
}

Thevaluereturnedbyf(1)is
A.
B.
C.
D.

5
6
7
8

answeris7.as,
f(1):n=2,i=2
f(2):n=4,i=3
f(4):n=7,i=4
f(7):print(n)===>>>7<ans>
name

GATE2004_90top

http://gateoverflow.in/book

351/400

2/26/2015

GATEOverflow Book

Dshouldbetheanswer.
name

GATE1999_2.13top

ansc)
Indynamicscoping,ifavariableisnotfoundinthelocalscopeitislookeduponatthefunctionfromwhichthecallismade.
name

GATE1998_2.15top
Fasteraccesstononlocalvariablesisachievedusinganarrayofpointerstoactivationrecordscalleda
A.
B.
C.
D.

stack
heap
display
activationtree

itisC
propertiesofdisplays
1>Useapointerarraytostoretheactivationrecordsalongthestaticchain.
2>Fastaccessfornonlocalbutmaybecomplicatedtomaintain.
3>Callingasubprograminthesamelevelsimplyreplaceandrestore.
4>Callingasubprograminthehigherleveladdanentryandmayneedtosavetheoldpointers.
5>Callingasubprograminthelowerlevelshrinkthepointerandrestoreitwhenthesubprogramreturns.
http://users.dickinson.edu/~wahlst/356/ch10.pdf
name

GATE2012_36top
Considertheprogramgivenbelow,inablockstructuredpseudolanguagewithlexicalscopingandnestingofprocedurespermitted.
Program main;
Var ...
Procedure A1;
Var ...
Call A2;
End A1
Procedure A2;
Var ...
Procedure A21;
Var ...
Call A1;
End A21
Call A21;
End A2
Call A1;
End main.

Considerthecallingchain:Main>A1>A2>A21>A1
http://gateoverflow.in/book

352/400

2/26/2015

GATEOverflow Book

Thecorrectsetofactivationrecordsalongwiththeiraccesslinksisgivenby

Since,Activationrecordsarecreatedatprocedureentrytimeanddestroyedatprocedureexittime.
thereforehereCallingsequenceisgivenas,
Main>A1>A2>A3>A1
nowA1,A2aredefinedunderMain...SoA1,A2Accesslinkarepointedtomain
A21isDefinedunderA2henceitsAccesslinkwillpointtoA2

name

GATE20141_10top
ConsiderthefollowingprograminClanguage:
#include <stdio.h>
main()
{
int i;
int*pi = &i;

scanf("%d",pi);
printf("%d\n", i+5);

WhichoneofthefollowingstatementsisTRUE?

(A)Compilationfails.
(B)Executionresultsinaruntimeerror.
(C)Onexecution,thevalueprintedis5 morethantheaddressofvariablei .
(D)Onexecution,thevalueprintedis5 morethantheintegervalueentered.

int i; //i is declared


int*pi = &i; //pi is a pointer variable assigned the address if i
scanf("%d",pi); //i is overwritten with the value we provided because pi is pointing to i earlier
printf("%d\n", i+5) //it will print the value stored in i+5

input=3
output=8
http://gateoverflow.in/book

353/400

2/26/2015

GATEOverflow Book

name

GATE2006_56top
ConsiderthefollowingcodewritteninapassbyreferencelanguagelikeFORTRANandthesestatementsaboutthecode.
subroutine swap(ix,iy)
it = ix
L1 : ix = iy
L2 : iy = it
end
ia = 3
ib = 8
call swap (ia, ib+5)
print *, ia, ib
end

S1:Thecompilerwillgeneratecodetoallocateatemporarynamelesscell,initializeitto13,andpasstheaddressofthecelltoswap
S2:OnexecutionthecodewillgeneratearuntimeerroronlineL1
S3:OnexecutionthecodewillgeneratearuntimeerroronlineL2
S4:Theprogramwillprint13and8
S5:Theprogramwillprint13and2
Exactlythefollowingsetofstatement(s)iscorrect:
(A)S1andS2
(B)S1andS4
(C)S3
(D)S1andS5

S1andS4arecorrect.Therewon'tbeanyruntimeerrorforthegivencodeusingpassbyreference.
name

GATE2006_57top
ConsiderthisCcodetoswaptwointegersandthesefivestatements:thecode
void swap (int *px, int *py) {
*px = *px - *py;
*py = *px + *py;
*px = *py - *px;
}

S1:willgenerateacompilationerror
S2:maygenerateasegmentationfaultatruntimedependingontheargumentspassed
S3:correctlyimplementstheswapprocedureforallinputpointersreferringtointegersstoredinmemorylocationsaccessibletotheprocess
S4:implementstheswapprocedurecorrectlyforsomebutnotallvalidinputpointers
S5:mayaddorsubtractintegersandpointers
(A)S1
(B)S2andS3
(C)S2andS4
(D)S2andS5

s1isfalse.s2istrue,dependingontheargumentpasseditmaygeneratesegmentationfaults3isfalsebczimplementationishavingsomeproblem...letx=3
andiwanttoimplementSWAP[x,x]nowanswouldbe0butthatmustberemainxproblemisbczwearenotcheckingwhetherbothpointerarepointingthe
sameaddressordifferentsos4istrues5isobviouslyfalsesoOption(c)isright
name

GATE20142_11top
SupposenandpareunsignedintvariablesinaCprogram.Wewishtosetpton C 3 .Ifnislarge,whichoneofthefollowingstatementsismostlikelytosetp
correctly?
(A)p=n*(n1)*(n2)/6
(B)p=n*(n1)/2*(n2)/3

http://gateoverflow.in/book

354/400

2/26/2015

GATEOverflow Book

(C)p=n*(n1)/3*(n2)/2
(D)p=n*(n1)*(n2)/6.0

B)
Inc,*and/havethesameprecedenceandareleftassociative.
Evaluationofn*(n1)*(n2)mightexceedtheunsignedintrange.
Soa)andd)areeliminated.
n*(n1)isalwaysdivisibleby2.(Givesanintegervalue).Whereasitisnotalwaysdivisibleby3.(Youdontalwaysgetaninteger..truncationpossible,less
accuracy)
c)eliminated.
Inoptionb)
n*(n1)/2givesanintegervalue.
Thisintegervaluemultipliedby(n2)againgivesanintegervalue.
Whichwhendividedby3givesanintegervalue(Setspcorrectly).
Reason:n*(n1)*(n2)isthemultiplicationof3consecutivenumbers.whichisdivisibleby2aswellas3.
Hence(n*(n1)/2*(n2))isdivisibleby3.
name

GATE20142_42top
ConsidertheCfunctiongivenbelow.
int f(int j)
{
static int i = 50;
int k;
if (i == j)
{
printf("something");
k = f(i);
return 0;
}
else return 0;
}

WhichoneofthefollowingisTRUE?
(A)Thefunctionreturns0 forallvaluesofj .
(B)Thefunctionprintsthestringsomethingforallvaluesofj .
(C)Thefunctionreturns0 whenj

= 50 .

(D)Thefunctionwillexhausttheruntimestackorrunintoaninfiniteloopwhenj

= 50 .

Thereisnoupdationforiandjinthefunction.soifwecallfunctionwithj=50therecursivecallwillbecontinuedinfinitely.Thereisnoterminating
conditionforrecursion.henceanwerD
name

GATE20143_42top
ConsidertheCfunctiongivenbelow.AssumethatthearraylistA containsn(>

0) elements,sortedinascendingorder.

int ProcessArray(int *listA, int x, int n)


{
int i, j, k;
i = 0;
j = n-1;
do {
k = (i+j)/2;
if (x <= listA[k])
j = k-1;
if (listA[k] <= x)
i = k+1;
}while (i <= j);
if (listA[k] == x)
return(k);
else
return -1;
}

WhichoneofthefollowingstatementsaboutthefunctionP rocessArray isCORRECT?

(A)Itwillrunintoaninfiniteloopwhenx isnotinlistA .
http://gateoverflow.in/book

355/400

2/26/2015

GATEOverflow Book
(B)Itisanimplementationofbinarysearch.
(C)ItwillalwaysfindthemaximumelementinlistA .
(D)Itwillreturn1evenwhenx ispresentinlistA .

B)....
SiddharthaDatta

GATE2011_22top
WhatdoesthefollowingfragmentofCprogramprint?
char c[] = "GATE2011";
char *p = c;
printf("%s", p + p[3] - p[1]);

(A)GATE2011
(B)E2011
(C)2011
(D)011

2011istheanswer.
InC,thereisarulethatwhatevercharactercodebeusedbythecompiler,codesofallalphabetsanddigitsmustbeinorder.So,ifcharactercodeof'A'isx,
thenfor'B'itmustbex+1.
Now%smeansprintftakesandaddressandprintsallbytesstartingfromthataddressascharacterstillanybytebecomesthecodefor'\0'.Now,thepassed
valuetoprintfhereis
p+p[3]p[1]
pisthestartingaddressofarrayc.p[3]='E'andp[1]='A'.So,p[3]p[1]=4,andp+4willbepointingtothefourthpositioninthearrayc.So,printfstarts
printingfrom2andprints2011.
(Here"GATE2011"isastringliteralandbydefaulta'\0'isaddedattheendofitbythecompiler).
NB:Inthisquestion%sisnotrequired.
printf(p + p[3] - p[1]);

Alsogivesthesameresultasfirstargumenttoprintfisacharacterpointerandonlyifwewanttopassmoreargumentsweneedtouseaformatstring.

name

GATE2012_48,49top
CommonDataforQuestions48and49:
ConsiderthefollowingCcodesegment.
int a, b, c = 0;
void prtFun(void);
main()
{
static int a = 1;
/* Line 1 */
prtFun();
a += 1;
prtFun();
printf( \n %d %d , a, b);
}
void prtFun(void)
{
static int a = 2;
/* Line 2 */
int b = 1;
a += ++b;
printf( \n %d %d , a, b);
}

Q.48Whatoutputwillbegeneratedbythegivencodesegment?

(A)
3

http://gateoverflow.in/book

356/400

2/26/2015

GATEOverflow Book

4
4

1
2

(B)
4
6
6

2
1
1

(C)
4
6
2

2
2
0

(D)
3
5
5

1
2
2

Q.49Whatoutputwillbegeneratedbythegivencodesegmentif:
Line1isreplacedbyautointa=1
Line2isreplacedbyregisterinta=2

(A)
3
4
4

1
1
2

(B)
4
6
6

2
1
1

(C)
4
6
2

2
2
0

(D)
4
4
2

2
2
0

48.
main
a=1
prtFun()
a=2
b=1
a=a+++b=2+2=4
b=2
printf>42
backtomain
a=a+1>1+1>2(localstaticaistaken)
prtFun()
a=4//previousvalueinthefunctionisretainedbcosofstatic
b=1
http://gateoverflow.in/book

357/400

2/26/2015

GATEOverflow Book

a=a+++b=4+2=6
b=2
printf>62
backtomain
a=2
b=0(initialvalueofglobalb.inprtFunlocalbisonlyupdated)
printf>20
Answer:C
49
main
a=1
prtFun()
a=2
b=1
a=a+++b=2+2=4
b=2
printf>42
backtomain
a=a+1>1+1>2
prtFun()
a=1//previousaislost
b=1
a=a+++b=2+2=4
b=2
printf>42
backtomain
a=2
b=0(initialvalueofglobalb.inprtFunlocalbisonlyupdated)
printf>20
Anwer:D
name

GATE2010_11top
Whatdoesthefollowingprogramprint?
#include<stdio.h>
void f(int *p, int *q) {
p=q;
*p=2;
}
int i=0, j=1;
int main() {
f(&i, &j);
printf("%d %d\n", i,j);
return 0;
}

(A)22
(B)21
(C)01
(D)02

p=q;
*p=2;

-- now p and q are pointing to same address i.e. address of j


-- value of j will be updated to 2

hence answer is (D) 0 2

name

GATE2010_14top
Whichlanguagesnecessarilyneedheapallocationintheruntimeenvironment?
(A)Thosethatsupportrecursion.
(B)Thosethatusedynamicscoping.
(C)Thosethatallowdynamicdatastructure.
(D)Thosethatuseglobalvariables.

http://gateoverflow.in/book

358/400

2/26/2015

GATEOverflow Book

Thosethatallowdynamicdatastructure.
mallocetcusesmemoryfromheaparea

name

GATE1997_1.10top

memoryistakenfromheapfordynamicallocation
sooptionbiscorrect
name

GATE2008IT_13top
Matchtheprogrammingparadigmsandlanguagesgiveninthefollowingtable.

(I)
(II)
(III)
(IV)

Paradigms
Imperative
ObjectOriented
Functional
Logic

(a)
(b)
(c)
(d)

Languages
Prolog
Lisp
C,Fortran77,Pascal
C++,Smalltalk,Java

A.
B.
C.
D.

Ic,IId,IIIb,IVa
Ia,IId,IIIc,IVb
Id,IIc,IIIb,IVa
Ic,IId,IIIa,IVb
Aiscorrect.LispisapurefunctionallanguageandPrologisalogiclanguage.Otherlanguagesarewellknown.
name

GATE2008IT_51top
ConsidertheCprogramgivenbelow.Whatdoesitprint?

#include <stdio.h>
int main ()
{
int i, j;
int a [8] = {1, 2, 3, 4, 5, 6, 7, 8};
for(i = 0; i < 3; i++) {
a[i] = a[i] + 1;
i++;
}
i--;
for (j = 7; j > 4; j--) {
int i = j/2;
a[i] = a[i] - 1;
}
printf ("%d, %d", i, a[i]);
}

A)
B)
C)
D)

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

Answeris(c)3,2
http://gateoverflow.in/book

359/400

2/26/2015

GATEOverflow Book

first2variableintegertypedeclarednamedi,j
thenaninttypearraya[8]declaredandinitialized.
a[0]1
a[1]2
a[2]3
a[3]4
a[4]5
a[5]6
a[6]7
a[7]8

thenforloopstarted
i=0i<3(true)
a[0]=a[0]+1=1+1=2
i++
i++
i=2i<3(true)
a[2]=a[2]+1=3+1=4
i++
i++
i=4i<3(false)
i(i=3)

nowanotherforloopstartedwhereinloopintegertypevariablenamedideclared

BlockScope:ABlockisasetofstatementsenclosedwithinleftandrightbraces({and}respectively).BlocksmaybenestedinC(ablockmay
containotherblocksinsideit).Avariabledeclaredinablockisaccessibleintheblockandallinnerblocksofthatblock,butnotaccessibleoutside
theblock.
Whatiftheinnerblockitselfhasonevariablewiththesamename?
Ifaninnerblockdeclaresavariablewiththesamenameasthevariabledeclaredbytheouterblock,thenthevisibilityoftheouterblockvariable
endsatthepointofdeclarationbyinnerblock

sohereinnerblockintihasthescopeinthisblockonlyandouterblockintivisibilityisnotallowedinthatblock
j=7j>4(true)
inti=7/2=3
a[3]=a[3]1=41=3
j=6j>4(true)
inti=6/2=3
a[3]=a[3]1=31=2
j=5j>4(true)

inti=5/2=2
a[2]=a[2]1=41=3
j=4j>4(false)

nowwhentheforloopendsitsvariablenamediscopeisalsoendandtheouterblockvariablenowvisible
sotheoutputwouldbe:3,2
http://gateoverflow.in/book

360/400

2/26/2015

GATEOverflow Book

name

GATE2008IT_52top
Cprogramisgivenbelow:
# include <stdio.h>
int main ()
{
int i, j;
char a [2] [3] = {{'a', 'b', 'c'}, {'d', 'e', 'f'}};
char b [3] [2];
char *p = *b;
for (i = 0; i < 2; i++) {
for (j = 0; j < 3; j++) {
*(p + 2*j + i) = a [i] [j];
}
}
}

Whatshouldbethecontentsofthearraybattheendoftheprogram?

ab
cd
ef
ad
be
cf
ac
eb
df
ae
dc
bf

A)

B)

C)

D)

Thecorrectanswerisoption(B)
firstintegertypetwovariablesdeclarediandj
thenanintegertype2darraya[2][3]isdeclaredandinitializedand2darrayb[3][2]iscreatedbutnotinitialized.i.e
addressvalueaddressvalue
a[0]0[]2000ab[0][0]3000garbagevalue
a[0][1]2001bb[0][1]3001garbagevalue
a[0][2]2002cb[1][0]3002garbagevalue
a[1][0]2003db[1][1]3003garbagevalue
a[1][1]2004eb[2][0]3004garbagevalue
a[1][2]2005fb[2][1]3005garbagevalue
nowthechartypepointerisdeclaredandthebaseaddressofarraybisputinit.sop=3000
nowtheforloopisstartedwhereiisinitializedto0,so
i=0:i<2(true)
j=0j<3(true)
*(3000+2*0+0)=a[0][0]=>*(3000)=a
j++
j=1j<3(true)
*(3000+2*1+0)=a[0][1]=>*(3002)=b
http://gateoverflow.in/book

361/400

2/26/2015

GATEOverflow Book

j++
j=2j<3(true)
*(3000+2*2+0)=a[0][2]=>*(3004)=c
j++
j=3j<3(false)
i++
i=1:i<2(true)
j=0j<3(true)
*(3000+2*0+1)=a[1][0]=>*(3001)=d
j++
j=1j<3(true)
*(3000+2*1+1)=a[1][1]=>*(3003)=e
j++
j=2j<3(true)
*(3000+2*2+1)=a[1][2]=>*(3005)=f
j++
j=3j<3(false)
i++
nowthevaluesinarraybis
b[0][0]3000a
b[0][1]3001d
b[1][0]3002b
b[1][1]3003e
b[2][0]3004c
b[2][1]3005f
hencetheoutputwillbe(B)choice.
Note:
*(p+2*j+i)
p+sizeofinnerdimension*j+i,henceissameasp[j][i].Hencewiththisstatementwecanidentifythatthecodeistransposingthematrixaandstoringinb
usingpointerp.
name

GATE2007IT_32top
ConsiderthefollowingCprogram:

#include <stdio.h>
#define EOF -1
void push (int); /* push the argument on the stack */
int pop (void); /* pop the top of the stack */
void flagError ();
int main ()
{
int c, m, n, r;
while ((c = getchar ()) != EOF)
{ if (isdigit (c) )
push (c);
else if ((c == '+') || (c == '*'))
{
m = pop ();
n = pop ();
r = (c == '+') ? n + m : n*m;
push (r);
}
else if (c != ' ')
flagError ();
}
printf("% c", pop ());

http://gateoverflow.in/book

362/400

2/26/2015

GATEOverflow Book

Whatistheoutputoftheprogramforthefollowinginput?
52*332+*+

A)
B)
C)
D)

15
25
30
150
B)25
letfirstpart
5push
2push
push5*2=10.(pops5and2)
push3
push3
push2
push3+2=5(pops2and3)
push5*3=15(pops(5and3)
push15+10=25(pops(15and10)
name

GATE2007IT_33top
Considertheprogrambelowinahypotheticallanguagewhichallowsglobalvariableandachoiceofcallbyreferenceorcallbyvaluemethodsofparameter
passing.

int i ;
program main ()
{
int j = 60;
i = 50;
call f (i, j);
print i, j;
}
procedure f (x, y)
{
i = 100;
x = 10;
y=y+i;
}

Whichoneofthefollowingoptionsrepresentsthecorrectoutputoftheprogramforthetwoparameterpassingmechanisms?

A)
Callbyvalue:i=70,j=10Callbyreference:i=60,j=70
B)
Callbyvalue:i=50,j=60Callbyreference:i=50,j=70
C)
Callbyvalue:i=10,j=70Callbyreference:i=100,j=60
D)
Callbyvalue:i=100,j=60Callbyreference:i=10,j=70

Correctansweris(d)
CALLBYVALUE:iasglobalvariabledeclared.Theninmain()alocalvariablejasintegerdeclaredi.ej=60Andglobalvariableiinitializedto50by
i=50.Nowprocedurefcalledandvaluesofiandjarepassedtoit.i.e.,inf(i,j)>f(x,y)contentofmemorylocationofi(here50)iscopiedtomemory
locationofx(whichisdifferentfromi)andcontentofmemorylocationofj(here,60)iscopiedtomemorylocationofy.Theninf(x,y)i=100changesthe
globalito100,X=10changesthelocalXfrom50to10andY=y+imeansy=60+100=160.Nowwhenreturnbacktomain,iandjwillbe100and60
respectively.
CALLBYREFERENCE:Nowprocedurefcalledandpassedreferenceofiandjtoit.i.e.,inf(i,j)>f(x,y)xandyarenewnames(aliases)pointingtothe
samememorylocationofiandjrespectively.So,i=100changestheglobalito100andx=10meansxaswellasglobali=10(astheibeingpassedisthe
globalvariableandxandisharethesameaddress).
y=y+imeansy=60+10=70andthischangesthevalueofjalsoto70asjandyhavethesameaddress.Nowwhenreturnbacktomain,iandjwillbe10and
70respectively.
name

GATE2007IT_34top
Considertheprogrambelowinahypotheticalprogramminglanguagewhichallowsglobalvariablesandachoiceofstaticordynamicscoping.
int i ;
program main ()

http://gateoverflow.in/book

363/400

2/26/2015
{

GATEOverflow Book
i = 10;
call f();

procedure f()
{
int i = 20;
call g ();
}
procedure g ()
{
print i;
}

Letxbethevalueprintedunderstaticscopingandybethevalueprintedunderdynamicscoping.Then,xandyare

A)
B)
C)
D)

x=10,y=10
x=20,y=10
x=10,y=20
x=20,y=20

Instaticscoping,thescopeofanidentifierisdeterminedbyitslocationinthecode,andsincethatdoesn'tchange,thescopedoesn'teither.Indynamicscoping,
thescopeisdeterminedbythesequenceofcallsthathasledtotheuseofanidentifier,andsincethatcanbedifferenteachtimethatuseisreached,isdynamic.
sohere.
optionCmustbetheanswer
as,
understaticscoping:x=10(globali)
underdynamicscoping:y=20(accordingtothesequenceofcalls,i.e20)

name

GATE2007IT_35top
Earlybindingreferstoabindingperformedatcompiletimeandlatebindingreferstoabindingperformedatexecutiontime.Considerthefollowingstatements:
i. Staticscopefacilitatesw1bindings.
ii. Dynamicscoperequiresw2bindings.
iii. Earlybindingsw3executionefficiency.
iv. Latebindingsw4executionefficiency.
Therightchoicesofwl,w2,w3andw4(inthatorder)are

A)
B)
C)
D)

Early,late,decrease,increase
Late,early,increase,decrease
Late,early,decrease,increase
Early,late,increase,decrease
Staticscopingcandoearlybinding(duringcompiletime).Earlybindingincreasesefficiency.
Dynamicscopingrequireslatebinding(duringexecutiontime).Latebindingdecreasesefficiencyasthisbindingneedstobedoneatruntime.(butit
increasesflexibility)
So,answeris(D)
name

GATE2006IT_51top
Whichoneofthechoicesgivenbelowwouldbeprintedwhenthefollowingprogramisexecuted?
#include <stdio.h>
int a1[] = {6, 7, 8, 18, 34, 67};
int a2[] = {23, 56, 28, 29};
int a3[] = {-12, 27, -31};
int *x[] = {a1, a2, a3};
void print(int *a[])

http://gateoverflow.in/book

364/400

2/26/2015
{

}
main()
{
}

GATEOverflow Book
printf("%d,", a[0][2]);
printf("%d,", *a[2]);
printf("%d,", *++a[0]);
printf("%d,", *(++a)[0]);
printf("%d\n", a[-1][+1]);

print(x);

A)
B)
C)
D)

8,12,7,23,8
8,8,7,23,7
12,12,27,31,23
12,12,27,31,56

a={a1,a2,a3}
printf("%d,",a[0][2])
a[0]isa1.So,thiswillprinta1[2]=8
printf("%d,",*a[2])
a[2]isa3.So,thiswillprint*a3=a3[0]=12([]hasgreaterprecedencethan*)
printf("%d,",*++a[0])
a[0]whichisa1isincremented.a1isapointertoint(baseaddressofanintegerarray)andsoincrementmeansaddingsizeof(int)andhencea1nowpointsto
thesecondelementinthearray.So,*++a[0]printssecondelementofa1whichis7andnowa1startsfrom7.
printf("%d,",*(++a)[0])
++awillincrementa,whichbeinganarrayofpointers(toint)willaddsizeof(pointer)toa.So,anowcontains{a2,a3}anda[0]willbea2and*a2willbe
thefirstelementina2whichis23

printf("%d\n",a[1][+1])
a[1]willsubtractasizeofpointerfromthebaseaddressofa.Normallythisresultsininvalidmemoryaccess,butsincewehaveincrementedapreviously,
a[1]isvalidandwillpointtoa1.So,a[1][+1]willbea1[1]whichhasthevalue8.
(a1wasincrementedin3rdprintfandhencestartsfrom7andnot6.+1issameas1,justgiventocreateconfusion)
name

GATE2004IT_59top
Whatistheoutputofthefollowingprogram?

#include<stdio.h>
int funcf (int x);
int funcg (int y);
main ()
{
int x = 5, y = 10, count;
for (count = 1; count <= 2; ++count) {
y += funcf(x) + funcg(x);
printf ("%d", y);
}
}
funcf (int x) {
int y;
y = funcg(x);
return (y);
}
funcg (int x) {
static int y = 10;
y += 1;
return (y + x);
}

A)
B)
C)
D)
http://gateoverflow.in/book

4380
4274
3337
3232
365/400

2/26/2015

GATEOverflow Book

funcf(x)+funcg(x)
funcforfuncgcanbeexecutedfirst.Letsassumefuncfisexecutedfirst.Itcallsfuncgsoeveniftheorderofcallisrevrsed,resultwillbesame.
Infirstcalloffuncg,ybecomes11anditreturns5+11=16.
Insecondcalloffuncg,ybecomes12anditreturns5+12=17.
So,inmainyisincrementedby16+17=33tobecome10+33=43.(ChoiceA)
Intheseconditerationywillbeincrementedby18+19=37togive43+37=80.
name

GATE2004IT_60top
Choosethecorrectoptiontofillthe?1and?2sothattheprogramprintsaninputstringinreverseorder.Assumethattheinputstringisterminatedbyanewline
character.

#include <stdio.h>
void wrt_it (void);
int main (void)
{
printf("Enter Text");
printf ("\n");
wrt_ it();
printf ("\n");
return 0;
}
void wrt_it (void)
{
int c;
if (?1)
wrt_it();
?2
}

?1isgetchar()!='\n'
?2isgetchar(c)
?1is(c=getchar())!='\n'
?2isgetchar(c)
?1isc!='\n'
?2isputchar(c)
?1is(c=getchar())!='\n'
?2isputchar(c)

A)
B)
C)
D)

itshouldbeoptionD

?1is(c=getchar())!='\n'
?2isputchar(c)
name

GATE2004IT_61top
ConsiderthefollowingCprogram:
#include <stdio.h>
typedef struct {
char *a;
char *b;
} t;
void f1 (t s);
void f2 (t *p);
main()
{
static t s = {"A", "B"};
printf ("%s %s\n", s.a, s.b);
f1(s);
printf ("%s %s\n", s.a, s.b);
f2(&s);
}
void f1 (t s)
{
s.a = "U";
s.b = "V";
printf ("%s %s\n", s.a, s.b);

http://gateoverflow.in/book

366/400

2/26/2015

GATEOverflow Book
return;

}
void f2(t *p)
{
p -> a = "V";
p -> b = "W";
printf("%s %s\n", p -> a, p -> b);
return;
}

Whatistheoutputgeneratedbytheprogram?

AB
UV
VW
VW
AB
UV
AB
VW
AB
UV
UV
VW
AB
UV
VW
UV

A)

B)

C)

D)

firstprintAB
f1iscallbyvaluethechangesapplciableonlyforlocal
fromf1UVisprinted
backinmainABisprinted
theninf2VWisprinted
henceanswerisB
name

WhatisthebestwaytostudyCprogrammingforGATE2015?top
IfyouknowCprogrammingyoudon'tneedtostudythatforGATE:)
Thatisthesameforalltopics.IwasgoodinCbasicsasIhaddoneallmybtechlabexercisesinCandhadtriedtounderstandanyCquestionIfound
anywhere.So,neverhadanyproblemwithCquestionsinGATE.
Now,ifyouarenotcomfortablewithC,thenagainGATEisthebestexamforyou.Becausetherewon'tbeanysyntaxbasedquestionsinGATE.Theyhave
includedCandnotanyotherprogramminglanguagebecauseCcoversmostofthe"programlanguage"techniquespointers,parameterpassing,scope,
lifetimeanddatatypes.IguessmostCquestionscomefromtheseportions.Understandthesethingsfromanystandardbook
(http://gatecse.in/wiki/Best_books_for_CSE#Programming_.26_Data_Structures)orfromgoodonlineresource(notsomeunauthorizedblogs).AndIbelieve
previousyearquestionsfromGATEalmostcoveralltheares(notallthepossiblequestionsdon'tthinkstudyingallquestionsisanyusefulinGATE,but
coveringtopicsofquestionsisusuallyenough).Youcanseepreviousquestionsinbelowlink:
http://gateoverflow.in/tag/programminginc
name

ifelseconditionbasedquestiontop
What's the "condition" so that the following code
snippet prints both HelloWorld !
if "condition"
printf ("Hello");
else
printf ("World");

Conditioncanbeprintf("Hello")!=5
Socodesnippetbecomes,
http://gateoverflow.in/book

367/400

2/26/2015

GATEOverflow Book

if(printf("Hello")!=5)
printf("Hello")
else
printf("World")
prathams

trytoprintthisinoneloopitself.top
trytoprintthisinoneloopitself.ihavealreadydonethisintwoloops(onenestedintoanother).sopleasetrytodoinoneloopitself.
1
24
369
481216
510152025

#include <stdio.h>
int main(int argc, char * argv[])
{
int i, j=1, k=1, n=atoi(argv[1]);
for(i = 1; j <= n; k++)
{
printf("%d ",i);
if(k == j)
{
k = 0; i = ++j;
printf("\n");
}
else i += j;
}
}

name

whyisthereadifferenceintheexecutiontop
iamdoingstrcpyfromalargerstringintoarelativelysmallerstringusingtwoways.Accordingtome
boththemethodsallocatespacestatically(asiamnotusinganymallocorcallocineitherofmycases).
butstillmethod1givesmesegementationfault(inubuntu)orjustcracshestheexegenerated(in
windows),i.eiamtryingtoaccessareaoutofmyway,whilemethod2doesn't.why?

method1:
char*a="hi"
char*b="hisi"
try
{
strcpy(a,b)
cout<<"allok"
}
catch(exceptione)
{
cout<<"error"
}
method2:
chara[3]="hi"
charb[5]="hisi"
try
{
strcpy(a,b)
cout<<"allok"
}
catch(exceptione)
{
cout<<"error"
}

char*a="hi"
Hereyouaredeclaringapointera,andassigningavaluetoitwhichistheaddressof"hi"."hi"isastringliteralheremeaningitisnothingbutaconstant.So,
compilerstoresthisstringinaREADONLY(ROdatasegment)regionasstringliteralsarenotmeanttobemodified.So,ifwetrytomodifythismemory
http://gateoverflow.in/book

368/400

2/26/2015

GATEOverflow Book

region(bystrcpyoranyothermeans),OSwon'tallowit.
chara[3]="hi"
Herevariableaisallottedmemoryforstoring3charactersandthecharacters'h','i'and'\0'arestoredtoit.Sincescopeofais"auto",thisallocationhappens
instackandprogrammerisfreetomodifythismemorylocationwithinthefunction.Butthereismemoryforonly3characters.Ifusingstrcpymorethan3
charactersareassigned,behaviourisundefinedsometimesitmightworkiftherearesomeunusedmemorygivenbythecompiler,sometimesitmightcrash
due to memory corruption by writing to unallocated memory or sometimes program might give wrong output by modification of unintended memory
locations.
name

Charpointertoaccessaninttop
main()
{
int i =300;
char *ptr=&i;
*++ptr=2;
printf("%d",i);
}

Here,wearemodifyinganintegervariableusingacharpointer.Themodificationhappenstothesecondbyte(fromtheleftofthestartinglocation)anditis
changedto2.
i.e.,300willbestoredas(loweraddressonleft)onabigendianmachine
0*224

0*216

1*28

44*20

1*28

0*216

0*224

andas
44*20

onalittleendianmachine.
Inboththecasesusingthecharpointerwepointtothestartingbyte.Andweareincrementingthestartingbyteby2.
Ao,aftertheincrementwehave
0*224

2*216

1*28

44*20

0*216

0*224

onbigendianarchitecturesand

44*20

2*28

onlittleendianarchitectures.
Therespectivevaluesare131372and556.
(Thisisthemostcommonmethodofcheckingifanarchitectureislittleendianorbigendian)
name

Whatwillbethesecondvalueprintedbytheprogramifparameterpassingmechanismiscallby
reference?top
Whatwillbethesecondvalueprintedbytheprogramifparameterpassingmechanismiscallbyreference?
int b=10 //global
begin
procedure func(int x,int y)
begin
print(b)
x=x+b
y=y+b
end
int a=10;

http://gateoverflow.in/book

369/400

2/26/2015

GATEOverflow Book

int b=20;
func(a,a);
print(a);
end

Staticscoping:Hereifavariableisnotinlocalscope,itislookedinglobalscope.
So,binfunc()istheglobalb.So,10isprinted.aisincrementedby10whenx=x+b,(duetopassbyreference)andaisagainincrementedby10wheny=
y+b.So,print(a)willprint30.
Dynamicscoping:Hereifavariableisnotinlocalscope,itislookedinthefunctionwhichcalledthecurrentone.
So,binfunc()isthebfrommain.So,20isprintedandaisincrementedtwotimesby20andfinalprint(a)willprint10+20+20=50.
name

whatisdifferencebetweendeepbindingandshallowbinding?Explainwiththiscode.top
int x=5;
void f()
{
x = x+50;
}
void g(h())
{
int x=10;
h();
print(x);
}
void main()
{
g(f());
print(x);
}

1)whatisoutputifcodeusesdeepbinding?
2)whatistheoutputifcodeusesshallowbinding?

Deep/shallowbindingmakessenseonlywhenaprocedurecanbepassedasanargumenttoafunction.
Deepbindingbindstheenvironmentatthetimeaprocedureispassedasanargument.
Shallowbindingbindstheenvironmentatthetimeaprocedureisactuallycalled.
1.Deepbinding.
f()getstheenvironmentofmain,sincef()ispassedasanargumentinmain.Atthetimeofpassing,xinmain(theglobalx)is5.So,fchangestheglobalxto
55,andgprintsthelocalxas10.
2.Shallowbinding.
f()getstheenvironmentofgatthetimeitiscalled.So,fchangesthexingto10+50=60,andgprintsthevalue60.
name

Considerthefollowingprogramtop
int i = 1;
int main()
{
int a[]= { 0,1, 2} ;
f(a[i], i);
printf("%d", a[i]);
}
void f(int x, int y)
{
y++;
x=5*i;
}

Inabovefunctionf()uses"callbyname"technique,whatistheoutputprinted?
a)2b)10c)5d)1
http://gateoverflow.in/book

370/400

2/26/2015

GATEOverflow Book

UsingaCstylecreatesconfusionforcallbyname.Thescopeofvariablescomesfromthefunctionwhereitiscalled(dynamicscoping)incallbyname.
y++ibecomes2
x=5*ia[2]becomes10.
So,10shouldbeprinted.
name

useofunionsinctop
whatarethereasonstouseunionsornottouseunionsinC?whyunionsinadaarebetterthanCimplementation?
Useunionstosavememory.Currentlywhenwehavesomuchofmemoryspaceinsystems,thereisnopointinusingaunion.Butitisstillusefulin
embeddedsystems.
Adahasbetterimplementationforunion?Thatcan'tbetrue.BecauseCdoesn'tspecifyhowaunionmustbeimplemented.Andbeingsosimpleandcloseto
hardwarelanguageisC,nolanguageotherthanAssembly,writtenbysomereallyreallygreatprogrammercanoutperformaCcodecompiledbyadecentC
compiler.So,"betterthanC"canmeaneasetouse,not"betterinperformance".
name

Whatistheoutput,explaintop
int main(void) {
char p[20];
char *s = "Gate015";
int length = strlen(s);
int i=0;
for(i=0;i<length;i++)
p[i]=s[length-i];
printf("%s",p);
return 0;
}

printf("%s",p)
%sprintsallcharactersfromthestartaddressgivenbyptillthefirstoccurrenceof'\0'Butp[0]=s[length0]='\0'So,nothingwillbeprinted.
Thecodecanbecorrectedby
for(i=0i<lengthi++)
p[i]=s[lengthi1]
name

pleaseexplainthereasonforthe"weird"falseconditioncomingoutfromforconditionalchecking.
top

InthisprogramtheTOTAL_ELEMENTScalculatesproperlywhennotusedinforloop.Andthefirstprintfprintsproperly.
Butwhythe2ndprintfisnotworkingeveniftheconditionintheloopistrue.TOTAL_ELEMENTSreturns7.
And1<72i.e1<5istrue.Sowhatiswronghere?
#include<stdio.h>
#defineTOTAL_ELEMENTS(sizeof(array)/sizeof(array[0]))
intarray[]={23,34,12,17,204,99,16}
intmain()
{
intd
printf("Total=%d\n",TOTAL_ELEMENTS)
for(d=1d<=(TOTAL_ELEMENTS2)d++)
printf("%d\n",array[d+1])
return0
}

Duetoimplicittypecasting.
Whenweoperateontwodifferentdatatypes,thesmalleroneisimplicitlycastedtobiggerone.Andbetweensignedandunsigned,unsignedisranked
higher.
http://gateoverflow.in/book

371/400

2/26/2015

GATEOverflow Book

http://gatecse.in/wiki/Chapter_2:_Data_Types_and_Operators_in_C#Implicit_Type_Conversion
InthedefinitionofTOTAL_ELEMENTS,sizeof,returnsunsignedint,andunsignedintdividedbyunsignedintreturnsunsignedint.Whencomparedwithd,
aninteger,dispromotedtounsignedandbecomes2n1,wherenisthenumberofbitsusedforstoringanint.So,thecomparisonherereturnsfalse.
name

GATE2015_7febtop
#include <stdio.h>
int fun(int n)
{
int x=1,k;
if(n==1)
return 1;
for(k=1;k<n;++k)
{
x=x+f(k)*f(n-k);
}
return x;
}
int main(void) {
// your code goes here
printf("%d",fun(5));
return 0;
}

Whatistheoutputoftheaboveprogram?
Ans51
name

GATE20152_15top
ConsiderthefollowingfunctionwrittenintheCprogramminglangauge
void foo(char *a) {
if (*a && *a != ' ')
foo(a+1);
putchar(*a);
}
}

Theoutputoftheabovefunctiononinput"ABCDEFGH"is
A.
B.
C.
D.

ABCDEFGH
ABCD
HGFEDCBA
DCBA

AnsDaspriorityof!=isgreaterthanthatof&&inC.
name

GATE20151_11
top
TheoutputofthefollowingCprogramis_____________.
void f1 ( int a, int b) {
int c;
c = a; a = b;
b = c;
}
void f2 ( int * a, int * b) {
int c;
c = * a; *a = *b; *b = c;
}
int main () {
int a = 4, b = 5, c = 6;
f1 ( a, b);
f2 (&b, &c);
printf ("%d, c - a - b);
}

heref1willnotchangeanyvaluesbczitiscallbyvaluebutf2iscallbyreferanceanditswapsvaluesofbandcandchangesarealsoreflectedinmain
function...so564=5henceansweris5
name

GATE20151_33top
http://gateoverflow.in/book

372/400

2/26/2015

GATEOverflow Book

Considerthefollowingpseudocode,wherexandyarepositiveintegers.
begin
q := 0
r := x
while r y do
begin
r := r - y
q := q + 1
end
end

Thepostconditionthatneedstobesatisfiedaftertheprogramterminatesis
A.
B.
C.
D.

{r=qx+yr<y}
{x=qy+rr<y}
{y=qx+r0<r<y}
{q+1<ryy>0}

Theloopterminateswhenr<y.So,r<yisonepostcondition.
Ineachiterationqisincrementedby1andyissubtractedfromr.Initialvalueofrisx.So,loopiteratesx/ytimesandqwillbeequaltox/yandr=x%y=>x
=qy+r
So,Bchoice.
name

GATE20151_35top
WhatistheoutputofthefollowingCcode?Assumethattheaddressofxis2000(indecimal)andanintegerrequiresfourbytesofmemory.
int main () {
unsigned int x [4] [3] =
{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}};
printf ("%u, %u, %u, x + 3, * (x + 3), * (x + 2) + 3);
}

A.
B.
C.
D.

2036,2036,2036
2012,4,2204
2036,10,10
2012,4,6

Addressofxis2000.
xbeinga2Darray,
x+3=x+3*sizeofitsinnerdimension
=2000+3*3*4(asinnerdimensionis3integersofsize4)
=2000+36=2036.
*(x+3)returnsthevalueataddress2036.Butsincexis2Darray,one*willjustreturnthe1Darraywhichisthestartingaddressofit,whichis2036only.
(x+2)=2000+2*3*4=2024
*(x+2)+3=2024+3*4=2036(The*changesthedatatypefrom2Dto1Dandhence+3willadd3*4andnot3*3*4)
So,A.
name

GATE20153_7top
ConsiderthefollowingCprogramsegment.
# include <stdio.h>
int main()
{
char s1[7] = "1234", *p;
p = s1 + 2;
*p = '0';
printf("%s", s1);
}

Whatwillbeprintedbytheprogram?

http://gateoverflow.in/book

373/400

2/26/2015

A.
B.
C.
D.

GATEOverflow Book

12
120400
1204
1034

p=s1+2
pnowpointstothethirdelementins1.
*p='0'
Thethirdelementins1ismade0.So,1234becomes1204.Cchoice.
name

GATE20153_26top
ConsiderthefollowingCprogram
#include<stdio.h>
int main()
{
static int a[] = {10, 20, 30, 40, 50};
static int *p[] = {a, a+3, a+4, a+1, a+2};
int **ptr = p;
ptr++;
printf("%d%d", ptr-p, **ptr);
}

Theoutputoftheprogramis_______.
forptrp=1,aspointerincrementaddsthesizeofthedatatypeandpointersubtractiongivesthenumberofobjectsthatcanbeheldinbetweenthetwo
addresses=diff(addr1,addr2)/sizeof(datatype)
andfor**ptr=*(a+3)=a[3]=40
name

GATE20153_48top
ConsiderthefollowingCprogram:
#include<stdio.h>
int main()
{
int i, j, k = 0;
j=2 * 3 / 4 + 2.0 / 5 + 8 / 5;
k-=--j;
for (i=0; i<5; i++)
{
switch(i+k)
{
case 1:
case 2: printf("\n%d", i+k);
case 3: printf("\n%d", i+k);
default: printf("\n%d", i+k);
}
}
return 0;
}

Thenumberoftimesprintfstatementisexecutedis_______.

Thevariablesjandkhavevalues1and1respectivelybeforetheforloop.Insidetheforloop,thevariableiisinitializedto0andthelooprunsfrom0to4.
,

,defaultcaseisexecuted,printfcount=1

,defaultcaseisexecuted,printfcount=2

,case2,case3anddefaultcaseisexecuted,printfcount=5

,case2,case3anddefaultcaseisexecuted,printfcount=8

,case3anddefaultcaseisexecuted,printfcount=10

,loopexitsandthecontolreturnstomain
Answer:

http://gateoverflow.in/book

374/400

2/26/2015

GATEOverflow Book

name

GATE20153_54top
ConsiderthefollowingCprogram
#include<stdio.h>
int f1(void);
int f2(void);
int f3(void);
int x=10;
int main()
{
int x=1;
x += f1() + f2 () + f3() + f2();
printf("%d", x);
return 0;
}
int f1() { int x = 25; x++; return x;}
int f2() { static int x = 50; x++; return x;}
int f3() { x *= 10; return x;}

Theoutputoftheprogramis______.

Thevariablex isinitializedto1 .Firstandonlycalltof 1() returns26.Firstcalltof 2() returns51.Firstandonlycalltof 3() returns100 .Secondcallto
f 2() returns52 (Thevalueoflocalstaticvariablex inf 2() retainsitspreviousvalue51 andisincrementedby1 ).
x = 1 + 26 + 51 + 100 + 52 = 230

Answer:230
name

http://gateoverflow.in/book

375/400

2/26/2015

GATEOverflow Book

DStop
GATE2013_44top
ConsiderthefollowingoperationalongwithEnqueueandDequeueoperationsonqueues,wherekisaglobalparameter.

MultiDequeue(Q){
m=k
while (Q is not empty) and (m > 0) {
Dequeue(Q)
m=m1
}
}

Whatistheworstcasetimecomplexityofasequenceofn queueoperationsonaninitiallyempty
queue?
(A)(n)
(B)(n + k)
(C)(nk)
(D)(n 2 )
TherearethreepossibleoperationsonqueueEnqueue,DequeueandMultiDequeue.MultiDequeueiscallingDequeuemultipletimesbasedonaglobal
variablek .Since,thequeueisinitiallyempty,whateverbetheorderoftheseoperations,therecannotbemoreno.ofDequeueoperationsthanEnqueue
operations.Hence,thetotalno.operationswillben only.
name

GATE1991_01,ixtop

41673258
name

GATE1991_01,viiitop

Thisisstraightforward.Thenodesofthegiventreearegiveninsquareboxes.Theweightsassociatedwiththenodesarethenumbersexample15,9,10etc.
Weightedpathlength=sigma(for(eachnodeinthetree)(pathlength)*(weightofthenode)).
Soanswer(writteninpath_length*weightform)=4*2+4*4+4*5+4*7+3*9+3*10+1*15=144
arvchamp

http://gateoverflow.in/book

376/400

2/26/2015

GATEOverflow Book

GATE1991_03,viitop
03.Choosethecorrectalternatives(morethanonemaybecorrect)andwritethecorrespondinglettersonly:

Letstrysomethingdifferentwhenyoureadthewordpopthendeletethelastpushedelementandprintit..nowdeletethepushwordwhichwehavealready
executed..nowgoonfromlefttorightanddothesame
name

GATE2002_2.12top
Aweightbalancedtreeisabinarytreeinwhichforeachnode,thenumberofnodesintheleftsubtreeisatleasthalfandatmosttwicethenumberofnodesin
therightsubtree.Themaximumpossibleheight(numberofnodesonthepathfromtheroottothefurthestleaf)ofsuchatreeonnnodesisbestdescribedby
whichofthefollowing?

A.
B.
C.
D.

log 2 n
log

log 3 n
log

Totalnumberofnodescanbedescribedbytherecurrence
T(n)=T((n1)/3))+T(2(n1)/3)+1
T(1)=1
Asthismakesmaximumnodesgotoonesubtreeandthatiswhatwewanttogetthemaximumheightwithagivennumberofnodes.
Now,theheightofthetreewillbe
H(n)=H(2/3(n1))+1
H(1)=0
Wecandrawarecurrencetreeandthecostateachlevelis1,andtheheightwillbelog(3/2)n.
So,Doptionistheanswer.
name

GATE2003_64top
LetSbe a stack of size n 1. Starting with the empty stack, suppose we push the first n natural numbers in sequence, and then perform n pop operations.
AssumethatPushandPopoperationstakeXsecondseach,andYsecondselapsebetweentheendofonesuchstackoperationandthestartofthenextoperation.
Form1,definethestacklifeofmasthetimeelapsedfromtheendofPush(m)tothestartofthepopoperationthatremovesmfromS.Theaveragestacklife
ofanelementofthisstackis

A. n(X+Y)
B. 3Y+2X
C. n(X+Y)X
D. Y+2X

letusrepresentstacklifeofithelementasS(i)
S(i)=Y+2.(ni)(Y+X)=Y+2.(ni)Z
whereZ=Y+X
http://gateoverflow.in/book

377/400

2/26/2015

GATEOverflow Book

averagestacklifewill,A=S(i)/n
nA=nY+2.n.n.Z2.Z.i
nA=nY+2.n.n.Z2.Z(n(n+1))/2
nA=nY+2.n.n.ZZ(n.n)n.Z
A=Y+2.n.Z(n+1).Z
A=Y+(n1).Z=Y+(n1)(X+Y)=n(X+Y)X
name

GATE2003_90top
Considerthefunctionfdefinedbelow.
struct item {
int data;
struct item * next;

};
int f(struct item *p) {
return ((p==NULL) || (p->next==NULL)||
((p=>data <= p ->next -> data) &&
f(p->next)));
}

Foragivenlinkedlistp,thefunctionfreturns1ifandonlyif
A. thelistisemptyorhasexactlyoneelement
B. theelementsinthelistaresortedinnondecreasingorderofdatavalue
C. theelementsinthelistaresortedinnonincreasingorderofdatavalue
D. notallelementsinthelisthavethesamedatavalue

Itreturns1ifthelinkedlistissortedinincreasingorder
name

GATE2004_5top

STACKScantheexpressionfromlefttorightwheneveraleftparanthesisisencounteredjustPUSHitintostackandwheneverarightparanthesisis
encounteredjustPOPitfromstack..ifattheendofexpressionweareleftwithanemptystackthenitisacorrectlyparenthesizedexpression
name

GATE2004_7top
http://gateoverflow.in/book

378/400

2/26/2015

GATEOverflow Book

optionciscorrectbecausethelastdigitofeverydigitgivenisequaliniandii
name

GATE2004_36top

ThepointerpointstotheRearnode.
EnQueue:InsertnewNodeafterRear,andmakeRearpointtothenewlyinsertednode:
//struct node *newNode;
newNode->next = rear->next;
rear->next = newNode;
rear=newNode;

DeQueue:DeletetheFrontnode,andmakethesecondnodethefrontnode.
//rear->next points to the front node.
//front->next points to the second node.
struct node* front;
front = rear->next;
rear->next = front->next;
free(front);

name

GATE2007_38top
Thefollowingpostfixexpressionwithsingledigitoperandsisevaluatedusingastack:
823^/23*+51*
Notethat^istheexponentiationoperator.Thetoptwoelementsofthestackafterthefirst*isevaluatedare
A.
B.
C.
D.

6,1
5,7
3,2
1,5

push8sostackis8
push2sostackis82
push823
^pop3and2performopn2^3andpushtostack.stackis88
http://gateoverflow.in/book

379/400

2/26/2015

GATEOverflow Book

/pop8and8perform8/8andpushresulttostack.stackis1
push2stackis12
push3stackis123
*pop3and2performby2*3andpush.stackis16

henceanswerisA
name

GATE2007_43top
Acompletenarytreeisatreeinwhicheachnodehasnchildrenornochildren.LetIbethenumberofinternalnodesandLbethenumberofleavesina
completenarytree.IfL=41andI=10,whatisthevalueofn?
A.
B.
C.
D.

3
4
5
6

Sumofdegreesintree=L+I*(n+1)1=10n+50(Eachleafnodehasdegree1andallinternalnodeshavedegreek+1,exceptrootwhichhasdegreek)
So,numberofedges=5n+25(Numberofedgesinagraph(henceapplicablefortreealso)ishalfthesumofdegreesaseachedgecontribute2tothesumof
degrees)
Inatreewithnnodeswehaven1edges,sowith41+10=51nodes,theremustbe50edges.
So,5n+25=50
5n=25=>n=5

name

GATE2009_59,60top
Considerabinarymaxheapimplementedusinganarray.
59.Whichoneofthefollowingarrayrepresentsabinarymaxheap?
A.
B.
C.
D.

{25, 12, 16, 13, 10, 8, 14}

{25, 14, 13, 16, 10, 8, 12}


{25, 14, 16, 13, 10, 8, 12}
{25, 14, 12, 13, 10, 8, 16}

60.Whatisthecontentofthearrayaftertwodeleteoperationsonthecorrectanswertothepreviousquestion?
A.
B.
C.
D.

{14, 13, 12, 10, 8}


{14, 12, 13, 8, 10}
{14, 13, 8, 12, 10}
{14, 13, 12, 8, 10}

Takingthegivenarrayaslevelordertraversal,wecanbuildbinarytree.
(A)13comesaschildof12,whichisnotallowedinabinarymaxheap
(B)16comesaschildof14violatingmaxheapproperty
(C)isavalidbinarymaxheapasallchildrenaresmallerthantheirparent
(D)16comesaschildof12,violatingmaxheapproperty
60.Duringdelete,therootelementisremoved,replacedwiththelastelementandheappropertyiscorrectedbypushingtherootdownwards.So,forfirst
delete,
2514161310812>12141613108>16141213108(theelementnotsatisfyingmaxheappropertyisexchangedwiththelargestofitschildren)
(heappropertysatisfied)
http://gateoverflow.in/book

380/400

2/26/2015

GATEOverflow Book

Seconddelete:
16141213108>814121310>148121310>141312810(heappropertysatisfied)
http://homepages.ius.edu/RWISMAN/C455/html/notes/Chapter6/heapify.htm

name

GATE2005_2top
AnAbstractDataType(ADT)is:
A.
B.
C.
D.

sameasanabstractclass
adatatypethatcannotbeinstantiated
adatatypeforwhichonlytheoperationsdefinedonitcanbeused,butnoneelse
alloftheabove

Anabstractdatatype(ADT)supportsonlytheoperationswhicharedefined.
Abstractclassisonethatmaynothavedefinitionsofalltheobjectsithave.Moreoveritcannotbeinstantiated.Toinstantiatewehavetocreateasubclass
theninstantiatetheclass.
AbstractDataTypeislikedatastructureeg.STACKwherewehavePUSH()POP()operationdefined.
Hencetheyarenotthesamething.
http://www.devx.com/tips/Tip/5681
name

GATE2005_5top

asweourareaofinterestisonlythe50numberssotakeAnarrayof50numberswhere0correspondsto50,1correspondsto51...50correspondsto100then
afterreadinganinputjustincrementthecounterincorrectpositionassaidabove
name

GATE2005_34top
ApriorityqueueisimplementedasaMaxHeap.Initially,ithas5elements.Thelevelordertraversaloftheheapis:10,8,5,3,2.Twonewelements1and7are
insertedintotheheapinthatorder.Thelevelordertraversaloftheheapaftertheinsertionoftheelementsis:
(A)10,8,7,5,3,2,1
(B)10,8,7,2,3,1,5
(C)10,8,7,1,2,3,5

(D)10,8,7,3,2,1,5

ansisD....wheneverweinsertanelementinheap,itwillalwaysinsertedinlastlevelfromlefttoright..sohereweinsertelement1and7asachildofnode
5.thenweperformheapifyalgorithmuntilwegetthemin/maxheap..soherefinallyinabovequestionwegettheheapwhoselevelordertraversalis
10,8,7,3,2,1,5
Initialheap:

http://gateoverflow.in/book

381/400

2/26/2015

GATEOverflow Book

Afterinsertof1

Afterinsertof7

nehapawar

GATE1998_2.11top

AnsisA
name

GATE1998_2.14top

A[LB1..............UB1,LB2.................UB2]
http://gateoverflow.in/book

382/400

2/26/2015

GATEOverflow Book

BA=Baseaddress.
C=sizeofeachelement.
Rowmajororder.
Loc(a[i][j])=BA+[(iLB1)(UB2LB2+1)+(jLB2)]*C.
ColumnMajororder

Loc(a[i][j])=BA+[(jLB2)(UB1LB1+1)+(iLB1)]*C.
substitutingthevalues.answerisA.

name

GATE2006_49top
AnimplementationofaqueueQ,usingtwostacksS1andS2,isgivenbelow:
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;
}
else while (!(stack-empty(S1))){
x=pop(S1);
push(S2,x);
}
x=pop(S2);
}

letn insertandm( n) deleteoperationsbeperformedinanarbitraryorderonanemptyqueueQ.Letx andy bethenumberofpushand


popoperationsperformedrespectivelyintheprocess.Whichoneofthefollowingistrueforallm andn ?
(A)n + m

x < 2n

(B)n + m

x < 2n

(C)2m

x < 2n

(D)2m

x < 2n

and2m

y n + m

and2m

y 2n

and2m

y n + m

and2m

y 2n

Answeris(a)
Theorderinwhichinsertanddeleteoperationsareperformedmattershere.
Thebestcase:Insertanddeleteoperationsareperformedalternatively.Ineverydeleteoperation,2popand1pushoperationsareperformed.So,totalm+n
push(npushforinsert()andmpushfordelete())operationsand2mpopoperationsareperformed.
Theworstcase:Firstnelementsareinsertedandthenmelementsaredeleted.Infirstdeleteoperation,n+1popoperationsandnpushoperationare
performed.Otherthanfirst,inalldeleteoperations,1popoperationisperformed.So,totalm+npopoperationsand2npushoperationsareperformed(n
pushforinsert()andmpushfordelete())
name

GATE20141_40top
Considerahashtablewith9slots.Thehashfunctionish(k) = k mod 9 .Thecollisionsareresolvedbychaining.Thefollowing9keysareinsertedinthe
order:5,28,19,15,20,33,12,17,10.Themaximum,minimum,andaveragechainlengthsinthehashtable,respectively,are
(A)3,0,and1
(B)3,3,and3
(C)4,0,and1
(D)3,0,and2

http://gateoverflow.in/book

383/400

2/26/2015

GATEOverflow Book

So,Maximum&minimumchainlengthsare3&0respectively.
Averagechainlength=(0+3+1+1+0+1+2+0+1)/9=1.
So,AnsisA

name

GATE20142_12top
ApriorityqueueisimplementedasaMaxHeap.Initially,ithas5elements.Thelevelordertraversaloftheheapis:10,8,5,3,2.Twonewelements1and7are
insertedintotheheapinthatorder.Thelevelordertraversaloftheheapaftertheinsertionoftheelementsis:

(A)10,8,7,3,2,1,5
(B)10,8,7,2,3,1,5
(C)10,8,7,1,2,3,5
(D)10,8,7,5,3,2,1

ansisA....wheneverinsertionwillbedoneinheap,itwillalwaysinsertedinlastlevelfromlefttoright.soweinsert1and7asachildofnode5nowwe
performheapifyalgorithmuntilheappropertywillsatisfied..andthenwegettheheapwhoselevelordertraversalis10,8,7,3,2,1,5
Initialheap

Afterinsertof1

http://gateoverflow.in/book

384/400

2/26/2015

GATEOverflow Book

Afterinsertof7

nehapawar

GATE20142_41top
SupposeastackimplementationsupportsaninstructionREVERSE,whichreversestheorderofelementsonthestack,inadditiontothePUSHandPOP
instructions.WhichoneofthefollowingstatementsisTRUE(withrespecttothismodifiedstack)?
(A)Aqueuecannotbeimplementedusingthisstack.
(B)AqueuecanbeimplementedwhereENQUEUEtakesasingleinstructionandDEQUEUEtakesasequenceoftwoinstructions.
(C)AqueuecanbeimplementedwhereENQUEUEtakesasequenceofthreeinstructionsandDEQUEUEtakesasingleinstruction.
(D)AqueuecanbeimplementedwherebothENQUEUEandDEQUEUEtakeasingleinstructioneach.
(C)istheanswer.WhileENQUEUEweREVERSEthestack,PUSHtheelementandthenagainREVERSEthestack.ForDEQUEwesimplyPOPthe
element.
(Option(B)canbeusedtogetthefirstelementfromthestackbydoingaPOPafterREVERSE.ButwehavetorestorethestackusingREVERSE(otherwise
nextPOPwon'twork)whichmeansENQUEUEactuallyneeds3instructionsandnot2)
name

GATE20143_40top
Considerahashtablewith100slots.Collisionsareresolvedusingchaining.Assumingsimpleuniformhashing,whatistheprobabilitythatthefirst3slotsareunfilled
afterthefirst3insertions?
(A)(97 97 97)/100

(B)(99 98 97)/1003
(C)(97 96 95)/100

(D)(97 96 95/(3! 100

Wehave100slotseachofwhicharepickedwithequalprobabilitybythehashfunction(sincehashingisuniform).So,toavoidfirst3slots,thehashfunction
hastopickfromtheremaining97slots.Andrepetitionisallowed,sincechainingisusedmeaningalistofelementsarestoredinaslotandnotasingle
element.
So,requiredprobability=
= (97 97 97)/100

http://gateoverflow.in/book

97
100

97
100

97
100

385/400

2/26/2015

GATEOverflow Book

name

GATE1997_4.7top

Implementingstackusingpriorityqueuerequirefirstelementinsertedinstackwillbedeletedatlast,andtoimplementitusingdeletemin()operationof
queuewillrequirefirstelementinsertedinqueuemusthavehighestpriority.
Sothekeysmustbeinstrictlydecreasingorder.
name

GATE1994_1.14top
Whichofthefollowingpermutationscanbeobtainedintheoutput(inthesameorder)usingastackassumingthattheinputisthesequence1, 2, 3, 4, 5 inthat
order?
(a)3, 4, 5, 1, 2
(b)3, 4, 5, 2, 1
(c)1, 5, 2, 3, 4
(d)5, 4, 3, 1, 2
push1push2push3pop3push4pop4push5pop5pop2pop1theno/pis3,4,5,2,1optionb
name

GATE1996_1.12top

A.
i)andiv)arefalse.
http://en.wikipedia.org/wiki/List_(abstract_data_type)#Operations
name

GATE1996_1.14top

B.
a,b,cwillbecomeunbalancedwithBalancefactoras+2,+2,+2respectively.Balancefactorshouldbe1,0,+1.
Balancefactor=Height(LST)Height(RST).
http://gateoverflow.in/book

386/400

2/26/2015

GATEOverflow Book

name

GATE1996_2.11top
Theminimumnumberofinterchangesneededtoconvertthearrayintoamaxheapis
89,19,40,17,12,10,2,5,7,11,6,9,70
(a)0
(b)1
(c)2
(d)3
"Theminimumnumberofinterchangesneededtoconvertthearray
89,19,40,17,12,10,2,5,7,11,6,9,70
intoaheapwiththemaximumelementattherootnodeis:"
Thisisthecorrection.
Answer:C.
Onlyelement70violatestherule.Hence,itmustbeshiftedtoitsproperposition.
Step1:swap(10,70)
Step2:swap(40,70)
Hence,only2interchangesarerequired.
name

GATE2008IT_72top
ABinarySearchTree(BST)storesvaluesintherange37to573.Considerthefollowingsequenceofkeys.
I. 81,537,102,439,285,376,305
II. 52,97,121,195,242,381,472
III. 142,248,520,386,345,270,307
IV. 550,149,507,395,463,402,270
WhichofthefollowingstatementsisTRUE?

A)
B)
C)
D)

I,IIandIVareinordersequencesofthreedifferentBSTs
IisapreordersequenceofsomeBSTwith439astheroot
IIisaninordersequenceofsomeBSTwhere121istherootand52isaleaf
IVisapostordersequenceofsomeBSTwith149astheroot
itshouldbeC)
Inordersequencesaresorted.Inpreordertraversalrootcomesfirstandinpostordertraversalrootcomeslast.
name

GATE2008IT_76top
A binary tree with n > 1 nodes has n1, n2 and n3 nodes of degree one, two and three respec
tively. The degree of a node is defined as the number of its
neighbours.
n3canbeexpressedas

A)

n1+n21

B)

n12

C)

[((n1+n2)/2)]

D)

n21

http://gateoverflow.in/book

387/400

2/26/2015

GATEOverflow Book

assumetheabovetreesovalueofn1is3n2=1n3=1checkwithoptionsnowuvilgetoptionBascorrect
name

GATE2008IT_77top
A binary tree with n > 1 nodes has n1, n2 and n3 nodes of degree one, two and three respec
tively. The degree of a node is defined as the number of its
neighbours.
Startingwiththeabovetree,whilethereremainsanodevofdegreetwointhetree,addanedgebetweenthetwoneighboursofvandthenremovevfromthe
tree.Howmanyedgeswillremainattheendoftheprocess?

A)

2*n13

B)

n2+2*n12

C)

n3n2

D)

n2+n12

fromabovetreewewillgetthetreebelow

http://gateoverflow.in/book

388/400

2/26/2015

GATEOverflow Book

nowcheckwiththeoptionsuvilgetaasanswer
name

GATE2007IT_29top
Whensearchingforthekeyvalue60inabinarysearchtree,nodescontainingthekeyvalues10,20,40,50,7080,90aretraversed,notnecessarilyintheorder
given.Howmanydifferentordersarepossibleinwhichthesekeyvaluescanoccuronthesearchpathfromtheroottothenodecontainingthevalue60?

A)
B)
C)
D)

35
64
128
5040

10,20,40,50,7080,90
InBSTsearchweifwegofromsay10to40whilesearchingfor60,wewillneverencounter20.So,10,20,40and50visited,meanstheyarevisitedin
order.Similarly,90,80and70arevisitedinorder.So,ourrequiredanswerwillbe

(Sinceonlyonepermutationisvalidforboththesmallersetofnumberaswellaslargersetofnumbers)
=

7!
4!3!

= 35

name

GATE2006IT_44top
Whichofthefollowingsequencesofarrayelementsformsaheap?

A)
B)
C)
D)

{23,17,14,6,13,10,1,12,7,5}
{23,17,14,6,13,10,1,5,7,12}
{23,17,14,7,13,10,1,5,6,12}
{23,17,14,7,13,10,1,12,5,7}
foraheap(maxheap)parentshouldbegreaterthanorequaltochildren.inaheapof[1..n]leftchildofithnodewillbeat2*ithpositionandrightchildwill
beat2*i+1position
soforgivenoptionswecanverifyit
optionCseemstobefollowingtheproperty
name

GATE2006IT_45top
Supposethatwehavenumbersbetween1and100inabinarysearchtreeandwanttosearchforthenumber55.WhichofthefollowingsequencesCANNOTbe
thesequenceofnodesexamined?

A)
B)
C)
D)

{10,75,64,43,60,57,55}
{90,12,68,34,62,45,55}
{9,85,47,68,43,57,55}
{79,14,72,56,16,53,55}
inoptionCsearchsequenceprogressin...47,68,43,..
at47weseethatsearchkey55isgreateranditwillbeonrightsideof47.soinfurthercomparisonavaluelessthan47willnotcome
henceoptionciswrong
name

http://gateoverflow.in/book

389/400

2/26/2015

GATEOverflow Book

GATE2006IT_71top
AnarrayXofndistinctintegersisinterpretedasacompletebinarytree.Theindexofthefirstelementofthearrayis0.TheindexoftheparentofelementX[i],
i0,is
A.
B.
C.
D.

i/2
(i1)/2
i/2
i/21

optionD
leftchildofithelementwillbeat2*i+1andrightchildat2(i+1)
name

GATE2006IT_73top
AnarrayXofndistinctintegersisinterpretedasacompletebinarytree.Theindexofthefirstelementofthearrayis0.Iftherootnodeisatlevel0,thelevelof
elementX[i],i0,is

A) log2i
B) log2(i+1)
C) log2(i+1)
D) log2i
Floor(log(i+1))drawthetreeandrealisethatthelastelementateachlevelisthebestchoicetoarriveataconclusion
name

GATE2004IT_53top
Anarrayofintegersofsizencanbeconvertedintoaheapbyadjustingtheheapsrootedateachinternalnodeofthecompletebinarytreestartingatthenode(n
1)/2,anddoingthisadjustmentuptotherootnode(rootnodeisatindex0)intheorder(n1)/2,(n3)/2,.....,0.Thetimerequiredtoconstructaheapin
thismanneris

A)
B)
C)
D)

O(logn)
O(n)
O(nloglogn)
O(nlogn)
itshudbeO(n).
name

GATE2004IT_54top
WhichoneofthefollowingbinarytreeshasitsinorderandpreordertraversalsasBCADandABCD,respectively?

A)

B)

http://gateoverflow.in/book

390/400

2/26/2015

GATEOverflow Book

C)

D)

inordertraversalisleftnoderight
preorderisnodeleftright

answer:D
name

GATE2005IT_12top
Thenumbers1,2,....nareinsertedinabinarysearchtreeinsomeorder.Intheresultingtree,therightsubtreeoftherootcontainspnodes.Thefirstnumberto
beinsertedinthetreemustbe
A.
B.
C.
D.

p
p+1
np
np+1

from1,...nelementspelementsareontheright.sorootorfirstinsertedwillbeatnp
name

GATE2005IT_13top
Afunctionfdefinedonstacksofintegerssatisfiesthefollowingproperties.f()=0andf(push(S,i))=max(f(S),0)+iforallstacksSandintegersi.
IfastackScontainstheintegers2,3,2,1,2inorderfrombottomtotop,whatisf(S)?

A)
B)
C)
D)

http://gateoverflow.in/book

6
4
3
2

391/400

2/26/2015

GATEOverflow Book

Ihopethishelps!

Shridhar

GATE2005IT_16top
Ahashtablecontains10bucketsanduseslinearprobingtoresolvecollisions.Thekeyvaluesareintegersandthehashfunctionusediskey%10.Ifthevalues
43,165,62,123,142areinsertedinthetable,inwhatlocationwouldthekeyvalue142beinserted?

A)
B)
C)
D)

2
3
4
6
43inloc3
165inloc5
62inloc2
123inloc4(collissionandnextfreespace)
142inloc6(collisionin2,and3,4,5alreadyoccupied)
henceanswerD
name

GATE2005IT_50top
Inabinarytree,foreverynodethedifferencebetweenthenumberofnodesintheleftandrightsubtreesisatmost2.Iftheheightofthetreeish>0,thenthe
minimumnumberofnodesinthetreeis

A)

2h1

B)

2h1+1

C)

2h1

D)

2h
itshouldbeB)
name

GATE2005IT_54top
http://gateoverflow.in/book

392/400

2/26/2015

GATEOverflow Book

The following C function takes a singlylinked list of integers as a parameter and rearranges the elements of the list. The list is represented as pointer to a
structure.Thefunctioniscalledwiththelistcontainingtheintegers1,2,3,4,5,6,7inthegivenorder.Whatwillbethecontentsofthelistafterthefunction
completesexecution?

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)
B)
C)
D)

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

ithinkit'sB)2143657:
as,
pandqareswappingeachother.whereqisp>nextallthetime.
name

GATE2005IT_55top
Abinarysearchtreecontainsthenumbers1,2,3,4,5,6,7,8.Whenthetreeistraversedinpreorderandthevaluesineachnodeprintedout,thesequenceof
valuesobtainedis5,3,1,2,4,6,8,7.Ifthetreeistraversedinpostorder,thesequenceobtainedwouldbe

A)
B)
C)
D)

8,7,6,5,4,3,2,1
1,2,3,4,8,7,6,5
2,1,4,3,6,7,8,5
2,1,4,3,7,8,6,5

AnswerisD.

http://gateoverflow.in/book

393/400

2/26/2015

GATEOverflow Book

name

GATE20151_10top
Whichofthefollowingis/arecorrectinordertraversalsequence(s)ofbinarysearchtree(s)?
I. 3,5,7,8,15,19,25
II. 5,8,9,12,10,15,25
III. 2,7,10,8,14,16,20
IV. 4,6,7,9,18,20,25

A.
B.
C.
D.

IandIVonly
IIandIIIonly
IIandIVonly
IIonly

optionAisright..chekforleftrootrightrule
name

GATE20152_38top
ConsidertheCprogrambelow
#include <stdio.h>
int *A, stkTop;
int stkFunc (int opcode, int val)
{
static int size=0, stkTop=0;
switch (opcode) {
case -1: size = val; break;

http://gateoverflow.in/book

394/400

2/26/2015

GATEOverflow Book
case 0: if (stkTop < size ) A[stkTop++]=val; break;
default: if (stkTop) return A[--stkTop];

}
return -1;
}
int main()
{
int B[20]; A=B; stkTop = -1;
stkFunc (-1, 10);
stkFunc (0, 5);
stkFunc (0, 10);
printf ("%d\n", stkFunc(1, 0)+ stkFunc(1, 0));
}

Thevalueprintedbytheaboveprogramis________.
Answer:15
Thecodeispushing5and10onstackandthenpoppingthetoptwoelementsandprintingtheirsum.
Referhere:http://ideone.com/kIUdQT
name

GATE20151_23top
Whataretheworstcasecomplexitiesofinsertionanddeletionofakeyinabinarysearchtree?
A.
B.
C.
D.

(logn)forbothinsertionanddeletion
(n)forbothinsertionanddeletion
(n)forinsertionand(logn)fordeletion
(logn)forinsertionand(n)fordeletion

optionb,bothhappenswhentheBSTisskewed.
GATERush

GATE20151_25top
Theheightofatreeisthelengthofthelongestroottoleafpathinit.Themaximumandminimumnumberofnodesinabinarytreeofheight5are
A.
B.
C.
D.

63and6,respectively
64and5,respectively
32and6,respectively
31and5,respectively

optionAiscorrectbecauseheight5meanslevel6somaximumnode=2^l1=2^61=63
andforminimum,ateachlevelonlysinglenodesototal6

name

GATE20151_32top
Consideramaxheap,representedbythearray:40,30,20,10,15,16,17,8,4.
Arrayindex
Value

1
40

2
30

3
20

4
10

5
15

6
16

7
17

8
8

9
4

Nowconsiderthatavalue35isinsertedintothisheap.Afterinsertion,thenewheapis
A.
B.
C.
D.

40,30,20,10,15,16,17,8,4,35
40,35,20,10,30,16,17,8,4,15
40,30,20,10,35,16,17,8,4,15
40,35,20,10,15,16,17,8,4,30

Heapiscompletebinarytree.Toinsertanewelement,weputitattheendofthetreeandmoveuptowardsroottillheappropertyissatisfied.Here,35comes
aschildof15,withthepath40301535.So,weswap15,35andthen30,35togetthenewpath40353015.So,newheapwillbe403520103016178
415.
name

http://gateoverflow.in/book

395/400

2/26/2015

GATEOverflow Book

GATE20151_40top
Analgorithmperforms(logN)1/2findoperations,Ninsertoperations,(logN)1/2deleteoperations,and(logN)1/2decreasekeyoperationsonasetofdataitems
withkeysdrawnfromalinearlyorderedset.Foradeleteoperation,apointerisprovidedtotherecordthatmustbedeleted.Forthedecreasekeyoperation,a
pointerisprovidedtotherecordthathasitskeydecreased.Whichoneofthefollowingdatastructuresisthemostsuitedforthealgorithmtouse,ifthegoalisto
achievethebesttotalasymptoticcomplexityconsideringalltheoperation?
A.
B.
C.
D.

Unsortedarray
Minheap
Sortedarray
Sorteddoublylinkedlist

NumberofInsertoperationsisthesignificantonehere.ForNinsertoperations,
Unsortedarray:O(N)
Minheap:O(NlogN)
Sortedarray:O(NlogN)
Sorteddoublylinkedlist:O(NlogN).
So,Unsortedarrayistheanswer.
name

GATE20153_12top
Theresultevaluatingthepostfixexpression105+606/*8is

A.
B.
C.
D.

284
213
142
71

wehavetokeepsymbolintostackandwhenwegettwooperandsfollowedbyoperator..wewillapplyoperatoronlasttwooperands

symbolstack
1010(keepinstack)
5105(keepinstack)
+105+=10+5=15(applyoperatoronlast2operands)
601560(keepinstack)
615606(keepinstack)
/15606/=1510(applyoperatoronlast2operands)
*1510*=150(applyoperatoronlast2operands)
81508(Keepinstack)
1508=1508=142(applyoperatoronlast2operands)
Soansweris142

name

GATE20153_13top
Whileinsertingtheelements71,65,84,69,67,83inanemptybinarysearchtree(BST)inthesequenceshown,theelementinthelowestlevelis

A.
B.
C.
D.

65
67
69
83

optionB....67becauseitisonlevel3and83isonlevel2
name
http://gateoverflow.in/book

396/400

2/26/2015

GATEOverflow Book

GATE20153_17top
GiventhathashtableT with25slotsthatstores2000elements,theloadfactora forT is_________.
loadfactor=totalnoelement/totalnoofslots2000/25=80
name

GATE20153_19top
Considerthefollowingarrayofelements.

89, 19, 50, 17, 12, 15, 2, 5, 7, 11, 6, 9, 100


Theminimumnumberofinterchangesneededtoconvertitintoamaxheapis

A.
B.
C.
D.

4
5
2
3

firstinterchange15100
2nd50100
3rd89100
sototalinterchange3sooptionDiscorrect.
name

GATE20153_25top
ConsiderabinarytreeTthathas200leafnodes.ThenthenumberofnodesinTthathaveexactlytwochildrenare______.
Letnumberofnodeswithexactlytwochildrenbex,andwithexactlyonechildrenbey.
Totaldegree=200+3x+2y1(Asallnodeswith2childrenhavedegree3excepttheroot)
No.ofnodes=x+y+200
No.ofedges=Totaldegree/2=(200+3x+2y1)/2
No.ofedgesinatree=No.ofnodes1
So,(200+3x+2y1)=2x+2y+4002
x=199
name

http://gateoverflow.in/book

397/400

2/26/2015

GATEOverflow Book

Otherstop
C++andjavaarenotinsyllabusforgateCSE?top
Yes.C++andJavaarenotinGATEsyllabusforCSE.GATEisforcheckingbasicsonlyandhenceonlyCisincluded.EvenforC,GATEchecksthebasics
ofprogrammingconceptsandnotanysyntaxbasedoutputsasoftenaskedforplacements.YoucanseethesyllabusforGATE2015.
http://gatecse.in/w/images/1/13/2015_syllabus.pdf(for85marks)
http://gate.iitk.ac.in/GATE2015/docs/syllabi/GA.pdf(GeneralAptitudefor15marks)
gatecse

http://gateoverflow.in/book

398/400

2/26/2015

GATEOverflow Book

OutofSyllabusNowtop
linearprogramming....explainittop

(D).
https://people.richland.edu/james/lecture/m116/systems/linear.html
name

http://gateoverflow.in/book

399/400

2/26/2015

GATEOverflow Book

BroughttoyoubyGATEOverflow
http://gateoverflow.in/

http://gateoverflow.in/book

400/400

You might also like