You are on page 1of 93

SonyIndiaSoftwareCentrePrivatelimited

WrittenExampattern???????
ImpetusTechnologies
WrittenExam????

sigmoidquestionpaper
Q1.Writeaprogramtoreversethewordsinastring

5points

Forexample:
Input:mynameishello
Output:helloisnamemy
Note:
WriteOnlytheFunctions&returntheoutput.
Donotwritemainorinput/outputhandlers.
Q2.Youvegotsomeoneworkingforyouforsevendaysandagoldbartopaythem.Youmust
paytheworkerfortheirworkattheendofeveryday.Ifyouareonlyallowedtomaketwo
breaksinthegoldbar,howdoyoupayyourworker?(Assumingequalamountofworkisdone
duringeachdaythusrequiringequalamount(1/7goldbrick)ofpayforeachday)
5points
Q3a.Writethecodetoevaluateifagivenstringisapalindrome.
points
Input:abcd
Output:0
Input:aba

Output1
Input:a
Output1
Note:
WriteOnlytheFunctions&returntheoutput.

Donotwritemainorinput/outputhandlers.

Q3b. Write the code to find the minimum number of characters to be


appended to a word to make it a palindrome
20 points
Example:
Input:abba
Output:0
Input:abb
Output:1

Note:
WriteOnlytheFunctions&returntheoutput.

Donotwritemainorinput/outputhandlers.
Q4.Writethecodetofindcharacterwithsecondhighestfrequencyinagivenstring
points
Forex:
Input:aaabbc
Output:b
Input:abcdddcaa
Output:c

Note:

10

WriteOnlytheFunctions&returntheoutput.

Donotwritemainorinput/outputhandlers.
Q5.Createthedatastructureforabinarysearchtree.Writeafunctiontoevaluateifagiven
binarytreeisavalidbinarysearchtree.

20points

Note:
WriteOnlytheFunctions&returntheoutput.

Donotwritemainorinput/outputhandlers.
Q6a.Functiontoevaluateamathematicalexpressionthathasonlyintegers,operators(+,*)and
numbers.

15points

Input:1*2+3
Output:6

Note:
WriteOnlytheFunctions&returntheoutput.

Donotwritemainorinput/outputhandlers.
Q6b.ExtendthefunctionfromQ6toevaluateamathematicalexpressionthathasbrackets,
integers,operators(+,*)andnumbers.
Input:(1+2)*3
Output:9

Note:
WriteOnlytheFunctions&returntheoutput.

Donotwritemainorinput/outputhandlers.

20points

Hascapitaldynamicsgivenoffer
lettersatanyIITafterGD&
interviewortheygavejustan
assignment(likeatIITD)?
IITDORIITBGUYSPLZUPDATE
INFORMATICAINTERVIEWQUESTIONSASAP
ANYIDEAABOUTRILANDITSTESTORINTERVIEW?
samequestionasnitwarangal

guwahati guys
30apti.questionsand60Technicalchemicalmultiplechoicequestionsin60minutes.
Youwillhavetocleartheaptituderoundtobeconsideredfortheinterviewselection.

capillary questions plz??

Codinground:
Sudokupuzzle.Tocheckwhetheritiscorrectornot.

SaavnWritten
Guys plzz share eBay interview questions asap ???

ERICSSONQuestionPaperanyidea??
5sectionsforeachquestion+1or1,75bits60mins
english15
reasoning15
quant15
technical15
programing15
thereisseparatepapersforECEandCSE
whattypeoftechnicalques???

MoojicQuestionPaperanyidea??Theyhavechangedthe
process!!

NetApp,Symantecheldanywhere???????Plz
updatethequestions
Anyhpwrittentestquestions??
hfORACLE

AnyupdateonTEXASINSTRUMENTSwrittentest???
ItsonAnalogDesign
PLEASEupdateSYOPSYSquestions.

VmwareInterviewfeedback?please..
VMWareinterviewIITKGP
AskedOSquestions
1.Communicationb/wthreads
2.Heapmemoryrelated
Javaques
1.Annotation
2.Methodoverloading3.inheritance
Datastructure:
1.Commonancestorstotwogivennodesoftree
2.findtop5elementsof1000element
3.Queueusingstack
4.mergesort
5.LongestincreasingsubsequenceDynamicProgramming
6.Frequencycountofallwordspresentinfile
7.Zigzagtraversaloftree
Quesaboutmyproject
AnyUpdateaboutCISCOwrittentest?
AnyUpdatefromiitmRegarding
WrittenTEST?pleasefcisco
IITG:Easytestconductedbycocubestotalof60questionsin60min..Cutofwasa
round5052
3sections...1.English2.mathematicalabilities3.Quant

SamsungInterviewQuestionsPleaseReplyhere

LinkedIninterviewfeedback@IITMadras

1.Designquestion.WhatinterestingandusefulfeaturewouldyouaddtoLinkedIn
website,whichisnotyetpresentinthewebsite.
2.ConvertRomannumberstringtointegers.Convertdecimalintegerstoromannumber
strings.
3.Computeallmultiplesofanumber.
4.Paintthehousessuchthatneighbouringhousesdonothavesamecolorpaints.Each
painthasanassociatedcost.Paintallhousessuchthatcostisminimum.
5.ComputenumberofBSTsthatcanbeformedwith1tonkeys.
6.Givenanarrayofintegers,computeanotherarraywhichcontainsproductofall
elementsexceptithelementfrominputarray,withoutusingdivisionoperation.
7.Implementhashtables.
8.Givenastreamofcharacters(streamisincreasingcharbychar),checkifnewly
formed10characterwordispresentinalreadyparsed/scannedstream.Printsuch
repeatingstreamslexicographicallyattheend.
9.Questionsonproject,internships.
GuysPleaseupdatequestionsformIITRoorkee??Please
pleasepleaseplease..
ABCOAdvisoryBoard
90minutespenandpapertest
2codingquestions
1)Nexthighernumberwithsamenumberofsetbits
http://www.geeksforgeeks.org/nexthighernumberwithsamenumberofsetbits/
2)printbinarytreefromtoptodownandbottomupmanner(Verticalzigzag).
mcqs,basedonsimplemathematics,algos,os,networks.

25questions+1programmingquestion
Questiontype:12objectivetype,restofthequestionsdidn'thaveanyoptions!Hadtowritethe
answerinthespaceprovided.

LotsofCconceptstested."Giveoutputofprogram"typequestions.
IITKharagpur:
Q1.PROGRAMMINGQUESTION
Givenanumberasastring/integerarray,writeafunctiontofindthenumberofcontiguous
subsequencesofthearraywhichrecursivelyaddupto9.
http://locklessinc.com/articles/binary_search/
eg:4189=>mustreturn3asthereare3subsequences={18,189,9}
Recursiveaddition:
18=>1+8=>9
189=>1+8+9=>18=>1+8=>9
9
Mainlogic:allnumberswhichrecursivelyaddupto9willbedivisibleby9.Thenfindsumofall
possiblecontiguoussequencesandcheck%9.
O(n^2)
Therecanbebettersolutions.ThisiswhatIcouldget.
Q2.AnelementisaLeaderifitisgreaterthanalltheelementstotherightofit.Howmany
iterationsneedtobedonetodeterminealltheleaderelementsinanarray.
Ans:O(n)
Q3.Normalcodeofbinarysearchgiven.Thiscodecausearithmeticoverflowincertaincases.
Rectifythatlinewithafix.cap
Answer:
Issuehappensinthisline:
m=(low+high)/2
Fix:

m=low+(highlow)/2
Althoughnotcompletely
Forknowledgereferthis:
Q4.Inthefollowingsequencea,b,b,c,c,c,d,d,d,d,....Findthe288thelement.
Ans:x
Q5.A2darrayofsizenxnisgivenwiththefollowingproperty:
allrowsandcolumnsareinascendingsortedorder.
Tofindagivenelementkinthearray,thisprocedureisgiven:
1. Startattoprightelement
2. Forcurrentelemente
1. ife=k
1. returntrue
2. ifk<elemente
1. movetoleft,ifpossible.Ifarray'sleftboundreached,quit.
3. ifk>elemente
1. movetobottom,ifpossible.Ifarray'sbottomboundreached,quit.
Whatisthenumberofelementsthatarecomparedtok,intheworstcase?
Ans:2n1
Q6.
intmain()
{
floatx=0.1
if(x==0.1)
printf("IF")

elseif(x==0.1f)
printf("ELSEIF")
else
printf("ELSE")
}
Whatistheoutputofthefollowingprogram?
Ans:ELSEIF
Q7.
inta
intmain()
{
intb
..
..
}
intc
Whichofthevariableshaslongestscope?
Ans:a

Someotherbasicquestionsonlinkedlistsandnumberofswapsinbubblesortetc.

5questionsonSQLmoderatedifficultylevel
conceptstested:Join,outerjoin,groupby
SELECT....WHEREXLIKE'%ABC%'
Note:'%NUT%'matcheswith'SCREW_NUT'i.e.%canalsotakeemptystring.


4questionsonpassagecomprehension.(notenglishcompreshension:D)Thegivenpassage
introducedbasicformulaeonlinearregressionandstuff.Mean,slope,interceptetc.Thenthe
formulaewheretobeusedtofindsolutionforsomebasicquestions.
Iinitiallyskippedthissection.ButwhenIdidgettime,Icamebackandfoundthatatleast2qns
inthissectionwhereveryeasy.Justbasicmeanandadditionandstuff.Justusethegiven
formulaeandsolve.Pleasedotakeyourcalculatorswithyou!:)

CompanyMcAfee:
McAfee@IITB:
PenpapertestisconductedbyeLitmus.Total4sectionswith20questionsineachsection.
Quant,Reasoning,VerbalandTechnical.(Veryirritatingtest).
negativemarksafteryour25%wronganswerspersection.
Technicaldidnothaveanynegativemarking.
Technicalwassimplequestions.(23questionsaboutJAVAinheritance.)

CompanyFlexTrade:@IITB
Pattern???
Code:
1.Writeafunctionthatreturnsauniquecharacterfromanarrayofcharactersif
present
2.Writeafunctiontoreversealinkedlist

3.Writeafunctiontoreturnallpossiblewaysthatasequenceofpositivenumberssums
toN

DOESMorganStanleyfilteringtosecondroundbasedonround1??No,everyonehasto
givebothrounds
CompanyMorganStanley
2 papers: (very long)Update weight matrices based on feedback, drop a packet which seen by
allusers.
Paper1:quant+DS+OS(3sections):sectionalcutoff
Paper2:C/C++/Java(nocoding)

CompanyIntuit@IITM:(Somefunnygroupactivitywasconducted)
Fivequestionsoncoding(penandpapertest):
1)Writeaprogramtoguessanumbercorrectlybetween09999.
(Theywerenotclearaboutthequestion.ThesystemreturnsjustYesor
NO).Noinfoaboutthenumberbeinggreater/lesserwastold.
2)Somepuzzledontremember(120wirecablepuzzle)
3)Dynamicprogramming(TocountthenumberofpossiblepathsinMXNgrid)
4)Toconvertanumberinwords.(123,456,67)isonehundredandtwentythreemillion,four
hundredandfiftysixthousandandsixtyseven
5)Therearesomeonemillionhashtags.Uneedtoreturnthetop3hashtagswhichoccur
frequently

pleasepostthequestionsaskedandpatternofthepaper...anyIIT?????
CompanyPOCKETGEMS
@IITKGP
thereweretwoquestionsfor50minutes.bothofthemwerebasedondynamicapproach.
firstquestionwassameasgiveninthislink.

http://www.careercup.com/question?id=15928678

AlthoughsomequestionsofCISCOareupdatedbutcansomeoneupdateexactformatand
numberofquestionsalongwithquestionsifoneremembers?
PleasesharesomeCISCOQUESTIONSIITMGUYS
CompanyCISCO:
Itsanobjectivetestwith20inaptitudeand30frommicroelectronicsandbasicCSE
nosubjectivecodingquestions

Wasthebelowpatternsameforeverybranch(CSEandElectronicsboth)?Yes
Ifsomeoneremembersexactquestions,pleaseupdate.ButasfarasIremember,there
were
twoaptitudequestionsonaverages,
threeonordering(AcancomebeforeB),
oneheightsanddistances(pythagorean)
onedirections,
If423ismultipliedbyxandansweris45569,and55arewrongdigits,findtheright
product.
Answerplease?????????35

Whatisanumberthatleavesremainder3whendividedby5,6,7,8but0whendivided
by9
1683
Q.agoatistiedtoacornerofusquare,with7mrope.findtheareaofgrazing?
Someonepleaseupdatetechpart.

addressofRST6in8085
noofbinarytreespossiblewithnnodes?
catalanno
whyisAvalanchediodepreferredtoPIndiodel
Onequestiononflipflop
minimumnumberofNANDgatesrequiredinY=A+AB+ABC
Isit2??????????
Q:WhatisZenerdiode?
CompanyCapitalDynamics@IITKGP:
(1)whethertwostringsareanagramofeachotherornotirrespectiveofanythingyou
do,surely1testcasewillfailgodknowswhy:P(whatiftwostringsaresame?
(2)oudo,surely1testcasewillfailagaingodknowswhy:Phowmanytotal1sare
therefrom0ton(nwillbeinput).e.g.outputwillbe6forn=13(1,10,11,12,13so
totalsix1sarethere)herealsoirrespectiveofy.
(3)exactlysameasthebelowlink:http://www.geeksforgeeks.org/fi
ndthesmallestpositivenumbermissingfromanunsortedarray/
Inputarrayforques(3)willbeoftypechar
Werethereonly3questionsandwhatwasthepatternanddurationofthetest?
CompanyLinkedin@IITKgp:
Time:2hrs.
@6am:10/11/13(6AM?Really?Yes:))
1)Therearen(frominput)stepsandgivenanotherinputxi.e.youcanclimb1,2,3.x
stepsatatime.Howmanyofwayscanyoureachthetopstair.
Forexample,givenn=3,x=4
youcango1,1,1or1,2or2,1or0,3etc.So,itsshouldbe4.
//Answers
StarelationndardRecurrenceF(n,x)=F(n1,x)+F(n2,x)........................+F(nx,x)

.DynamicProg.isapplicable
Checkboundaryconditioncarefully.
2)Givenaundirectedgraph,findthediameterofthegraph.(Peoplemessedupwith
input!)
http://people.hofstra.edu/geotrans/eng/methods/diameter.html
Diameter:pathbetween2nodeshavingmaximumlength.`````
Thediameter ofagraphisthemaximumeccentricityofanyvertexinthegraph.Thatis, itis
thegreatestdistancebetweenanypairofverticesor,alternatively,
.Tofindthe
diameterofagraph,firstfindtheshortestpathbetweeneachpairofvertices.Thegreatestlength
amongallthesepathsisthediameterofthegraph.
ItsaO(V^3)solution.Doesthequestionsaidthatitwasageneralundirectedgraphorageneral
tree??????
Pleasementioninputsizeconstraintsandwhatwastheinputformat??
createallnonoverlappingintervalswithrangeandvaluefield
3)Givenarangeansdasignature4bitintegerlikethis[21,30,1101b].Here,therangeis
[21,30]andthefourbitintegeris13(1101b).Now,Givenarangeandasignature4bit
integerlikethis
[1,10,4]and[2,5,3]=[1,2,4],[2,5,4bitwiseor3],[5,10,3].Soon..!
(kindlyexplainwhatweneedtocodeandresult?,seemsquestionisnotcomplete)

1,6
5,9
8,11
forabovequestionyouhadto.Overlappingintervalscanbeobtainedfromtaking
bitwiseORoperationofoverlappingsequences.hopeitexplainsthisquestion
Iguessinitiallyyouhadtoaoofintervalsasinputthenthensequentiallyreadneweach
intervalinanewline
Whatisthesignificanceofsignatureifitwasjustaboutfindingnonoverlapping
intervals?Whyfindingoverlappedsignature?
forparticularintervalinputwillbeinthisformat
1610(Allvalueswillbeindecimal,firsttwofieldsindicateRangeand3rdfield
indicatessequenceorvalue)
Anyonehassolutionofthis??????(Solution:sortallendpointsofintervalandprint
consecutivepointsasnewnonoverlappingintervalswithcomputedsignificance)
IITDelhi,Madras:sameasabove
@IITK
3codingquestions
Interviewstreetplatform
2hours
Question1
GivenNfindthenumberoftriplets(a,b,c)ofintegerssuchthata^2+b^2+c^2=N
N<=50000000
Ans:use2loopsandrangetillsqrt(n)
Question2

Giventwocontainershavingnandmgallonsinitiallyfindtheminimumnumberof
stepsrequiredtocorrectlymeasurelgallons.
Onlyallowedoperations:
emptyacontainer
fillacontainercompletely
transfercontentsofoneintoothercompletelyortilltheother
containerfillsup.
outputminimumnumberofstepstogetlgallons.output1ifcan'tbedone.
Ans:usebfs
Question3
GivenN2dimensionalrectanglesintheformofoppositecornersfindthetotal
areacoveredbytherectangles.
Sidesofrectanglesareparalleltotheaxes.Morethan2rectanglescanoverlap
eachother.Theycanalsooverlapcompletely.

Companyinmobi@IITD:
Therewereabout20MCQs(30minutes)tobedoneafterthecodingsection.MCQswere
totallynonsense.Canbedonein10mins.
Forcodingsection60mins.
1.Inalinewherewordsareseparatedbyspaces,
,andcapitalizefirstletterofthereversedword.Otherlettersofthewordshouldbeinsmall.
Input:howareyou?Output:WohEra?uoy

2.Thesecondquestionreducedtofindingmaximumweightmatchinginabipartitegraph.Not
manypeoplewouldhavedonethis(maybenone).
3.Thereare2setsofcountries.Onesetwilldonateclothes(somethingofthissort)andanother

setwillacceptclothes.Acountrycanbeinonly1ofthesets.Theamountofclothesdonatedis
alsogiven.Theproblemistomaximizethisamountofclothes.Condition:OnetoOne
relationshipmustbetherebetweencountriesindifferentsets.TestCasesarelikethis:
{4,4,5,{1,3,7},{1,2,6},{2,1,5},{3,4,6},{4,2,4}}
{r1,r2,tc,{c1,c2,a},....}
r1=no.ofcountriesinset1
r2=no.ofcountriesinset2
tc=no.oftestcasesfollowedbythatno.oftestcases
{c1,c2,a}=c1countryisgivingaamountofclothestoc2country.Maximizethetotalamount
donated,followingtheconditionthatonecountrycandonatetoonlyonecountryandone
countrycanacceptfromonlyonecountry.
IITRCodingQuestions
1.SameasinIITD
2.0/1KnapsackProblem.Weightwasreplacedbytime.

CompanyGoldmanSachs@IITK
Solutionsplease
GoldmansachwrittenconductedatIITKanpuron6nov2013
Therewas2testoneismultiplechoiceobjectiveof75minandotherissubjectiveof90
min
Therearesomequestions
Test1:thereare25questionssomeofthemare

whichofthesearenotthedegree3sequenceofasimplegraph(solvebyHavell
Hakimi)
ifprobofoccurringheadispthenfindtheprobthathhhhcomesbeforethhh
ans(p^4B)from
https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&
ved=0CC4QFjAA&url=http%3A%2F%2Fwww.math.wisc.edu%2F~kiselev
%2FHW04sol.doc&ei=Hwx_UqHVEM2prAf2yIDABA&usg=AFQjCNHMo
cAZgNWwKInvWxM0b5itlAn7A&sig2=5uaxXgXvueGdhPzQPFKTA&bv
m=bv.56146854,d.bmk&cad=rja
asquareofunitlengthhascenterat0,0andedgeparalleltoaxisfindtheexpected
valuemax(X,Y)herex,yisapointinthesquare
asquareofunitlengthhascenterat0,0andedgeparalleltoaxisfindtheexpectedvalue
max(X,Y)herex,yisapointinthesquare
solution:XandYareindependentanddistributeduniformlyin[a,b],then
expectationofmax(X,Y)=E[max(X,Y)]=(2*b^2a*ba^2)/(3(ba))
inourproblma=1/2andb=1/2soaftercalculatingweget
E[max(X,Y)=1/6
ALTERNATESOLUTION
for{(x,y)|x<yand<x,y<}
expectedvalue=2*integral(integral(y.dx.dy))
for{(x,y)|x>yand<x,y<}
expectedvalue=2*integral(integralx.dx.dy)
puttingtheappropriatelimitsyoullget

onequestocheckconflictserializability
2radioactiveballsamong15ballsfindtheminno.oftestthatcanbedonetofind
theradioactiveballs,testcanbedoneongrouporindividualballs
ans7

Anshttp://math.stackexchange.com/questions/43696/howtofindtheballs
Sarahas6flowerpots,eachhavingauniqueflower.Potsarearrangedinarow.
Sararearrangethesequenceeachdaybutnottwopotsshouldbearranged
adjacenttoeachotherwhichwerealreadyadjacenttoeachotherinprevious
arrangements.Howmanydaysshecandothisorhowmanysucharrangementsis
possible?ans3B|
Anshttp://math.stackexchange.com/questions/560726/flowerpotpuzzle
Inoneislandthereare3colorsofchameleon,10blue,15greenand14red(i
thinkthesearethenumbers).whentwodifferentcolorschameleonmeettogether
,theyconvertintothethirdcolor.minimumno.ofmeetingrequiredtoconvertall
chameleonintosamecolor?ans14B|
http://gurmeet.net/puzzles/chameleons/
Ithinkitisnotpossiblebecause
anystepchangesthedifferencebetweenthenumberofchameleonsofanypairofcolors
by3or0.
sincenoneofthesedifferencesareinitiallyamultipleof3thereforenosequenceof
meetingscanleadtoaconditionwhereallchameleonshavethesamecolor.cebetween
thenumberofchameleonsofanypairofcolorsby3or0.
sincenoneofthesedifferencesareinitiallyamultipleof3thereforenosequenceof
meetingscanleadtoaconditionwhereallchameleonshavethesameco
Correctmeifimwrong.
whatswronginthisfirst10meetingbetweenblueandredwillgive25green(35green
andnot25)and4red.then2redand2greenwillmeettogive2blue.thenfinally2red
and2bluewillgive25green.14meetings
Themistakehereisthat2redand2greenwillgive4bluenot2blueandfirstiteration
willgive35greennot25.
solution:
reference:http://tierneylab.blogs.nytimes.com/2009/09/21/mondaypuzzledarwinsspiritres
toresparity/

1.Letussaythatthenumberofred,greenandblueeggsarer,bandg.Thesenumbers
canbeevenorodd.Sincetherearethreeofthemtwomusthavethesameparity,thatis,at
leastwehaveapairofoddnumbersorapairofevennumbers.Theaverageoftwooddor
twoevennumbersisawholenumber.
2.Denotethenumberofred,blueandgreenchameleonsr,bandgrespectively.The
criteriontoknowiftheagivensetofchameleonscanallchangetoonecoloristhe
following:agiventerrariumcannotbeunicoloredifr+b+gisamultipleof3,andr+2bis
notdivisibleby3.Statedasthisitseemsasymmetricalinr,gandb,butinfactisnot
(simplearithmetic).1414
Inthefollowingwedenotetheremainderofthedivisionby3likethisa=b(3)meansthat
theremainderofthedivisonofaby3isb.Forexample,5=2(3),meansthatthe
remainderofthedivisionof5by3is2.
Tounderstandwhythecriterionistrue,wehavetoconsiderseveralcases.Sincethe
remainderofthedivisionofanynumberby3canbe0,1or2,weanalyzeonecaseata
time.Onecrucialobservationis:theremainderofthedivisionofr+2bby3isnotchanged
aftermeetingsbetweenchameleons.Thisissoforthefollowingreason:denotethepossible
meetingby(rb),(rg)and(bg).Then:
after(rb):(r,b,g)>(r1,b1,g+2),thenr+2b>r1+2b2=r+2b3=r+2b(3)
after(rg):(r,b,g)>(r1,b+2,g1),thenr+2b>r1+2b+4=r+2b+3=r+2b(3)
after(bg):(r,b,g)>(r+2,b1,g1),thenr+2b>r+2+2b2=r+2b=r+2b(3)
Thereforetheremainderafterdivisionby3(whichwewillcallittrinityforobvious
reasons)isinvariant.
Now,letusseecasebycase.Eachcaseinr+2b=a(3),a=0,1,2,hastobesplitin
subcasesfortheremaindersofthesumr+b+g.Forexample,forthecaser+2b=1(3)we
havetostudyr+b+g=0,1,2(3).Thiscoversallpossibilities.
a)r+2b=0(3).
Inthiscaseunicoloringmayhappen.Toseehow,supposer<b.Notethatr+2b=0(3)
impliesbr=0(3).Thenwecandothefollowingsequenceofmeetings:afterrmeetings
betweenrandbchameleonswehave:(r,b,g)>(0,br,g+2r).Nowwedothefollowing
tango:ablueandagreenchameleonmeet,thenwehavetwomeetingsbetweenredand
bluechameleons,whichimpliesthat:(0,br,g+2r)>(2,br1,g+2r1)>(0,br3,g+2r+3).
Wecanrepeatntimesuntilbr3n=0,leaving(0,0,r+b+g)(recallthatbrisdivisibleby
3).So,unicoloringmayhappen.

b)r+2b=1(3)
b1)r+b+g=0(3)
Ifwemanagetounicolorthechameleons,thenwemusthave(r,b,g)>(n,0,0)or(0,n,0)or
(0,0,n),andeachcasehasr+2b=0(3),whichisacontradiction,sincethetrinityis
invariantandinitiallyitwas1.Sounicoloringcannothappen.
b2)r+b+g=1(3)
Sincer+2b=1(3)andr+b+g=1(3)wehaver+2bb+g=1(3)>gb=0(3).But
accordingtoa),unicoloringmayhappen.(thisisso,becausegb=0(3)impliesb+2g=0
(3),whichisthesameascasea)).
b3)r+b+g=2(3)
Inthiscaser+b+g+r+2b=1+2(3)>g+2r=0(3).Again,bycasea),unicoloringmay
happen.
c)r+2b=2(3)
c1)r+b+g=0(3)
Bythesameargumentinb1),unicoloringisnotpossible.
c2)r+b+g=1(3)
Thenr+2b+r+b+g=2+1(3)>g+2r=0(3),andbya)unicoloringmayhappen.
c3)r+b+g=2(3)
Thenr+2b+r+b+g=2+2(3)>g+2r=0(3),andbya)unicoloringmayhappen.
Conclusion:toavoidunicoloringweneedtohaver+b+g=0(3)andr+2b=1or2(3).
whatistheminimumno.ofcomparisonsrequiredtofindthesecondlargestno.in
anarrayofsizeN
(N+ceil(logN)2)(repeated???))
answer(http://stackoverflow.com/questions/3628718/findthe2ndlargestele
mentinanarraywithminimumofcomparisom)
test2:SubjectiveQuestions
1.Ifanetworkhasamaximumpacketdatasizeof128bytes,amaximumpacket
timetoliveof30secondsandan8bitsequencenumber,whatisthemaximumdatarate
perconnectionforthisnetwork?

2.designanalgotofindtheno.ofancestorsofagivennodewithi)O(m)memory,
ii)unlimitedmemorysize.
whatismhere?isitthenumberofnodes?
3.inanundirectedgraph2peopleplayagamethatifonechoseanyvertexthensecond
mustchooseitsadjacentvertexprovethat2willwinonlyifthereisperfectmatching
otherwise1winsalways.
Solution:3.1.18westbooksolutionmanualforgraphtheory

4.Proveordisprovethatthenoofedgesineulerianbipartitegrapharealwayseven.
solution:
http://answers.yahoo.com/question/index?qid=20130227220918AAoWQvp
Everyvertexhasevendegree.Wecancounttheedgesby
summingthedegreesoftheverticesinonepartitesetthiscountsevery
edgeexactlyonce.Sincethesummandsarealleven,thetotalisalsoeven.

5.inbinarynowecanfindthattheno.isevenoroddonlybycheckingits1stdigitisit
canbedonewithotherbaseandwhy?
solution:disproveasfor(10)inbase3=3.Herefirstdigit0isevenbutthenumberis
odd.

IITBombayandIITKGPandIITGuwahatiandIITDelhi
Objective
75mins

1.Whatistheminimumnumberofcomparisonsneededtofindthemaximumandtheminimum
numbersfromanarrayof100numbers?
ans:148
2.Findthetotalnumberofsolutionsofequationxyz=72.
ans:60
72=2^3*3^2
soans=5C3*4C3(Wrong)
Plscheckthisanswer
72=2^3*3^2
Nowif
x=2^x1.3^x2
y=2^y1.3^y2
z=2^z1.3^z2
xyz=2^{x1+y1+z1}.3^{x2+y2+z2}
Numberofpositiveintegralsolnsofx1+y1+z1=3is(3+31)C3=10
Numberofpositiveintegralsolnsofx2+y2+z2=2is(3+21)C2=6
Thereforetotalnumberofpositiveintegralsolnsis10*6=60.
Nowconsideringthenegativeintegralsolns.Finalanswerispositiveforthefollowingfoursign
combinationsofx,yandz{+++,+,+,+}
Overallnumberofintegralsolutionsis4*60=240.
3.Findthetotalnumberofsolutionsofequationxyz=510510wherex2y+y2z+z2x=xy2
+yz2+zx2
Answer:3

510510=2x3x5x7x11x13x17
x2y+y2z+z2x=xy2+yz2+zx2
soonfactorization(xy)(yz)(zx)=0,twooutofthreemustbeequal,noneofprimefactoris
havingpowertwo.Soonlysolutionwillbe(1,1,510510)andpermutations.

4.Aphotonstartsmovinginrandomdirectionfromthecentreofsquareofsize3.Letssayit
firstcolloidstotheglasswallAB.Whatistheexpecteddistancetravelledbyphotonbefore
hittingthewallABagain?
Answer68(not100%sure)
5.Ifadiceisthrowntillthesumofthenumberappearingontopfaceofdiceexceedsorequal
to100.Whatisthemostlikelysum?
Ans:100
6.Onequestionwasrelatedtogrammar
E>T+E|TE|T
T>F*T|F/T|F
F>a
Somethinglikethis.Andafewstatementsweregivenlike1.Thegrammarisambiguous2.The
grammarisleftassociative3.Rightassociative4.*and/getprecedenceover+and....blabla
blah.Anditwasaskedtofindwhichofthestatementsarecorrect.1,2and3,Only1and2,
Only2and3,...somethinglikethat.
7)Timecomplexityofinversionoperation
ans:O(NlonN)
8)Eggdroppuzzle100floors2eggs.minimumnumberoffloors
ans:14
9)Thevalueofrforwhichareaoftrianglewithtwotangentsandchordofcontactismaximum.
circle(x1)^2+(y2)^2=r^2.Tangentsaredrawnfrom(7,10)
ans:Sqrt(50)
10) lim

1a+2a+...+na
[(na+1)+(na+2)...+(na+n)]

a1

n (n+1)

1
= 60
.Findthevalueofa.

answer:a=17/2
dividenumeratoranddenominatorby1/n^(a+1)andcauchytheorem

11)A3x3matrixMisgivenwhereM[i,j]=1ifthereisadirectflightfromairportitoairportj0
otherwise.If1,0,1areeigenvaluesofthismatrixandM[2,3]=1,findthenumberofwaysin
whichairport2canbeconnectedtoaiport3in3hops.
12)Findval1(78).
intval1(intn)
{
if(n==0)return0
if(n==1)return1
return2+6*val2(n1)+val1(n2)
}
intval2(intn)
{
if(n==0)return0
if(n==1)return1
returnval2(n2)+4*n
}
ans:78^3
13.primalityofn^4+4^n,forn>=2.
answer:composite
n=even,composite(obvious)
n:odd
n^4+4^n=n^4+4^n+2.2^n.n^22^(n+1).n^2(thistermisperfectsquare)
use(a+b)^2c^2=(a+b+c)(a+bc)socomposite.
F
14.Determiningwhetherx^y+y^xis>=or<=1ingivenranges.
Solution:(1/e1/e2,1/e)
14.layer4firewallproperties.whichofthefollowingisfalse?
Ans.d)canblockhttps

15Anumberisstoredinitsbinaryforminalinkedlistinreverseorder.Forexample,if4or
(100)2isstoredas0>0>1.
Findthetimecomplexityofupdatingthevariablexstoredasabovedatastructureifitisupdated
tofloorof(x/8)intermsofn,wherenisthesizeofthelinkedlist.

Subjective
90mins,butthequestionsweresodifficultthatjuntafrommyhallstartedleavinginjust
5mins
1.a)TwosetsX={x1,x2,...xn}andY={y1,y2,...yn}suchthatx1<=x2<=x3<=.<=xnand
y1>=y2>=y3>=yn.LetZ={z1,z2,...,zn}beanypermutationofelementsofY.Thenprove
that
n

(xi yi) >= (xi zi)2

i=1

i=1

b)Asacorollary,forasequenceofpositivenumbers{ak},provethat
n

i=1

ak
k2

>=
i=1

1
k

2.BettingontheWorldSeries.Youareabrokeryourjobistoaccommodateyourclients
wisheswithoutplacinganyofyourpersonalcapitalatrisk.Yourclientwishestoplaceaneven
$1,000betontheoutcomeoftheWorldSeries,whichisabaseballcontestdecidedinfavorof
whicheveroftwoteamsrstwins4games.Thatis,theclientdepositshis$1,000withyouin
advanceoftheseries.Attheendoftheserieshemustreceivefromyoueither$2,000ifhisteam
wins,ornothingifhisteamloses.Nomarketexistsforbetsontheentireworldseries.However,
youcanplaceevenbets,inanyamount,oneachgameindividually.Whatisyourstrategyfor
placingbetsontheindividualgamesinordertoachievethecumulativeresultdemandedbyyour
client?
Ans:

3.ProveordisprovethatEuleriansimplegraphwithevenverticescontainsevennumberof
edges.
Answer:Nottrue(thereisacounterexample)

4.Twothreadst1andt2printcan2and4respectively.Writethecodefort1,t2usingstandard
lockingmechanismsuchthatfollowingserieswillbeprinted:422442244.
5.GCDofithtojthelementsofarray.TherewillbeO(n)numberofsuchqueries.
6.Npointsarerandomlyandindependentlymarkedonaunitcircle.Thecircleiscutatthe
points.Findtheexpectedlengthofthearccontainingthepoint(1,0).
(answer=2*Pi/N)(Idoubtthisanswerisincorrect)(Thisiscorrect:P)(noitsnot)
*ifyouassumethateachcutpoint,xi~U(0,2pi)oncircumference,theansweris4pi/n+1
*ifyouusesymmetry,sayingdoesntmatterwhichpointwechooseforthearc,its2pi/n
(incorrect,youneedmoreinsightofrandomvariables:P)
http://www.math.northwestern.edu/~mlerma/problem_solving/putnam/trainingprobability
*4pi/n+1iscorrect
Explanation:ThinkproblemasN+1randompoint(include1,0),becauseifyoufixonepoint
andtakeNrandompoint,isequivalenttotakeN+1randompoint(becausethereisnosenseof
absolutedistance).Nowarccontaining1,0willbeformedfromtwoadjacent
archavingmeanlength2pi/n+1(allthearcshavingequalmeanof2pi/n+1).
someanlength=2pi/n+1+2pi/n+1=4pi/n+1...

7.Inaclassof9students,eachstudentsendsagiftto3otherstudents.Isitpossiblethatallthe
studentsgetgiftbackfromeachstudenttowhomtheysentthegift.
Answer:No
http://cse.iitkgp.ac.in/~agupta/graph/SolH1.pdf
14Problem7
8.Thereare4resourcesofthesametypeandtherearethreeprocesseseachofwhichneed
atmosttworesourcestocomplete.Isthisadeadlocksituation?Why/Whynot?
ans:Deadlockfree
9.Thereare2threads.Oneprints4andanotherprints2.Giveasynchronizationmechanism
suchthatthefollowingisprinted.
42244224

10.Youaregivenanarrayofnumbers.Youhavetofindthegcdofarangeofnumbersinthe
array.Youwillbegiventhestartandendindexiandjbetweenwhichthegcdidtobefound.
Ans.Usesegmenttree
Similartohttp://www.geeksforgeeks.org/segmenttreeset1sumofgivenrange/

IITG:
Paper1:75mins.MCQ.onlyoneanswercorrect
Paper2:90mins.Subjective
Subjectivequestions.
1.SomeAcquireLockquestion.Dontremember.
2.9students.Eachstudentsendscardsto3otherstudents.Willeachstudentrecieve
cardsfromteh3studentshehasgivencards?why?
3.forEuleriangraphProveordisprove:thatifverticesareeventhentherewillbeeven
numberofedges.
4.Fourresources.3processes.Aprocesscantakeatmosttworesources.willtherebe
adeadlock?Why?
5.SomeMatrixquestion.Dontremember.someoneupdateifheremembersthe
question.
6.classa{
public:
~a()
{
printf("destroy")
}
}
vector<a*>v1=newvector<a*>
vector<a>*v2=newvector<a>

Whosedestructorfunctionwillbecalled?
(a)v1
(b)v2
(c)v1andv2.
(d)none
7.ThereisshortestpathbetweenAandB.LetitbeP.NowalinkisbrokenbetweenA
andBalongthisshortestpathP.letthepointofbreakingbeuandv.Now2options
exist:
(a)TofollowthepathPuptouandthenfollowanothershortestpathtov.andthen
continuetheshorterpathP.LetthetimerequiredforthisbeT1.
(b)TofindanewshortestpathbetweenAandBandnotusingpathP.Letthetime
requiredforthisbeT2.
Proveordisprove:T1<=3T2.
8.X1<=X2<=....Xn.Y1>=Y2>=.....Yn.LetZibeanypermutationofYi.
Provethatsummation_of(XiYi)^2>=summation_of(XiZi)^2
9.Printtehsequence:4,4,2,4,4,2,2,4....withthehelpofpropersynchronizationbetween
twothreadst1andt2.
10.voidprintarray(inta[],intsize)
{
if(size==0)
{
//dontprintanything
}
elseif(size==1)
{
//printoneelement
}

else
{
//printalltenelementsofarray
}
}
andcorrespondingassemblycodewasgiven.(Youcantusegreaterthanoperatorfor
comparisonbecausesuchanoperaorwasnotgiveninassemblycode.onlycompare
functionwasgiven.).Whatistehprobleminabovecodewithrespecttopipelinignwhen
itisgiventhatmostoftheinstrudctionhaveasizegreaterthanone.Writesuchacode
andwritethecorrespondingassemblycode.
8.ThereisavariableiwhichismadebyclassA.Makevariableinsuchawaythatitis
allocatedonheap.Makeafunctionforintilizationandtrasnferringofownership.when
thebariableisdeletedanexplicitfunctionshouldbeamdeforthat.
9.Asquare(madeofmirror)givenofsidelength:3cm.AphotonhitapointAby
startingfromthecenterofthesquare.whatisexpecteddistanceitcoversbeforehitting
atpointAagain.
(a)[2,4)
(b)(4,6],

10.Acircleofradiusoneisgiven.Nchordsaremadeincircle.findexpectedlengthof
chordofcirclecontainingpoint(1,0).
11.gcd(a,b,c)=gcd(a,gcd(b,c))
gcd(a)=a
Anarraycontainingnelementswithkbitofeachnumber.givenarrayis[a1,a2,...an].
q(=O(n))queriescomewhichspecifyiandjforwhichwehavetotakeoutgcdof
[ai,a(i+1),....aj].Makeanalgorithmtoanalyseruntimecomplexityandmemory
required.

CompanyAdobe:
http://www.iitplacementpapers.com/2012/09/blogpost.html
IITDelhi:(samepapergotrepeated)
IITRoorkee:Sameasabove
IITGuwahati:SameasIITDelhi.(timelimit2hrs)
IITMadras:SamePaper
IITKanpur:SamePaper
CompanyAmazon@IITG:
AmazoncodingquestionsatIITGuwahati

AmazonMCQs
1)Huffmancodefora,b,c,d,e
2)Initially5numbersstoredinmaxheap.levelordergiven.2newnumberinserted.findnew
levelorder.
3)IfP(a)=1,P(b)=1/2andP(c)=1/3anda,b,careindependent,findP(a/b)P(b/c)P(c/a).this
questionwasrepeated.
4)3menplayingagamewithcoin,whoevergetsfirstheadwins.findtheprobabilityofwinning
of3rdguy.
5)onecodewasthereontree.Itwasfindingtheheightoftree.
6)2questionsonrecursion.cvf
7)11playersteam.ageofcaptain=26andwicketkeeper=29given.avgageofteam=avgageof
teamwithoutcaptainandwicketkeeper+1,findtheavgageofteam
8)Arrangingtimecomplexities.
9)ininsertionsortifweusebinarysearchinsteadofinternalloop,whatwouldbethetime
complexity.PleaseWriteanswerifsomebodyknowaboutitComplexitywontimprove
becausestillnswapswillberequired.
Explanation:

Canwebringdownthecomplexityofinsertionsortto(NlogN)?Observethatthecardsinleft
handarealwayssorted.Can'tweusebinarysearchtoefficientlylocatefinalpositionofcurrent
insertingcardinO(logN)time?Perfectly,yes.But,weca*n'tbringdownthecomplexitytoO(N
logN).Becauseofthefact,evenafterfindingfinalpositionofcurrentinsertingcard,weneedto
movedownthosecardsthatarebiggerthanpresentcardtoonesteppasttheircurrentposition,
inordertomakeroomforpresentinsertingcard.
CompanyAmazon@IITK
Codingquestions
1)Checkifgiventwostringsareanagrams(ignorespacesanddontconsidercasesensitive
cases)
2)givenarrayofstsesensitivecases)
2)givenarrayofstringsofdatesindd/mm/yyyyform,writeaprogramtosortthem
ringsofdatesindd/mm/yyyyform,writeaprogramtosortthem
Onlythealgowasrequiredorcodewasalsoasked??Alsotheinputwasa2Dcharacter
arrayorwasitarrayofstrings(Itwasarrayofstrings.).
Thesearecodingquestionsandimplementationisrequired

CompanyAmazon@IITD:Marking+1/0.25
1.oneProbabity,onereasoning,onejava,onenetworkquestionsubnetmaskquestion.
2.TOCquestion(a+b*)and(a+b)*samelanguageorsubset.
1)findinaarraydifferentnumberofpairswithdifferencek.Arrayhasuniqueelements.
2)Secondquestionswassameas
http://www.geeksforgeeks.org/forums/topic/directicodinground2/
onlystorywaschanged,testcasesweresame.
IITMadras:,sameinIIfTRoorkee
ForMCQsgothroughlast5yearsGATEpapers
coding:
1.Listalltherepeatedcharacterslexicographicallyinastring(ifa&Aarethere,thatalso

countsasarepetition.
2.printthe90degreerotationofamatrix.
IITGuwahati:
Findtheminimumdistancebetween2numbers.
http://www.geeksforgeeks.org/findtheminimumdistancebetweentwonumbers/
Sumof3linkedlists.fortwolistucansee.
http://www.geeksforgeeks.org/addtwonumbersrepresentedbylinkedlists/
IITBombay
20MCQs:aptitude,datastructures,os,C
1Coinchangeproblem:Givenasumanddenominationsofcoins,findminimumnumberof
coinsrequiredtomakethesum.
2.Findanagrampairsinanarrayofstrings.Checkshouldbecaseinsensitive.
IITHyd:
1.Firstnonrepetitivecharacterinstring.
2.Nexthighernumberwithsamedigits.
http://stackoverflow.com/questions/2553522/interviewquestioncheckifonestringisarotation
ofotherstring
IITKgp
90mintest
20MCQs.Basics,coveredevrythngfromOS,DBMS,Netwoking,C,OOP&DS.
2codes:
1.Leftviewofbinarytree
http://www.geeksforgeeks.org/printleftviewbinarytree/
2.Givennpoints,find3nearestpointsfromeach
Input:

n(noofpoints)
thennlineseachcontainingid,x,y
Output:
nlineseachcontainingidof3nearestpoints
(Theoutputforthesampletestcasewaswrong,andsonooco
nesanswermatched.ComplainedaboutitLetsc:))
TheAmazonguysaidtheywouldcheckthesolutionmanually.
CodingroundAmazon:

Givenasquarematrixofsizencontainingpositiveintegers.Findthe
greatestsubmatrix(squareorotherwise)whichissortedbothrowwise
andcolumnwiseinincreasingorder.Amatrixissortedrowwise,ifall
theelementsinanyrowaresortedinincreasingorder.Andsimilarly,a
matrixissortedcolumnwise,ifalltheelementsinanycolumnare
sortedinincreasingorder.Greatestsubmatrixisdefinedasthe
submatrixcontainingthemaximumnumberofelements.
eg
25383
14684
36795
13642
26431

hasthegreatestsubmatrixas
1468
3679
CompanyCisco@IITB:
IITB09Nov
20Apti+30TechnicalMCQs(1hr)
QuestionsonDigitalLogic,1quesonZenerdiode
1Questiononnetworking,1Questiononnptransistor
Youhavefourballstworedandtwowhitewhichyouneedtokeepintotwoboxes.Outofthese
twoboxes,yourwifewillrandomlypick(oneboxandthen)oneball.Ifshepicksaredball,you
winaprize.Withbestpossiblestrategy,whatistheprobabilitywithwhichyouwillwinthe
prize?
ans5/6(Pleaseexplain,Iamgetting4/6)
Twostraightforwardquestionsonvenndiagram.
Acylinderofheight105cmhasacircumferenceof20cm.Astringmakesexactly7
completeturnsroundthecylinderwhileitstwoendstouchthecylinderstopandbottom.
Howlongisthestring?
Q.Whichofthetopologyhavetodowithmultipleconnectednodeswithasinglephysicalline?
a.starb.bus
@nitw::sameasabove+following...
resetlowerbitusing8085instructionAnsA
NI0F///itsawz[///fvtnif0
refer8085instruction
simpledigitalquestions(referKmaps)23questions

prefix/postfixSimple
in8085ALEsignalistothedemultiplexeaddressanddata.45questions
1simpledbmsquery
timedivisionmultiplexing/carriersignal/nyquestrate56questionsfromdisarea
Acomputersystemhas6tapedrives,withnprocesscompetingforthem.
Eachprocessmayneedthreet
.Themaximumvalueofnforwhichthesystemis
guaranteedtobedeadlockfreeis
A.1
B.2(ANS)
C.3
D.4
englishreading+simpleApt.

ISTHEREANEGATIVEMARKINGINTHEPAPER?>NO
postsomequestionswhichuremember.
plzsharesomequestionsortopicsfrommemory
andplzsharesomequestionofcandds.

CompanyCitrix@IITM:
1.Findanumberoccurringmorethann/2timesinagivensequenceinlineartimeand
constantspace.

2.Coinchangeproblem.Findminimumnumberofcoinsneededtoformasumofngiven
mrepeatablecoins.
IITB21stoct...
MCQ:
1.mostlyfromComputernetworks,OperatingSystemandOOPs(C++).
3programmingquestions
1.goldbach'sconjecture
2.stringrotation
http://stackoverflow.com/questions/2553522/in
terviewquestioncheckifonestringisarotationofotrstring
3.Givenpreandinordertraversalprintpostordertraversalofthebinarytree.Alsoreporterror
ifforagivencombination(preorder,inorder),atreecannotbeformed.

P1Goldbachsconjecturestatesthateveryevenintegergreaterthan2canbeexpressedasthe
sumoftwoprimes.
GivenanN(2<N<1,000,000&Niseven),findthetwoprimesPandQsuchthatP+Q=N
Input:EachtestcasesconsistsofoneevenintegerNsuchthat2<N<1,000,000
Output:PrintthevaluesP&QinsinglelinewithPandQseparatedbyasinglespace.ifthere
aremultiplevaluesforP&Q,thenchooseonewiththelowestvalueforP.Ifthereisnosuch
value,thenprint!!!withoutthequotesandyou'veprovedGoldbach/Eulerwrong.
ConstraintsEachtestinputcontainsTlinesofwhereeachlinehasanintegerNsuchthat

0<T<100
2<N<1,000,000
F


P2Onecanconstructauniquebinarytree,giventaskittooutputthepostordertraversalfor
thetree,givenpreorderandinordertraversalforthattree.
Input:
Eachinputtestcasewillconsistsof3lines.firstlinegivesthenumberofnodesinthetree.
secondlinegivesitspreordertraversalwitheachnodeseperatedbyawhitespace.thirdline
givesitsinordertraversalwitheachnodeseparatedbyawhitespace.
Output
Foreachinputtestcase,outputshouldcontainasinglelinewhichisthepostordertraversalfor
treewitheachnodeseparatedbyasinglewhitespace.Ifnobinarytreecanbeformedwithgiven
input,thenprint"NO"withoutthequotes.
P3GiventwostringsS1&S2,S2isrotatedversionofS1,ifS2canbegoS1withoutchatby
takingthelastncharactersofS1andattachingittobeginningofngingcharacterorder.(S1is
rotatedbyntogetS2.)Notethatcomparisonmustbecasesensitive.
Forexample:
TRIXCIisrotationofCITRIXby4characters(m=4)andIXCITRisrotationofCITRIXby2
characters(m=2).
Input:
EachlineconsistsoftwostringsS1andS2seperatedbyasinglespace.S1andS2consistonly
ofazAZ.Eachstringcanbeupto10,000characterslong.
Output:
ifS2isrotatedversionofS1.ThenoutputthevaluenbywhichS2isrotated,IfS2isnota
rotationofS1,thenoutput1.
Fmi
Constraints
EachinputtestcasewillcontainTlinesofinputwhereeachlinecontains2stringS1andS2
separatedbyspace.

1<T<100
1<S1,S2<10,000

SampleInput
CITRIXTRIXCI
BOMBAYBAYBOM
CompuTERPUTERcom
SampleOutput
4
3
1
Explanationsincewedocasesensitivecomparison,for3,S1andS2arenotrotations.

CompanyChronus@IITB:
Chronus@IITB:F
Givenasquarematrixwithblackandwhitecellsfindthesizeofthelargestsquare,theborderof
whichhasonlyblackcells.
Givenamillionworddictionary,whatisthesizeofthelargestrectanglethatcanbeformedsuch
thateachrowandeachcolumnoftherectangleisawordfromthedictionary.
BoththequestionsarepresentintheHardsectionofGaylesbook.
MCQsameasIITD

CompanyChronus@IITD:

Itwasapenandpaperwrittentest,time75min

34sectionsofmcqquestionswith6/7questionsineachsection(vemarkingisthere):
sectionswere:Algo(fromgate),Aptitude(oneabout5couplehandshakeproblem),SQL(one
aboutcascadingdelete),SQLinjectionandafewwebtechnologyrelatedquestion
Twocodingquestions:
1.onewasaboutpruningthelargestBSTsegmentexpandingfromtherootofgivenbinary
tree.
forexample:
f
1
/\
23
heretheanswerwouldbe
1
\
3
ITSNOTFINDINGLARGESTBSTSUBTREEINABINARYTREE
2.Twotimesweregiven
intnoOfClicks(char*clockTime,char*currentTime)
inHH:MMformat.
Therearetwobuttonstomatchtheclocktimewithcurrenttime.Onetoincreasehoursand
anothertoincreaseminutes.

HHcountisfrom0023andagaingoesto00ifitisincreasedfrom23.sameisforminutes
0059.
minutebuttonisworkingfinebuthourbuttonisfaulty.Whenyoupresshourbutton,itincreases
bothhourandminuteby1.
Youneedtocountandreturntheminimumnoofbuttonpresstomatchtheclocktimewith
currenttime.
Ex:
clocktime03:12
currtime04:15
noofclicks:3
whenhrbuttonispressed,04:13
minutebuttonpressedtwice,04:15
CompanyChronous@IITKGP
sameasDelhi
4sections:Algo/DS,quant,DBMS/SQL,programming
codingquestionswerediff
1:Youaregivenanarraynxnwithwhiteandblackpixels.Findthelargestsubsquarehaving
blackpixelsonitsboundaries.
2:Youaregivendictionarycontainingmillionwords.Formasquarematrixofletterssuchthat
eachrowandcolumnformsawordavailableindictionary.Writeanalgorithmtoobtainlargest
sizeofsuchmatrix.
Chronus@IITM
Coding:
Giventwowords,saysource,target.Alsogivenadictionaryofwords.Findminimumpossible
transformations(insert/delete/replace)ofsourcetotargetsuchthateachtransformationformsa
validwordindictionary.Printallthewordsduringtransformationfromsourcetotarget.
foreg.cattobed.
cat>bat>bet>bed.

PLEASEPOSTTHECODINGQUESTIONS@IITKGP
CompanyDirecti
IITDelhi:
Question1YouweregivenaBinaryTree(notnecessarilyaBinarySearchTree)toplaywith,
sayT.Thadsomespecialproperties
EachinternalnodeinThadexactly2children
EachinternalnodeinTwasrepresentedbyanuppercaseEnglishalphabet(AZ).
EachleafnodeinTwasrepresentedbyalowercaseEnglishalphabet(az)
YouweretoldrememberTaslongasyoucould.Hence,youmemorisedthestringformedby
traversingTinpostorder.Youusedsomethingsimilartothepseudocodebelow
toPostOrderString(node)
ifnodeisleaf
returnnode.value
else
T=""
T=T+toPostOrderString(node.left)
T=T+toPostOrderString(node.right)
T=T+node.value
returnT
Now,timehascometousethatstringagain.TheEyehascontactedyou.Yes,thesecret
organisationmentionedin"Nowyouseeme"(don'ttellanyonetheyarereal!!)
Yourememberthestringyoumemorisedbackthen.YoumustreconstructthebinarytreeT.
YouarealsogivenastringA.AllthecharactersofAareuppercaseEnglishalphabets.Letus
assumethatThasLleaves.Then,therewillbeexactlyLpathsfromtheroottotheleaves1
uniquepathtoeachleaf.
YouhavetotellTheEyethenumberofpathsoutofL,onwhich,Aexistsasasubsequence.

LookattheexplanationfortheSampleCase1forclarity.
YouhavetoimplementthemethodexplorePathsinthecode.explorePathsispassedthe
followingparameters,respectively
N,thenumberofnodesinT
S,thestringrepresentationofthepostordertraversalofT.Ofcourse,thelengthofSwillbe
equaltoN.
K,thelengthofthestringA
A,thestringyoumustfindinthepathsfromtherootofT,totheleavesinT.

IITRoorkee
1.GivenN,OwhereN=No.ofdigitsthatcanbedisplayedoncalculatorandO=No.of
multiplicationtobeperformed.
Thenumbersusedforthemultiplicationcanbefrom{2,3,...8,9}
2<=N<=8
2<=O<=30
writefunctionthatwillreturnthelargestnumthatcanbeobtainedafterOmultiplication.
Eg:N=2,O=3
thefunctionshouldreturn98,sincethemaximumno.generatedafter3multiplications2*7*7.
functionshouldreturn1forerrororinvalid.
2.GivenNsetofpointswithXandYcoordinates.
1000<X[i]<1000
1000<Y[i]<1000
Wehavetocalculatethelengthofthesquarethatbeconstructedoutofthesepointshaving
followingfeatures:
i.Thepointsshouldlieonthesquare,
ii.ThesidesshouldbeparalleltoXorYaxis.
iii.Thesquareshouldbeconstructedwithminimumpossiblelength.
Note:Itispossiblethatallthecornersnotbethepoints.
Foreg:

N=5
X[]={0,2,3,5,7}
Y[]={3,0,0,0,3}
functionshouldreturn7
incasethesquarecan'tbeformedoranyothererrorreturn1
Directi(IITGUWAHATI):
Twocodingquestions.Therewere11testcasestopassforeachquestion.
Q.1.RepeatedfromIITRoorkeeQ1.
Q.2.ThequestionwasverybigwithastoryofIPLteamselection.Thesummaryofthestoryis:
RoyalChallengerneedstoformateamofXplayers.EachoftheYfansofRoyalChallengercan
selectXplayersoftheirpreference.Theteammanagementhaveacriteriathat,atleastoneplayer
havetobeintheteamfromeachofthefanspreferences.So,findtheminimumnumberof
playersthatcansatisfyeachofthefanspreferences.Forerroneousconditionsreturn1.
Example:
numberOfPlayers=5
numberOfFans=3
fanspreferences=
{
10000
00100
00010
}
output=3
numberOfPlayers=4
numberOfFans=3
fanspreferences=
{
1000
0100

0101
}
output=2
Givenfunctionsignature:
intfindminimum(intnumberOfPlayers,intnumberOfFans,char**fanspreferences)
{
}
http://www.careercup.com/question?id=5734638857224192
Directi(IITKGP)
Q.1.RepeatedfromIITDelhiQ1.
Q2
Youaregivenastringthatconsistsofdigits.Thestringcontainsnotonlydigits,butmatched
roundbracketsaswell.
Examplesofsuchstringsare
"1234(56)"
"03(5(68(42)7))"
Notethattheroundbracketswillalwaysbematched,meaning
Thenumberofopeningandclosingbracketsisexactlyequal
Therewillbenoprefixthatcontainsmoreclosingbracke
"1234(56)"
"03(5(68(42)7))"
Notethattheroundbracketswillalwaysbematched,meaning
Thenumberofopeningandclosingbracketsisexactlyequal
Therewillbenoprefixthatcontainsmoreclosingbracketsthanopeningbrackets
Inthisstring,theopeningbracketisalwaysprecededbyadigit.
Now,yougothroughseveraliterationstogetridoftheroundbrackets.Theiteration
proceedsas
Ifthestringcontainsroundbrackets,pickupanymatchedpairofroundbracketsthatyou
find
Repeattheentireexpressionwithintheroundbrackets,exa
tsthanopeningbrackets

Inthisstring,theopeningbracketisalwaysprecededbyadigit.
Now,yougothroughseveraliterationstogetridoftheroundbrackets.Theiterationproceeds
as
Ifthestringcontainsroundbrackets,pickupanymatchedpairofroundbracketsthatyou
find
Repeattheentireexpressionwithintheroundbrackets,exactlyasmanytimesas,thedigit
thatimmediatelyprecedestheopeningbracketinthematchedpair
Notethatthestringaftereliminatingalltheroundbracketswillalwaysbethesamenomatterin
whatordertheroundbracketsarepickedforexpansion.
Forexample,considerthestring"42(30(1)4(21()))8"
Wefirstpickup"(30(1)4(21()))"andrepeattheexpressioninsidethebrackets2times.
Wedoit2times,becausethedigit2immediatelyprecedesthisbracketedexpressionin
thestring.
Thestringnowbecomes"430(1)4(21())30(1)4(21())8"
Wenowpick"(1)"andrepeatit0times,since0isthedigitthatimmediatelyprecedesit.
Repeating0timeseffectivelymeansthatweignoretheexpression.
Wecandothisforboththe"0(1)"substringsofthestrings.
Thestringnowbecomes"434(21())34(21())8"
Next,welookat"1()".Sincethebracketcontainsnothing,werepeattheemptystring
exactly1times.
Thisalsoeffectivelymeansthatweignoretheexpression.
Thestringnowbecomes"434(2)34(2)8"
Wecannowexpand"4(2)"to"2222"inboththeinstancesabovetogetthefinalstring
"432222322228".
Thisstringhasthelength12.
ImplementthemethodstringLengthinthegiventemplate.Theparameterstothemethodare
S,thestringthatmustbeexpanded.
Yourmethodmustreturnthelengthofthestringafterexpandingtheexpression.Donottryto
actuallyfindtheexpandedstringsincethisstringmightbetoobigtofitintomemory.Only
calculatethelengthandreturnit.Youmayassumethattheanswerisalwayslessthan109.Note
thatitispossiblethatthelengthoftheexpressionintheendis0.
Youcanassumethattheinputstringalwaysisalwaysvalidaccordingtothespecification
above.

SampleTestCase1
"42(30(1)4(21()))8"
Answerasdescribedaboveis12
SampleTestCase2
"1(1(1(30(9(12345678)))))"
Answeris1.Theexpandedstringis"3"
Constraints
1LengthofS1000
Theresultwillbelessthan109.
AnyalgorithmofcomplexityO(N2)orbettershouldpass.
Note:BecarefulwhenreturningastringinC.Declare"charstr[]"globallyandreturn"str".Local
chararraysaredeallocatedafteramethodlevel2callendsandwillproduceSegmentationFaults!
IITKanpur
Q1.Givenabinarytreewherevalueofeachinternalnodeis1andleafnodeis0.Everyinternal
nodehasexactlytwochildren.Nowgivenlevelordertraversalofthistreereturnpostorder
traversalofthesametree.
Q2.sameasIITKgpq2.(actuallyithinkitisIITRq2)butinplaceofrectangletheywanteda
square(justsomeadditionaltestcases)
Q3.Givenamatrixwith1and0asentries.Findtheperimeterofsquareswhichencloseallthe
1s.Allthe1sarecontiguousi.e.therearenoisolated1s.Forinstance
01000
11100
10000
heretheanswerwillbe12.
Q4.givenastringoftheformAB2C3andanintk.
ExpandthestringasABABC3thenABABCABABCABABC.Thenwhatisthekthelement.You
dntactuallyhavetoexpanditasitwillviolatedthememoryconstraints.Youjusthavetofindthe
kthelement.

IITB
1.Question1fromIITR
2.Givena2Darraycontainingdots(.)andhashes(#),findtheperimeterofareacoveredby
hashes.
Ex.Perimeterofareacoveredbyasinglehashis4.Thatofacoupleofadjacenthashes(##)is6.
Forthefollowinginput,theanswershouldbe15.
.##.
.#..
###.

CompanyEBay:
IITDelhi:
Shortlistingwasdonebeforewrittenexam.MostprobablythecriterionwasB.Techinstitute(
likeNITs).Thewrittentesthad2sectionswitheachhavingaseparatecutoff.1stsection:30
mins,7aptiquestions.Tough.2ndsection:30mins,10technicalquestions.Highlevelofobject
orientedconceptsandgoodlevelofjava(mostoftheppldidntknowthatmuchjava).
(pleaseupdatethequestionsalsothanks)
IITB:
Sameasabove:P
Howwasshortlistingdone??couldntgettheabovewrittenreason???
Shortlistingwasdonebasedontheundergradcollege.Andthereisnolisttheyadhereto.Its
uptotheirwhimsandfancies.Wasquitesilly.
IITM:Same
puzzlesimilartohttp://www.suhelbanerjee.com/2010/02/puzzlehighlyrecommendedone.html
IITKgp
sameasabove:)
FirstquestioninaptitudesectionwasLRtype.

2ndSection:
1.PredictoutputofaJavacode.SomethingrelatedtoassertfunctioninJava.
2.OnequestiononworkingsetmodelfromOS.
IITGuwahati
1.Aptitudetest:7questions30minutes
Q1.i.Hegavefivesetsofruleseachspecifyingtherelationfromwhichyouhavetoafilla
table.
ii.InthetablethecolumnswereFather,Mother,Child,LastName,Location.
iii.Thecolumn(father)isfilledforyou,Youhavetofilltheremainentriesusingtherelations
specifiedabove.
Ex:MarysMotherisntaSmith(LastName).Michellefoundherdaughteratacradle.Ali
andhiswifeLabirdidntfindtheirchildatrollercoasteretc.
Q2.Givenanamountfortwoobjectsandsomeprocedureofsellingtheobjectsyouhaveto
findtheirvalues.
Q3.Userstartsmovingfromapointinsomedirectionandfinallyyouhavetosayhisposition
withrespecttothefirstone.
Q4.Someencodingrule.likeCCQWiswrittenasDDRYwhatwillbethecodeofHIJK
Q5.Findthemissingnumberinatable.
Q6,Q7.GivenapiechartandyouhavetocalculatethepercentageofSwithrespecttoP..on
similarlines.
2.MCQsbasedonJava,C++,Networks,OS.:10questions30minutes.
Thenwehavehad3roundsofinterviewsfortheshortlistedstudents.
Theyjustseehowenthusiasticyouare.Whatyouexpectfromebay.Howyoucanhelp
ebay.
Whatdoyouwanttodoinebay.Yourinterestsandwhatyoudidthese4years.
AnAdvice:GothroughyourCVthoroughly.Youshouldbeabletodescribeeveryprojectyou
havementionedintheCVinaneatmanner.FinallyIwouldsaywhentheinterviewerasksAny
Questions?.Pleasedoaskfewquestionsrelatedtoebay.Thismakestheinterviewertofeel

thatthisguyisreallyinterestedinebay.
BestLuck!!
CompanyEpic:
IITDelhi:
Round1:1.5hrMCQtestwith3sections:epic
1.questionin102min
2.Mathsection14question(Simple)
3.Newprogramminglanguage(20questions)

CANANYONEPLEASEPOSTSOMEQUESTIONSFROMTHE3rdSECTION
^QuestionsrelatedtoMIISprogramminglanguage.Basicconceptsweredefinedinthe
questions,andthensimplethingswereasked.
3rdsectionsomefunctionisgivenwithitsdefinitionandsomeexpressionisgivenasargument
inthatfunctionthentheyaskwhatistheoutput.e.g.PIECEfunctionisgiven.
IITRoorkee
(MIISprogramminglanguage)
thesearebaseduponthedefinitionsgiven
a)NumericConstants(integers)
b)StringConstants
c)VariableswhichcantakebothbothNumericandStringConstantswithoutanytype
declaration
d)TheConcatenationoperatoronVariables
e)TheLogicalOperatorsmin(&),max(!),negation(),greaterthan(>),lessthan(<),equalto
(=)
f)Thefunctionofx=null
ifx=3inanexpressionx+xis(0)+3
ifx=0butinalogicalexpressionx=xgivesnull=0asfalse.

g)andsomemixoftheseoperatorstogether.likeconcatenateand()onthesevariablesand
askingwhatwillthosevaluesbecome
h)PIECEfunctionthatwillworklike$PC(abc,cde,fgh,2)willprintcdeas,isDELIMITER
and2ispostionholder.
similarextensionofthis
Round2:
Thiswasanonlineroundwhereyouhavetojustwritecode(properlydocumented).No
Compilationandcoderunning.2hrroundwithfourquestions.
Allcandidatesweregivendifferentquestions,whichcanbefoundoncareercup.combyfinding
resultsforEpicSystems.Justhavealookthroughthesequestions.
Edit(29thOct2013):
Didthecodingroundincludecompilationandtesting?
No(IITK)
secondround(Codingoneoftheset)
1.Defineanumbertobe'valid'ifallitsdigitareinincreasingorderstartingfromunit'splace.
Nowgivenanumberk,findallpossiblekdigit'valid'number.
2.Giventwowordsthatare
anagramofeachother.Swaponeword(onlyadjacentswapping
oflettersallowed)toreachtotheotherword.Example,http://www.wordsmith.org/anagram/
3.AnumberXissaidtobe'seed'ofnumberYifmultiplyingXbyitsdigitequatestoY.For
example,123isaseedof738coz123*1*2*3=738.Nowgivenanumberfindallits'seed'.
Solution???http://pastebin.com/MeqzY9Bp
1.Likeinnormalphoneifwepress2singletimeitisAandpressittwotimesitisBthreetimesit
isC,sameforothernumberkeys,*meansspace.Yoraregivenonebignumberlike
337444222*7777999777783367777wehavetoprintEPICSYSTEMS
2.Numbersatisfysomepropertywehavetofindwhethergivennumberfollowsthatproperty.
3.Input{1,7,6,3,5,8,3}

Requiredsum:16
Output:24
Sincehereindexstartsat1andwehavetoprintallcontiguousindexeswhoselocationvalues
addsupequaltogivensum.here24indexvaluesumis7+6+3=16.
Theysaidthatfollowinglinkwasveryhelpfulinparticular:t
http://placementpapers.org/category/placementpapers/epicsystems/

IITRoorkee
ThesewereEasybuttimeisimportant
1.Apersonhascheckingamountis50000$andcash500$.hebought2tvseach$1995of
whichhepaid1/15inchequeand1/10incash(Assumerestamountnotpaid).Thenwhatis
checkingamountleftandwhatiscashamountleftAns:49734,101
2.apple40centsbanana60centsgrapefruit80centsthenpear=?cents
Ans:40(2vowels)
3.16476481121pickoddoneout??ans:47
4.Whatistheamountoftimebefore5:00pmnow,ifbefore30minutesthetimeafter3:00pm
is4timesthatofbefore5:00pmans:66min(how???)
5.Amothcan(climb5inchesanddropbacks4incheseachtime)in1min.howmuchtimewill
ittaketoreachthetopof60.5inchbar.ans:58
(how???Theanswerassumesthatthemothtook1minuteforfallalso.Soitwillreach
56inchesin112minutes.Nextminuteitcango5butweneedonly4.5,whichwilltake
0.9m.So112.9m)
6.Sequence47134997fillthemissingelement.ans:25
7.?????

CompanyEpicIITKGPCodinground:
SomeMCQsrelatedtoAptitude:

1)Bankaccountquestion
2)Bankaccountquestion
3)yearlysalaryisgivenforaworker.ayear=52weeks
5workers5weeksalaryisgivensohowmuchsalaryremained?
4)Firstpersonat1(5office/min)andsecondpersonat106(10office/min)
andtheirrespectiveSpeedgivensowheretheywillmeet?36officenumber
5)1fora1$.customersaysIwant600thentakethese3$.
whatwillcustomerbuy?dontrememberanswerforthis
6)Agoatjumps3feetupandslips2feetinoneminute.
sohowmanyminshewilltaketoreachtogoupatapole
ofheight70.5?heredatachangesforsomepeople
7)2.5humanscut2.5treesin2.5daysthen,5humanwillcut
howmanytreesin10days?
20trees
(Timeisacrucialfactor.Youllgetmorethanenoughtime.Butfinishitasearlyas
possible)
1.Youaregivenastring.Gibberizeitseligiblecharactersundertheconstraints:
eligiblecharactersare:a,A,e,E,i,I,o,O,u,U
similarlyyouwillhaveonegibberizedcharactercorrespondstoeacheligiblecharacter.
youcanassumeonefunctionisgiventogibberizethesecharacters
atmost4eligiblecharactersfromtherearofthestringcanbegibberized
exemptfirst3eligiblecharactersofthestringfromanygibberization
2.GivenanNxNgridofalphabets.Youneedtosearchonewordinthatgrid.Wordcanbe
presentinanyrow(inreverseordertoo),anycolumn(inreverseordertoo)oranydiagonal
contiguouslySolution:http://pastebin.com/4ptu8VFi
3.Youneedtolabelfilesfromnumber1toN.Nwillbetakenfrominput.Onekeyisbroken.
Inputthebrokenkeytoo.Printlargestpossiblelabelausercanprint.e.g.N=1232andthe
brokenkeyis3thenlargestpossiblelabelwillbe1229.

4.PrintallpossiblevalidpasswordsofN(takeNasinput)lettersundertheconstraints:
lettersineachpasswordwillbeenglishalphabetsandinascendingorderonly.e.g.ably
isvalidpasswordof4digitbutableisnot.
letterscanbeinSMALLorCAPS.e.g.aBlyisalsovalid
5.Printallanagramsofastringsuchthatuppercaselettersandlettersotherthanalphabets
positionisfixed.http://pastebin.com/Emqdn0h9
IITB:
Almostsamequestionsasabove.
CompanyFlipkart:
@IITM
<whichtypeofMCQ..plzexplainifucanandhowmanyinterviewroundsarethere?>
20MCQ,2codingquestions
SomeMCQsare:
1.howmanybitsarerequiredtorepresentmacaddress
2.lastnonzerodigitin(551)!
3.minimumnumberofnodesinacompletebinarysearchtree
4.howmanywaysagarlandofatleast2roses,3lilies,1lotus..flst5flowerscanbeformed?
5.whichdatastructureisusedforefficientsequentialinsertionandsearching?
6.wehavetostorethelikesinfacebooksothatthepeoplewholikedthisareshowedinsorted
order(alphabetically).Whichdatastructurecanbeused?
7.digitalsignatureincryptographyis(a.symmetricb.asymmetricc.both(a&b)d.advanced)
,SomeRDBMSqsUnixcommands,Networkqs
Coding:
1.Findthebotttomviewofabinarytree.
SecondQuestionidontremember,plzupdateifanyoneremembered.
google
CompanyGoogle:
IITG,IITM,IITR,IITB,IITKGP,IITK
MCQ
20questionsfrompreviousyearpaperalreadyposted.

Link:https://www.dropbox.com/s/v3eyb56v8kbqu1z/Google.pdf(previouspaper)
Codingquestion:

Inalanguage,thereareonly4charactersh,i,r,e.andwehavetowriteafunctionwhich
takesastringasinputandreturnswhetherthegiveninputstringisavalidwordornot.
Similartothisone:o
http://community.topcoder.com/stat?c=problem_statement&pm=12778&rd=15705
Defineofvalidword:
1.Agivenwordisavalidwordifitisoftheformhninrnenwheren>=1.
2.Validwordshasconcate
nationpropertyi.e.ifw1andw2arevalidwordsw1w2isalsoa
validword.
IITD
codingques:
http://www.spoj.com/problems/BOOKS1/
insteadofgivingthecompletepartitionofsequence,onlyfindingtheminimumnoofpages
assignedwasasked.
CompanyInformatica:
IITD:Round1(40minutes):
35MCQsmostofthemfromGATE2011and2012.
TopicswereCN,OS,DBMS,OOP

Round2(75minutes)
Subjective:Wehavetogiveexplanationsofanswers,writesomecode(compilerwasnot
providedwriteonlycodeintext).Nottoomuchcodingwasrequiredbutthorough
understandingofcomputersciencewasproperlytested.

IITR:MCQsameasIITD.
secondround:
1.swaptwostring.
2.fork()question.
3.Redwhitetree(prunemaxrednode)withconstraintthatanodecanbewhiteifitsallchildrens
arewhite.
4.efficientfibbonacci(dynamicalgo)recursive.
5.acodeisgivenyouneedtofindouthowmanybytememoryallocatetostackandheap.
float*a
double**b
char*s=informatica
int*p=newint[10]

IITG:
Round1:35MCQin40mins..90%ofquestionsarefromGate2011andGate2012paper.
Cutoffforthisroundwashigh(closeto30).
Round2:15Subjectivequestionsin75mins.someofthequestionsweretocheckerrorsand
issueswiththegivencode.
ex:HowmanytimesHelloWorldisprintedinthebelowcode:
intmain()
{
for(inti=0i<7i++){
temp=fork()
if(temp>0)
break
printf(\nHelloWorld)
}
Somesimplefindoutput,errorsandissueswiththecodequestionsandwealsohavetogive
correctexplanationsfortheoutputquestionstogetcredit.
ItsdifficulttosolveallquestionsinRound2becausewehavetoexplainalotoneveryquestion.

Forround2:(Total15question)
Alltheabovementionedquestionswerethereplusfollowingquestionswerealsothere:
1Adirectedgraphwasgiven.Youhavetowritethecodetocopythegraphifitcontainscycle.
2.Youwillbegivenadescriptiveproblem,itwasverylong.Youhavetowritesolutionforthe
problem.
3.RemainingquestionswereCoutputquestions.
a.)char*string1=Something1
char*string2=Something2
youhavetowriteacodetoswapthestrings.(Meansafterswappingiftheyprintthestrings,
theresultshouldbetheswappedresult.)UsevoidswapString(char**str1,char**str2)
b.)Codewasgiventocopythestring.Youneedtotelltheerrorsinthecode.Andwritethe
correctcodewithexplanationsinthespaceprovided.
voidcopyString(char*dest,char*src)
{
inti
dest=(char*)malloc(strlen(src))
for(i=0i<strlen(src)i++)
dest=src
}
c.)Acodewasgiven.Afunctioncallsitselfrecursively.Ithasonestaticvariable.Theywere
checkingthestaticvariableandbasedonthevaluesofthevariabletheywereprintingsomething.
Soyouhavetotelltheoutputofthecodewithexplanation.
Basicallyyouhavetobeclearwithstaticvariableconcept.
d.)Codewasgiven.YouhavetotellhowmanytimesHelloworldwillbeprintedwith

explanation.
voidmain()
{
inti,temp
for(i=0i<7++i)
{
temp=fork()
if(temp>0)
break
printf(Helloworld.)
}
}
d.)Outputofthecode:
#include<stdio.h>
#include<stdlib.h>
#defineVALUE120
#defineVALUE244
intf(int*x,inti)
{
int*y
y=(int*)malloc(sizeof(int))
*y=*x+VALUE2
switch(i){
case0:
*x=*y+1
break
case1:

*x=*y
break
case2:
//something
break
}
return(*y)
}
intmain()
{
int*x,i,j
x=(int*)malloc(sizeof(int))
*x=VA
LUE1
i=f(x,0)
j=f(x,1)
printf(i=%dj=%dx=%d\n,i,y,*x)
return0
}

IITBombay:
Round1:35MCQsin45minutes.MostofthemwerefromGATE2011and2012andothers
fromolderGATEpapers.
Round2:Shortlistedstudentswereallowedtowriteasubjectiveexam.Oneoptionoutof
C/C++andJavahadtobechosenpriortostartofthetest.15questionsinC/C++withallthe
abovementionedquestionspresent.Wehadtofindoutputorlogicalerrorsinprograminmost
questionswithfewonwritingcode/pseudocode.Afewmorewhichwereaskedwere:

a)intmain()
{
staticinti=6
if(i)
{
main()
printf(%d,i+1)
}
}
b)
char*p=(char*)0
int*q=(int*)0
float*r=(float*)0
double*s=(double*)0
char*a=p+1
int*b=q+1
float*c=r+1
double*d=s+1
printf(%d%d%d%d,a,b,c,d)
c)
intmain()
{
int*diptr,*iptr,i
diptr=iptr=(int*)malloc(4*sizeof(int))
for(i=0i<4i++){
*iptr=i*10
iptr++
}
for(i=0i<4i++){
printf(%d,*diptr)

diptr+=sizeof(diptr)
}
}
d)Belowfunctiongives1869onsomecompilerswhilegivesillegalaccesserroronothers.
Reasonforthisbehaviour.
structA
{
int*p
A(intx){
p=(int*)malloc(sizeof(int))
*p=x
}
~A(){
free(p)
}
}
f()
{
Ayod=indep
}
Aindep(1947)
intmain()
{
f()
Adob(1869)
cout<<*indep.p
}
Ifyouchoosejava,thenyouhavetoattempt21questions.Outofwhich5questionsare
commontoc/c++section.IntheJavasectionmostofthequestionsareonJavabasics

(inheritence,polymorphism),Objectsequality,Initializationofarrays,Compilationerrors
identification,Runtimeerroridentification[compiletimeerrors|RuntimeExceptions],Inner
Classes,Threads.
Tip:Ifyouareverygoodatsmallsmallaspectsofjava,thenonlyoptforjavaotherwiseitwill
beverydifficulttopredicttheanswerandtowriteproperexplanationforthat.
microsoft::
1.48bitarchitecture,whatissizeofvirtualaddressspace?2^48bytes
2.1rabbitcouple.Couplewillstartproducingothercoupleonlywhentheirageisone
month.Initiallyinfirstmonthonecoupleisthere.howmanycoupleswillbeattheendofyear.
Hintfibonacciseries
3.Somecppcodes.andaskedoutput.(i.e.VirtualFunctions)
4.Ccodesandoutput.
5.Findbugsingivencode.
6.ComplexityofBFSifadjacencylistisgiven.
7.WhatisusedinDemandpaging
a)sequentialsearchb)binarysearch.Answerplease..
8.Ifpointertofunctionisdeclaredthehowtocallthatfunction.
CodingRound(60min)2questions
SameasIITbombay

CodingRound(60min)2questions
SameasIITbombay
1)checkistwowordsareanagrams.
2)printlast10linesofgiv

IITBombay
15MCQ(30min)

1.Inatreeeverynodehas2childrenor0children.ifthereare'n'nodeswith2childrenthen
howmanywith0children?ans:n+1
n+1.IITKanpur
15MCQ(30min)
SameasIITBombayquestions
somemore
1.48bitarchitecture,whatissizeofvirtualaddressspace?
2.1rabbitcouple.Couplewillstartproducingothercoupleonlywhentheirageisone
month.Initiallyinfirstmonthonecoupleisthere.howmanycoupleswillbeattheendofyear.
Hintfibonacciseries233
http://www.maths.surrey.ac.uk/hostedsites/R.Knott/Fibonacci/fibrab.html#rab
3.Somecppcodes.andaskedoutput.(i.e.VirtualFunctions)
4.Ccodesandoutput.
5.Findbugsingivencode.
6.ComplexityofBFSifadjacencylistisgiven.
7.WhatisusedinDemandpaging
a)sequentialsearchb)binarysearch.Answerplease..
8.Ifpointertofunctioni
2.Ifweaddaconstantweighttoeachedgeinagraphwilltheshortestpathbetweenanytwo
verticeschange?
Ans:(Mayormaynotchange)//*thiswillbeDepends,notNO,consideragraphwhoseone
pathfromAtoBhas4edgesof1andotherpathwith2and3,nowadd1toalledges..now
shortestpathbecomes2and3*
3.howmany'0'in100!?ans:24(100/5+20/5+)
4.Forrecursivefibonacci,whatisitscomplexity?ans:O(2pown)
5.i=2,printf("%d%d",++i,++i)ans:44/*sequencepointconceptinCcomesintopicture
here*/(dependsonthecompiler??)(itdependsonthecompiler,giving43here(where?))
6.intc[]={2,3,4,5,6},
int*p=c,int*q=c,
(1)for(i=1to5){printf("%d",*c)q++}
(2)for(i=1to5){printf("%d",*p)p++}

ans:2222223456(itshouldbecontinuousbecauseno\nisthere.)
Manyquestionswereofthekind:givetheoutputoffollowingC/C++code
7.x=4|3<<4x=?ans:52
8.x=2,y=4,z=10if(x<y<z){printf("abc")}else{printf("pqr")}?ans:abc
9.x=1mask=~(x<<51).Whatis
(1)mask&48
(2)mask&64
(3)mask&121
ans:3264105
10.Inanpagefaultsystemimplementation,whatisgoodwaytoaccesspages?and
(1)Linearsearch
(2)Arithmeticindirection
(3)Binarysearch.
(4)VectorOperation
CorrectAns:Option(4)and(1)..itwasamultiplecorrecttype
OtherwaythatarealsogoodareStackandpurecode
11.whichofthefollgivesmostefficientwaytoaccesselementssequentially?
(1)LL(2)DLL(3)vectors
Answer?Ithinkvector..isitcorrect?//yesitis//cachelocality
http://stackoverflow.com/questions/238008/relativeperformanceofstdvectorvsstdlistv
sstdslist
12.whatistheoutput?
classA{
public:voidfoo(){
printf("a")
}
}
classB:publicA{public:voidfoo(){printf("b")}}
classC:publicB{public:voidfoo(){printf("c")}}
voidfoo(B&b){
b.foo()
}
main(){

Cc
foo(c)
}
output:b
13.WhatisthedatastructurethathasO(logn)complexityonaveragingfortheoperations:
search,insert,delete.ANS:AVLTreecorrect?
14.Findtheoutput:
#include<stdio.h>
intfun(intnum){
while(num>0){
num=num*fun(num1)
}
returnnum
}
voidmain(){
x=fun(8)
printf(%d,x)
}
ans:0
15.Findtheoutput:intfun(intnum)
{if(num<3)
return3
returnnum+fun(num2)
}
main()
{
intx=fun(12)
inty=fun(13)
printf(%d%d,x,y)
}
4351

2codingquestions1hour
Codingquestions:
1.Givena2Dmatrix.Eachcellwasfilledwithaspecificcolordenotedbysinglecharactereg.
forblueB.Ifonepositionisclicked(x,y),colourpresentatthatpositionwouldbedeleted.If
thesamecolourispresentinneighbourhood(up/down/left/right)thenitwouldalsobedeleted.
Afterdeletionblankspaceswillbereplacedbythevaluepresentinthecellabovethat.Incase
novaluepresentabovethecellthenblankentrywillbereplacedby0.
Input
x:1y:1
BGB
BGG
BBB
Output
B00
B0B
BBB
WHATSHOULDBEOUTPUTOFTHIS?????
BGBB
BGGB
GGBB
BGGB
startfrom1,1

B00B
B0BB
G0BB
BGGB

2.Givenalinkedlistswapthealternativenodes(assumelisthaveevennumberofnodes.)
Input:11>12>13>14
Output:12>11>14>13
Retest:
1.Given2strings,checkiftheyareanagramsofeachother.
2.Deleteeverynthnodeinalinkedlist.
Whatdoesthisquestionmean,cansomeonepleasegiveanexample.
LettheLLbe,1>2>3>4>5andn=2,thenresultantlistwillbe:1>3>5

IITKgp
15MCQ.MostlywereaskingC/C++output(SomequestionswererepeatedfromIITBpaper
above).Someexamplesare:
unsignedinti=1<<10
for(i>=0i)printf(%d\n,i)
Ans:Infiniteloop
howtocallpointertoafunction:
ans:(*foo)(2)
askedtofindoutputfrom
a)C++basics=>severaltypesofconstructorforaclass(e.g.copyconstructor)
b)Virtualfunctionsandcallingthosefunctionsamongclasses
unsignedinta=1
unsignedintb=~1
intz=a*b
printf(%d,z)
Ans:2

rabbitfibonacciseries.plzgivereasoning.
Ans:233
intn=1000,c=5
do{n/=c}while(c)
printf(%d,n)
Ans:Arithmeticerror(divideby0)
classA{
public:A(){cout<<AC}
~A(){cout<<AD}
}
classB:publicA{
public:B(){cout<<BC}
~B(){cout<<BD}
}
main()
{B*b1=newB()Bb2}
Ans:ACBCACBCBDAD
intfun(intnum){
if(num<3)return3
returnnum+fun(num2)
}
main(){
printf(%d%d\n,fun(12),fun(13))
}
Ans:43,51
voidswap(int*a,int*b)
(a)callbyname(b)callbyvaluecallbyreference(d)callbypointer
Ans:CallByPointerbecozinC++wehavebothCBRandCBPandinC++forCBRwedont

use*inoperationwereferobjectonlyjustbytheirnameinCBR
intfun(intnum){
intval=num<<3
val+=num
returnval
}
main(){
printf(%d%d%d\n,fun(0),fun(1),fun(3))
}
Ans:0927
2codes:
1.pruneallthenodesfromaBSTwhicharenotintherangeminValueandmaxValue
2.printlast10linesofaverylargestring
IITRoorkee,Delhi:
SameasIITKGP

CompanyMicrosoftIITGuwahati:
Round1:
15MCQquestions.SomeofthemwererepeatedfromotherIITs
Q.1.
code1:
intMAX=1000
inta[MAX][MAX]
for(i=0i<MAXi++)
for(j=0j<MAXj++)
a[j]=i*j
code2:
intMAX=1000

inta[MAX][MAX]
for(i=0i<MAXi++)
for(j=0j<MAXj++)
a[i]=i*j
Whichiscorrect?
a.code1isfaster
b.code2isfaster
c.botharesameinRISCarchitecture
d.bothareaboutsame
Myanswas(b).Isitcorrect?

Q.2.Whatistheoutput:
unsignedintx=1
inty=~0
printf(%u,%d,x,y)
if(x==y)
printf(same)
else
printf(notsame)
a.compilationerror.
b.45.,1same
c.45.,1notsame
d.idontremember
Myanswas(b).
SecondRound:
2Codingquestions.WesufferedalotforInternetExplorerinthisround.Somecharacterswere
notunderstoodinthequestions.:(
Q.1.InaTicTacToigametwoplayersareplayingwhereplayer0isdenotedas0andplayer1
isdenotedas1.Givenalinkedlistofmovesmadebytheplayersdeterminewhoisthewinner
andinhowmanymovesherequiredforwinning.(Youhavetojustprint)RestofthepartI
didntunderstand.(Looksveryeasyquestion...butIEmadeittough):(

StructMove{
intp //Playernumber
intx //xandyposinthetictactoi
inty
structMove*next
}
Thesamplefunctiontowriteis:
voidplayGame(structMove*move,intN)
Q.2.
Givenanarrayifinapositionleta[i][j]=1thenprintallitsrowandcolumn1.Youshouldnot
consideraposition1afteryoumadeit1inyourpastcomputation.
sample(input):
(i)00100
(ii)10
00000
01
output:
(i)11111
(ii)11
00100
11
CompanyMorganStanley:

CompanyNVidia:
IITBombay
@IITB
<Whatwasthetimelimit?>:,1hr>
Approxhowmanyquestionsineachsection..?atleastonthewholehowmanyquestions?
<Howmanywereshortlisted..%??,NA>
<Wasthisapenpapertest?,Yes>
Howmanyquestionsineachsection?
Ifpossiblepleasepostfewmorequestions..
4sectionswithsectionalcutoff:

Section(1):.Coutputquestionspointerarithmetic,preincrement,postincrement,union
Q
x=25
if(!!x)
printf(%d,!x)
elseprintf(x)
.Q.enuma{A,B=2,C}
print(enum)
a.023
b.123
c.022
Q.
intx=0
while(x>10)
{
x
}
printf(x)
section(2).Datastructuresmostquestionswereveryeasy.Ionlyremember:
Q.
section(3).OS:
Q.A.4frames.HowmanypagepagereferencestringwasgivenfaultswithLRU.
Q.Whichofthefollowingdoesntneedsynchronizationwithmultiplethreads:
a.accessingaglobalvariable
b.accessingafile
c.modifyingavariableonstack
Q.WhatisMemorymappedI/Owith4options
section(4).Aptitude:difficultylevelwasmoderate`

CompanyOracle:
IITGuwahati:
Mostquestionsfrompreviousplacementquestionsandtherewerenewonesaswell
(Thosewhorememberquestionsindividuallycanaddthem)

IITBombay
Q1:Whenstackusedforparameterpassing,Whatistheprotection?
ans??0
Q2:O/Poffo
llowincode
main()
{
inti=10
i=!i>14
printf(%d,i)
}
Answerwas0
Q3:HwOOSachivessystembehaviour?

Q4:WhichisnotaOOADmethod?4optionsweregiven
datadriven
behaviordriven
usecasedriven
thelifecyclestages

thedegreeofformalism
Q5:worsecasetimetosearchinsortedLL?
ans:O(n)
Q6:Syntaxofpurevirtualfunctionforabstractclass(c++)?
ans:virtualvoidf()=0
Q7:Timecomplexitytoinsertinstack(implementedthroughLL)?
ans:O(1)
Q8:TimecomplexityofQuicksort?
ans:avgcase:O(nlogn)
worstcase:O(n^2)
Q9.ManyquestionsfromAVLtrees:givenBST,converttoAVLtree,preordering,
postordering
Q10.SomepeoplealsogotquestionsonRedBlacktrees.Insertionanddeletion
Q11.Questionsofdoublestackimplementedonanarraywhichstartsfromendsofarrays
AnyupdatesfromcompletedIITguys??
IITKGPandIITR:Mostlyfrompreviousyearpapersanditwasonline!!!<<ProvideLinks
CompanyQualcomm:
IIT(BHU)
Sameaspreviousyear:)
http://interviewfeedbacks.blogspot.in/2012/06/qualcommwrittentestandinterview.html
CompanySamsung:
!
IITM

WrittenTest:
20MCQquestions.
VerybasicofCanddatastructurelikepostordertraversalisleft,right,root.
IITD:
Iftwothreadsareincrementingavariable100timeseachwithoutsynchronization,whatwould
bethepossibleminandmaximumvalue
WrittenTest:20questions
ExtremelyhopelessMCQs.Verybasicones.
IITB:
20MCQsmostlybased
onC,alsohaddatastructures(tree,linkedlist,queue)andOS.
IITKgpsameasIITM/IITD
Couldyoupostquestionsorlinkfromwherequestionshadbeentaken??
1qonfree(ptr)
1onrealloc()
1codeondoublylinkedlist..choosethecorrectoutput
1onwhichisshortestpathalgo.....optionswerkrushkal,dijktras,andtwootherrandom
options
onequestiononsizeofptrs....

23questionspointertofunctions
oneoninordertraversal
CompanySymantec:
SymantecQuestionsomebody?

CompanyWalmart:
WalmartOnlineTestQuestionIITRoorkee
MCQ:
1.SqlQueryisgivenoverasmalldatabaseandweneedtofindoutnaturaljoin.
2.Ans:min:2,Max:200
Doubt:Ithinkminshouldbe=100,kindlyclarify?
seeherehttp://www.careercup.com/question?id=18315663.ANS:itshouldbe2only.suppose
firstthreadreads0andsecondthreadsdoes99increments.i.e99.nowfirstthreadwrites1
over99andsecondthreadnowread1,nowfirstthreadincrement100timesandthensecond
threadincrement1andwrites2.http://www.careercup.com/question?id=18315663
3.acprogramweneedtofindoutcomplexityofcode.
4.Indijkstraifusedaryheapthencomplexity?
5.supportandconfidenceforatransaction.supportandconfidenceforatransaction
6.giveMatrixM1:10x100M2:100x20M3:20x5M4:5x80findminimummultiplication
required:(gate2011question)
Ans:19000
7.ExpectationquestionR=liswhat?(gate2011question)
ANs:R>=0

8.givenf(x)=forx=0,1,..,5andxisthenumberofcakessoldbyabakerononeday.the

profitis$1.00/cakeandlossis$0.40/cakethenwhatisthenumberofcakesheshallbake?
note:cakescannotbestoredfornextday
9.linklisthavingaloopthansomeconstraintisgivenonitweneedtofindoutwhichistrue.(easy
one)
10.DontRemember.
11.Walmartsecondcodingquestion:
wehavestreamofpalindromeinincreasingorder
like:{1,2,3,4,5,6,7,8,9,11,22,33,....101,111,121,131...212,222,232,.....}andtheyareforminga
ndigitnumberlike:
number=12345678911223344.....101111121131..(allpalindromeinincreasingorder)
thenwehavetofindthekthdigitofthenumber.
12.Engineersat@WalmartLabshavedecidedtocallanyinteger(+ve,veor0)thatisdivisibleby
atleastoneofthesingledigitprimes(2,3,5,7)asWalprimes.Thus21,30,0,5,14etcare
Walprimes,while121,1,143etc.arenotWalprimes.
Now,considerandigitintegerd1d2d3..dn.Betweenany2consecutivedigitsyoucanplace
eithera(+)sign,a()signornothing.So,thereare3(n1)differentexpressionsthatcanbeformed
fromit.SomeoftheexpressionssoformedmayevaluatetoaWalprime.Forexample,consider
the6digitinteger123456:1+2345+6=236,whichisaWalprime,but123+456=71,
whichisnotaWalprime.
Yourtaskistowriteaprogramtofindtheno.ofexpressions(outofthepossible3^(n1)
expressions)thatevaluatetoaWalprime,foragiveninput.Notethatleadingzeroesarevalid.
Forexample,iftheinputis1202004,itcanbesplitas12+02004etc.Also,theinputitselfcan
containleadingzeroes.
Inputformat:(Readfromstdin)

Thefirstlineofinputcontainsasingleinteger'T'denotingtheno.oftestcases.
Eachofthefollowing'T'linescontainasinglestring's'(oflength'n')denotinganinputfor
whichyouneedtofindtheno.ofvalidexpressionsevaluatingtoaWalprime.
Outputformat:(Writetostdout)
Outputexactly'T'integers(oneperline),wheretheithlinedenotestheno.ofvalidexpressions
thatevaluatetoaWalprimefortheithinputstring.Sincetheoutputcanbelarge,printallthe
quantitiesmodulo1000000007.
Sampletestcase:
Input:
2
011
12345
Output:
6
64
Explanation:
Forthefirsttestcase,s="011".Thereare3^2=9validexpressionsthatcanbeformedfrom
thisstring,namely{0+11,011,0+1+1,0+11,01+1,011,01+1,011,011}.Outofthese9
expressions,onlythefollowing6ofthemevaluatetoaWalprime:{0+1+1,0+11,01+1,011,
01+1,011}.
Constraints:
Thereare3datasets.
Forthefirstdataset(5points)
1
Fortheseconddataset(10points)
1
Forthethirddataset(15points)

1
ComapnyWalmartOnlineTestQuestionIITKharagpur
10MCQ2coding
1.Cubetobepaintedwith6differentcolourson6faces..howmanypossiblecubes?ifon
rotating1configuration,wegetanother,thenthatisnottobeconsidered.
Ans:30?(5!/4)
2.(777^333333^777)whatisthedigitatonesplace(LSB)intheresultingno.
Ans:0?(7^333%10=33^777%10=3)
3.nelementsunsortedarray(theirvaluesareinrange0tok1)..minimumtimetocalculate
median
4.linkedlistwithlastnodepointingtooneofthepreviousnodes(cycle)..howmuchtime
requiredtodetectthecycleandmakethelastnodepointtoNULL(i.etoremovethecycle)
5.O(n)complexityisrequiredtocalculaten/4thsortedelementofanunsortedarray
quicksortpivotelementischosentobethat.whatisworsttimecomplexityofquicksort
6.Infinitelylargenoofelementsinabarytree.bisgiven.Uneedtosearchforanelementat
finitedepth.possiblemethodsBFS,DFS,iterativedeepeningdepth1stsearch(IDDFS).Dnsome
statementsgivenabouttheircomplexities.This1wasamultiplecorrectquestion.
7.narraystobesortedbymergesort.time?
******whataboutQ8,9,10?Pleaseupdatethem*******
11.Pilesofcoinsaregiven(ex.5piles:9,0,5,1,5)total20coins..Theminimumno.ofmoves
requiredsothatallpileshaveequalnoofcoins(4,4,4,4,4)(ansforthisis9moves)Rules:one
coincanbemovedtoonlyadjacentpiles..i.e.jthpilecoincanbemovedtoj1orj+1ifthey
exist

Level1:n<10
Level2:n<100/1000
Level3:n<10^6
12.TilesintheformofastringconsistingofonlyBorWex.BWW,BBBWWBB..etc
givenntiles..findthelargestpossiblechainoftilesbyjoiningthem..
Joiningrules:
ThelastletterofaTileshouldmatchthefirstletterofothertile.thentheycanbejoined
ex.BWandWWBarejoinedasBWWWBbutBWandBWcantbejoined
Anyconstraintsonn?Therewerethreelevelsoftestcases:
Level1:n<10
Level2:n<100or1000(dontremember)
Level3:n<10^5
IITBombay:
10MCQs
2CodingQuestions:
1.GiventwonumbersLandR,findthehighestoccurringdigitintheprimenumberspresent
betweenLandR(bothinclusive).Ifmultipledigitshavethesamehighestfrequencyprintthe
largestofthem.Iftherearenoprimeno.sbetweenLandR,print1.
Testcases:
L=1,R=30,Ans=1
L=13,R=13,Ans=3
L=4,R=4,Ans=1
2.GivenastringsofHsandTsdenotingheadsandtails,thereare2possiblemovesat
everypoint:
a.FlippingaTbyHorHbyTisavalidmove
b.Switchingeverycharacterofaprefixofs,i.e.,forany1<=m<=n,replaceallHswithTsand
allTswithHsins[1...m]isalsovalid.

Findthemin.no.ofmovestoconvertagivenstringintoallHs.
eg:HHTH=>flip3rdposition=>HHHH
HTTT=>(flipprefix)=>THHH=>HHHH

IITDelhi
onlinetestoninterviewstreet.
9singleoptionobjective,1multipleoptionobjective,2codingquestions.
Coding1.CodeChefLinktothisproblem.
Coding2.Inputisagainarrayofintegers(canbenegativealso),andtwonumbersLandR(L<=
R).OutputthenumberofsubsetswhohavesumbetweenLandRinclusive.
Again,pleasefillinsampletestshere.

CompanyWalmartIITM:
MCQ:10question
Coding:
1.Givenastring(withonlyazcharactersandoflengthN),findthenumberof
permutationsthatarepalindromes.
2.ThereaNpilesofcoins.ArrayAoflengthNcontainsthenumberofcoinsineachpile.
ArrayCoflengthNcontainsthecosttoadd/remove1cointothecorrespondingpile.Goalis
tomakethearrayAcontainequalvalues.Whatistheminimumcost?Infinitesupplyofcoinsis
allowed.
CompanyWooqer@IITR:

2codingquestions
1)Nexthighernumberwithsamenumberofsetbits
http://www.geeksforgeeks.org/nexthighernumberwithsamenumberofsetbits/
2)printbinarytreefromtoptodownandbottomupmanner(Verticalzigzag).
mcqs,basedonsimplemathematics,algos,os,networks.

CompanyYahoo:
CompanyCitiCorp:(NITW)
Thecodingistobedoneononlinecompilerwehavetorunalltestcasesalso.(Amcat)
generalaptiquestions(simpleonly)logicalreasoning
Programmingquestions(80min)2questionswereaskedtoeachcandidatesomeare:

youaregivenastringanduneedtoencryptit
foreg:0123401230120123456
hellodereandwelcome(givenstring)
hfnosdfth....(outputstring)
`
souneedtoaddtheindexofcharactertoitselfAlsoifthecharacteris'z'anduhvtoaddsay3
toitthenitshouldwraparoundandbe'c'Ifitis'Z'thenitshouldbe
'C'http://ideone.com/oVI49q

aadjacencymatrixisgivenandhvtofindwhetheritrepresentsGraphorTree?
soln:uhvtofindifcycleexists.

totraversethelinklistandfindifthereisacycleinthatlinklist

######################
totaldurationoftestwas2:30hrsifwhich80minisforcodingquesaptiquestionsareeasy
only..sou'llbeshortlistedonthebasisofcodingquesonly.
Citicorp@IITD:
(Isitpenpaperoronline?)onlinetest
(IsthereanycodingroundoronlyMCQs?)bothbutindifferentsectionsbutinsame
round
1stsectionCprogramming25ques35min.
2ndsectionQuants16ques16min.
3rdsectionLogicalAptitude15ques14min
4thsectionCprogramming2ques60min

differentquestionsetforeachstudent,programmingquestionsarealsodifferent.
Noswitchingisallowedbetweenthequestion.
CANANYONEADDPROGRAMMINGQUESTIONSOFCITICORPfromIITD??????

Company:OPERASOLUTIONS
IITMadras
1.Testiswrittenoneandnotanonlinetest.Itisconductedintwoparts.
2.Firstpartconsistsof20MCQs30min.f

3.Secondpartconsistsof6subjectivequestions45min.
PartI
Q1.Expectednumberoftrialstogeta4or6whenadiceisthrown.
Q2.Howmanytimesdoesaminutehandcrossoverthehourhandin24hours?
PartII
Q1.GivenasetX={1,2,3,4,5,6,7,8,9,10}.FindtwononemptydisjointsubsetsAandB
suchthat
i)AUB=X
ii)prod(A)isdivisiblebyprod(B).prod(S)istheproductofalltheelementsofsetS.
iii)Thequotientobtainedwhenprod(A)isdividedbyprod(B)isminimum.
Q2.Therewere3knobsforalockA,B,C.Eachcantake8positions.When2oftheknobsare
attheircorrectpositions,irrespectiveofthethird,thelockopens.Sothenumberofattemptsto
getitrightwillbe8**2=64.Canyoudobetterthanthat?
Q3.Thereare3colorsfora9digitlotteryticket.Foracolortobeofthesameclassalldigits
shouldbedifferentfromanotheroneinthatclass.122222222isgreen,all2isred.Predictthe
colourof123123123
Q4.ProvethatnC7floor(n/7)isdivisibleby7forn>7.
Q5.Amanhas2girlfriends.OnelivesinNandanotherinS.Hehastrainsleavinginboth
directionsin1hourinterval.HewakesaccordingtoaRNGandtakes5minutestoreachstation
andfromtheretakeswhichevertraincomesnext.InayearhehasvisitedtheSgfalittleover300
times.Howisthispossible?
Q6.http://vishnumenon.com/2013/08/13/tocatchapirate/
..someonepleaseelaboratequestioM/sStrandLifeSciences,Karnatakawillbevisitingour
campustoconducttheWrittenTestforBTech/DualDegree/MTechComputerScience&
Enggasscheduledbelow:

Date:29thNovember2013
Time:12.45p.m.(LatecomerswillnotbeallowedintheHall)
Venue:CRC
ns..idonotrememberexactly

IITKgp:
exactlysameasmadras.
Company:StrandLifeSciences@IITD
Duration:90minutes.
Paperpentest.
1.[5Marks]
Weareperformingsumofindividualdigitsforallnumberfrom1to10,00,000
Wehavetofindtheno.of1'sand2'sobtained=NO.sof1and2????
2.
OneCoutputquestion[5Marks]
3.
AgainCquestion,onecodeisgivenwehavetofindhowmanyaandbpairsarepossible.[5
Marks]
4.
OneReasoningquestion[5Marks]
5.
whichcoderunsfasterinonearrayisaccessedinrowmajororderandinotherarrayisaccessed
incolumnmajororder.[5Marks]
6.
Wehavetoderivetheclosedformulaeformaximumno.ofregionsformedfromnlines.[15
Marks]
7.
Checktwostringsareanagramsornot.[15Marks]
8.
Nqueenproblemcode.[20Marks]
9.
Nutboltproblemcode.[30Marks]

IITB
QwritepseudocodeforNqueenproblem
Qaftermidnight,atwhattime,bothhandsofclockoverlap.
QSimulationofunbaisedcoinfrombiased
Qpseudocodeforcountingleafnodes.
QA
BC
wDEF
GHIJ
WhereA,B,C,D,......arenumbers.AssumeanyDSandfindpathfromtopof
triangle(i.e.A)tobottomrowsuchthatyoucanonlymovetonumberinbottomrowto
rightorleftofcurrentnodeandsumismaximum.
QT(n)=T(n2)+T(n1)+c,findcomplexity.
Q4peoplehastocrossabridge,only2pplcancrossthebridgeinasinglepass.1
torch,
A=1min,B=3min,C=9min,D=11min.Findmintime.

CompanyTimesInternet:
Arbit

CompanyHTMedia@IITD:
PROBLEMSTATEMENT:
CalculatorLanguage(CL)supportsassignment,positiveandnegativeintegersandsimple
arithmetic.TheallowablecharactersinaCLstatementarethus:
A..Z:Variables
0..9:Digits

+:Additionoperator
:Subtractionoperator
*:multiplicationoperator
/:integerdivisionoperator
=:assignmentoperator
():brackets
:negativesign
Alloperatorshavethesameprecedenceandarerightassociative,thus1583=15(83)=
10.
Asonewouldexpect,bracketswillforcetheexpressionwithinthemtobeevaluatedfirst.
Bracketsmaybenestedarbitrarilydeeply.Anexpressionneverhastwooperatorsnexttoeach
other(evenifseparatedbyabracket),anassignmentoperatorisalwaysimmediatelypreceded
byavariableandtheleftmostoperatoronalineisalwaysanassignment.Forreadability,spaces
maybefreelyinsertedintoanexpression,exceptbetweenanegativesignandanumber.A
negativesignwillnotappearbeforeavariable.Allvariablesareinitialisedtozero(0)andretain
theirvaluesuntilchangedexplicitly.
Writeaprogramthatwillacceptandevaluateexpressionswritteninthislanguage.Each
expressionoccupiesonelineandcontainsatleastoneassignmentoperator,andmaybemore.
Input
Inputwillconsistofaseriesoflines,eachlinecontainingacorrectCLexpression.Nolinewill
be
longerthan100characters.Thefilewillbeterminatedbyalineconsistingofasingle#.
Output
Outputwillconsistofaseriesoflines,oneforeachlineoftheinput.Eachlinewillconsistofa
listofthefinalvaluesofallvariableswhosevaluechangesasaresultoftheevaluationofthat
expression.Ifmorethanonevariablechangesvalue,theyshouldbelistedinalphabeticalorder,
separatedbycommas.Ifavariablechangesvaluemorethanonceinanexpression,onlythe

finalvalueisoutput.Avariableissaidtochangevalueifitsvalueaftertheexpressionhasbeen
evaluatedisdifferentfromitsvaluebeforetheexpressionwasevaluated.Ifnovariableschange
value,thenprintthemessage`NoChange'.Followtheformatshownbelowexactly.
Sampleinput
A=B=4
C=(D=2)*_2
C=D=2*_2
F=CD
E=D*_10
Z=10/3
#
Sampleoutput
A=4,B=4
C=4,D=2
D=4
NoChange
E=40
Z=3

Onlyonecodewasgivenandapproximately100minutesaregiventosubmitthecodeand
allowedprogramminglanguagesareC,Java,Python,Ruby.Nocompilerisprovidedwehaveto
useourowncompiler.

CompanyDell@IITD
15apti+45tech(75min)singlechoicecorrectOnlinetestandallofushadthesame
sequenceofquestions:)and
nonegativemarking
1.preorderandinorderaregiven.find postorder
2.prefixtopostfixexpression

3.Shortestremainingtimefirstquestion
4.2questionsonpagereplacementstrategy(oneonLRUandotheronoptimal)
5.somequesonC
6.onequesonprobabilityusingbayestheorem
7.grapes74%wateranddrygrapes35%andofgrapesaregiven..howmanydrygrapescan
beprepared??
8.villagepopulation2500.65%arewomenofwhich24%areliterate.38%ofvillagersare
literate.find%ofmenwhoareilliterate?
9.pipesP1andP2fillstankin6minand9minrespectively.P3canemptyitin3min.Starting
withP1ndP2openedfor3min.ThenP3alsoopened.Howmuchtimetotakeittobeemptied?
10.somequesondbms.
11.networksalso.
12.unixzombieprocess,chmodrecursivelychangepermissions,hardlinkquestion
CompanyCisco@IITD:
20apti+30tech(60min)singlechoicecorrectPen&Papertestandallofushadthesame
sequenceofquestions:)andnonegativemarkingtechquesinvolvesbothhardwareand
software.
1.8queensproblemRecursive
2.Venndiagramques
3.Areaofacircleques
4.Onequesonsemaphore
5.DiffbetweenPAMandAM
6.JKflipflop
7.hammingcode
8.Booleanfunction
9.SUBBinstructionof8085
10.RSTof8085
CompanyNECCorporation@IITD
68Personalitybasedquestions.Eachinvolves4optionsandtotickmostandleastin
yourself.Notimelimit.Butaveragetimetocompleteitis20min.Sotrytofinishitwithin

20min.
CompanyBrowserStack@IITD:(itwasonlineorpaperpen?????)online
Section1.
Q1parseandprettifyhtml
givenasinglelineinput
input:<html><head><title>hello</title></head></html>
output:<html>
<head>
<title>hello</title>
</head>
</html>
Q2removecommentsfromc/c++
WAPtoremovecommentsfromc/c++file
(Canthecommentsbeofbothtypes,i.e.,//and/**/?)
Section2.
givenaarrayofnumber
.numberwithin1ton.Howuwouldsorttheminfollowingsituations.
a.alluniqueelements
b.1repeated,1missing
c2repeated2missing
d.4repeated4missing+
Q3
givenaNXNgridnumberofuniquepathsfromlefttoptobottomright
Ans.(2n)!/(n!n!)(isitcorrect?)//Yes:its2nChoosen
CompanySAPLabs@IITD:

Onlinetestonmettl.com

Time:90minutes
Nonegativemarking
5sections
1st:10Aptitudequestion
2nd:Analytical15question
3rd:Verbal1essayand9otherquestion(Otherasinwhat?Wordmeaningsandstuff?)
4th:CSfundamentals10question
5th:Coding1question
Differentquestionsetforeachstudents.
Wasthecodingquestiondifficult?moderate
WasitDPbasedforthemostofthepeople?No
OneQuestionwasalmostsametoProblem38inDynamicProgramming(Karumanchi)
WhatarethequestionsinSAP@IITD?
fico,iitkgp
(15aptitude,10programming,2generalthinking)

*howmanymultiplicationsneededtocomputex^100whenproductoftwonumberscanbesa
vedintoanothervariableatatime.
*howmanynumberswithin200canbelistedsuchthatnotwodistictnumbersarenotdivisable
byoneanother??
Answersplease???

You might also like