Capgemini Pseudo Codes
Capgemini Pseudo Codes
IONS
1
.Consi
derfol
lowi
nggiv
enc odeandpr edi
cti
tsou
tput
.ma i
n()
{
i
ntnum[ ] ={1 ,
4,8,1
2,16};i nt*a,*b;
i
nti;a=nu
m;b=nu m+2;i=*a+1;print
f("%d,%d,%d\n"
,i,*a
,*b);
}
ops
:A.2,
1,8 B.
4,1
,8 C.4,
4,8 D. 2,
4,8
Ans
:2,
1,8
2.Su
ppos
ef(A,
B)=A'
+B.Si
mpl
if
iede
xpr
ess
ionf
orf
unc
tionf
(f(x
+y,
y),
z)i
s:ops:A.x
'+z B.x
yz
C.x
y'+z D.Noneoft
heme
nti
onopt
ions
Ans
wer
:xy
'+z
3.T
henu
mbe
rofc
ont
roll
ine
sfora8-
to-
1mu
lti
ple
xeri
s:ops:A.3B.4C.2D.5
Ans
:3
4.Sta
ckisusef
ulf
orimple
menti
ng:
A.re
curs
ion B.dept
hfir
stsea
rch C.bot
h(A) &(B) D.br
ead
Ans
:Bot
h(A) &(B)
5.HUB i
sa_
__
__
__de
vic
eands
wit
chi
sa_
__
__
__
_de
vic
e.
ops:A.mu
lti
cas
t,u
nic
ast B.mu
lti
cas
t,br
oadc
astC.br
oadc
ast
,uni
cas
t D.br
oadc
ast
,mu
lti
cas
t
Ans
:C.br
oadc
ast
,uni
cas
t
6.whatisthebi
nar
yequ
iva
lentoft
henu
mbe
r368?
a.
111100000
b.
111010000
c.
101110000
d.
110110000
Ans
:c.
101
110000
7.wha twil
lbet heou
tpu
tofthefol
lwi
ngloop?
#include
<s t
dio.h>
main()
{
Whi l
e(Printf
(“%d”,pr i
ntf
(“az
”)))
Printf
(“by”);
}
a.
noneoft hese b.i
tgi
vessy
ntaxe
rror c
.itw
Ans
:c.
itwi
llpr
inta
zby
azby
azby
azby
…
8.whichofthefoll
owingc ombina
tionsofthev
ari
abl
esx
,y,
zma
kest
hev
ari
abl
e‘a
’ge
tthev
alu
e4I
nthe
fol
lowi
nge x
pres
sion?
A=(x >y)?((x >z)?x :
z): ( (y>z)?y :
z)
A.x=3;y=4;
z=2 B.x=6;y=5;z=3 C.
x=5
Ans
:A.
x=3;
y=4;
z=2
9.
pre
sstheent
erk eyina l
lofthecir
cumstanc
ese x
cept
…………
A.
toins
ertablankli
nei nt
oadoc u
me nt B.t
obe
ginanew paragr
aph
C.
whenthei
nser
t i
onpointrea
chestherightma r
gin D.
inre
s ponsetoce
rta
inwor
dcomma
nds
Ans
:c.
whe
nthei
nse
rti
onpoi
ntr
eac
hest
her
ightma
rgi
n
11.
Thefol
lowi
ngfra
gmentofcprogr
am wi
llpr
int
?
charc[ ] =“ DATA1
234”
char*P =C;
pri
ntf(“%S”P+P[3]- P[1]);
A.
DAT
A1234 B.
234 C.
1234 D.
A1234
Ans
:DAT
A1234
12.Whati
sEx t
ende
dASCI
Itabl
e
Ans:T
heExte
ndedASCI
IChar
a c
terSe
tal
soc
ons
ist
sof1
28de
cima
lnu
mbe
rsa
ndr
ange
sfr
om 1
28t
hrou
gh
255(u
singt
hef
ull8-
bit
soft
heby
te)
1
3.Moz
il
laF
ire
foxi
sa/a
nAns
:we
bbr
ows
er.
1
4.-
---
---
---
--he
lpsi
nca
ptu
ringt
heda
taa
nde
nte
ringi
ntoc
ompu
ters
yst
em.
Ans
:Inpu
tde
vic
es
15.Sec
retkeye
ncr
ypt
ionisal
sok
now a
s- -
---
---
--
Ans:Pri
vat
eKeyEncr
ypti
onorSy
mmetri
cKeyEncry
pti
on.
1
6.A c
las
sde
fine
dwi
thi
nanot
herc
las
sisna
meda
sa)i
nhe
rit
anc
eb)ne
ste
dc)c
ont
aine
rcl
ass
d)e
nca
psu
lat
ion
Ans
:b)ne
ste
d
1
8.wha tissi
mple
stwayofimpl
ement
ingagr
aphi
ncorc
++a
)as
soc
iat
ivel
is
tsb)bot
hadj
ace
ncyma
tri
xand
a
ssos
iat
iveli
std)adj
ace
ncymatr
ix c
)
Ans
:NotAv
ail
abl
e,i
fyous
olv
eitpl
eas
ecomme
ntt
hea
nswe
rbe
low i
ncomme
nts
ect
ions:
)tha
nks
1
9.Whic
hoft heOSImode
lisres
ponsi
blef
orc
ompre
ssi
onanddecompre
s s
ion
a)pres
ent
ati
onla
yer b)tr
anspor
tlaye
rc)appl
ic
ati
onla
yerd)ses
sionlaye
r
Ans
:pr
ese
ntat
ionl
aye
r
20.
Uponmixi
ngtwoi
nde
pendentone-ma
nyrela
tions
hips
___
__
__
__
_de
pende
ncya r
ise
s.
a)tr
ans
iti
ve b)mult
ival
ued c)f
unct
ional d)par
tia
l
Ans
:Mu
lti
val
ued
IfLislef
tnode,M ismi
ddl
enode
,R i
srightnodet
henanL-M-Rtrav
ers
alcanbet
erme
d
21
.as_
__
__
A) postorde
r b) i
norde
r c) preor
der d) t
hisi
sinval
idorde
r
Ans
:Inor
der
22.Whi
choft
heOSImode
lla
yeri
sal
sok
nowna
send-
to-
endl
aye
r
a
)se
ssi
onl
aye
r
b)
Ans
:Tr
ans
por
tLa
yer
23.Wh
OSImo
r
espons
ibl
eforbot
henc
rypt
iona
ndde
cry
pti
on
a
) Pr
ese
nta
tionl
aye
r b)Ne
twor
kla
yer c
)se
ssi
onl
aye
r
d) t
ra
Ans
:Pr
ese
nta
tionL
aye
r
24.I
dent
if
ythepointtha
ti snottruewit
hr e
spectt
os ta
c k
a) notpos
sibletoinse
rtorr e
movee l
ementsany
whe ree
xce
ptthetopofs
tac
k
b) Stacks
upportsLIF
O(lastinfi
rstout)fordelet
ingel
ement
s
c) Noneoft hes
e
d) s
tac
kisdy nami
cs etwher
ee l
ement
sa rere
mov edinrev
ers
eorderofi
nse
rti
on
Ans
:NotAv
ail
abl
e,i
fyous
olv
eitpl
eas
ecomme
ntt
hea
nswe
rbe
low i
ncomme
nts
ect
ions:
)tha
nks
25.Whenwordfl
agapos s
ibl
espe
ll
ingorgra
mma
re r
ror,ital
socha
ngesma
rkont hespe
ll
inga
ndgr
amma
r
st
atu
si c
onto__
__
__
__
__
__
_
a)r edx b) re
dcheckmark c) gr
eencheckmark d) gre
enx
Ans
:Re
dX
26. Ide
ntif
ythepoi
ntt ha
ti sNOTtruewithrespe
ctt oaqueu
e? A.de
let
ionfr
om theque
uehappe
nsonl
y
att hetailoft
hequ e
ue.B. Que
uesupport
sFIFO(Firs
tInFi
rstOut
)or
derofr e
movalofel
ement
s.
C.noneoft hes
e
D.Insert
ioninqueu
eha ppensonlya
tt hehea
doft hequ
eue
.
Ans
:NotAv
ail
abl
e,i
fyous
olv
eitpl
eas
ecomme
ntt
hea
nswe
rbe
low i
ncomme
nts
ect
ions:
)tha
nks
28.Per
iodi
cc ol
le
cti
onofa
llt
hefr
eememor
yspac
et oformconti
guou
sbl
ockoffre
es pacebyanope
rat
ing
sy
stemiscall
ed:
A.ga
rbagecol
lect
ion B.Dy
nami
cmemor
ya l
loc
ati
on C.col
li
son D.
conca
tena
tion
Ans
:NotAv
ail
abl
e,i
fyous
olv
eitpl
eas
ecomme
ntt
hea
nswe
rbe
low i
ncomme
nts
ect
ions:
)tha
nks
29.InCpr
ogr
ammi
ngarr
ayi
nde
xs t
art
sf rom:
A.0or1 B.0 C.
1 D.
noneofthe
s e
Ans
:0
30.jav
as ou
rcec
odeiscompi
le
dinto_
__
__
__
__
.
A.by
tecode B.wor
dc ode C.bi
tcode D.obj
ect
ivec
ode
Ans
:By
teCode
31.t
heoutputqu
ali
tyofapri
nterismea
sur
edby:
a.
Dotspr
inte
dperu ni
tti
me b.Dotpe
rcent
ime
trec.
Dotpe
rsq.
inc
h d.
Dotpe
rinc
h
Ans
:Dotpe
rsq.
inc
h
32.T
henu mberoff u
lla ndha lfa
dde
rsr
equ
ire
dtoa
dd1
6-bi
tnu
mbe
rsi
s:
a.
16ha l
f-adders
,0full
-a dders
b.
8ha l
f–a dders,8ful
l-a dde
rs
c.
4ha l
f-adders
,12full
-a dders
d.
1ha l
f-a
dde r
,15ful
l-adde rs
Ans
:d.
1ha
lf-
adde
r,1
5fu
ll
-adde
rs
33.T
os elec
tagr oupofwor ds
,___
__
___.
a. ri
ght-c
li
ckthef i
rstandlastc hara
ctersofthegrouptobes el
ect
ed
b. doubl
e-cl
ic
ka nywherewit
hint hegroupt obes e
lec
ted
c. cl
ic
kt hegroupbu t
tonont hef or
ma tt
ingtool
bar
d. dragthemou sepoint
erthrought hec ha
racte
rstobes e
lec
ted
Ans
:d.
dra
gthemou
sepoi
nte
rthr
ought
hec
har
act
erst
obes
ele
cte
d
34.wha
twi
llbetheou t
putoffol
lowi
ngCc ode
?
1. st
ruc
ta bc
2. {
3. intb=6;
4. cha rc;
5. }
6. st
ruc
ture ;
7. i
ntma in()
8. {
9. inti=siz
eof
(struc
tur
e);
10. pr i
ntf
(“%d”,i);
11. }
a
.4 b.
1 c
.2 d.
6
Ans
:6
Pa
rt2
Ques0.Thereisanew da
ta-
typewhi
chc
ant ak
easv a
lue
snatu
ralnu
mbersbet
wee
n
(andi nc
ludi
ng) 0 a
nd25.How manymini
mum bi
tsarere
qui
redtost
orethi
sdata
type
.
Op1 :4
Op2:5
Op3:1
Op4:3
Op5:
Corr
e c
tOp:2
Ques
1.A datat
ypeisst
oredasan6 bi
tsi
gne
dint
ege
r.Whi
choft
hef
oll
owi
ngc
annot
berepre
sent
edbythi
sdataty
pe?
Op1:- 1
2
Op2:0
Op3:32
Op4:1 8
Op5:
Cor
rectOp:3
Qu
es2
(Imageta
ken)
Corr
ectOp:4
Ques3.A languagehas28di f
fer
e ntlet
ter
sintotal
.Eac
hwor di
nt hel
angua
geisc ompos
edof
maxi
mu m 7let
ters
.Youwa nttoc rea
teada t
a-ty
pet os
toreawordofthisl
angua
ge .Youde
cidet
o
st
oret heworda sa narr
ayofletter
s.How manybi t
swil
lyouas
signtothedat
a-ty
pet obeablet
o
st
orea llki
ndsofwor dsofthelanguage.Op1:7
Op2:35
Op3:28
Op4:1 96
Op5:
Corr
e c
tOp:2
Qu
es4.A 1
0- bi
tuns
igne
dint
ege
rha
sthef
oll
owi
ngr
ange
:
Op1:0to1 000
Op2:0to1024
Op3:1to1
025
Op4:0to1023
Op5:
Cor
rec
tOp:4
Ques5.Ra j
niwantstoc re
ateada ta
-typeforthenumberofbooksinherbookcase
.
Hershel
fcana cc
ommoda t
eama xi
mum of75 book
s.Sheall
ocat
es7 bi
tst
othedatat
ype.L
ate
ra not
her
she
lfisaddedtohe rbook
-case.Shereal
iz
esthatsheca
ns t
il
luse
thesameda ta
-typeforstori
ngthenu mberofbooksinherbook-c
ase
.Wha tist
hema xi
mum possi
ble
c
apa
cit
yofhe
rne
wadde
dshe
lf? Op1
:52
Op2:1 27
Op3:53
Op4:75
Op5:
Cor
rec
tOp:1
Qu es
6.A ne wlangu
a gehas15pos si
blelet
ters
,8 dif
fer
entk i
ndsofpu nc
tuat
ionma rk
s
andabl ankc har
act
er .Rahu
lwa nt
st ocreatetwodat
at ypes
,f i
rstonewhichc oul
d
storethel et
tersofthelanguageandas econdonewhichc oul
ds t
oreanyc hara
c t
erin
thelangua ge
.T henumbe rofbit
sr e
quire
dt os t
oret
hesetwoda ta-t
ype
swi l
l
respect
ive
lybe :
Op1 :3a nd4
Op2:4a nd3
Op3:4a nd5
Op4:3a nd5
Op5:
CorrectOp:3
Ques
7.Pa rultakesasinputtwonu mber
s:aa ndb.aa ndbca ntakeintege
rv a
lue
sbetwe
en0 and
255.Shes toresa,ba ndca s1-byt
eda t
aty pe.Shewri
test
hef ol
lowingcodesta
teme
nttopr
ocess
aandba ndpu ttheresu
ltinc .c=a+2*b
Tohers u
rpris
ehe rprogram gi
vestherightou t
putwi
thsomeinputv a
luesofaa ndb,
whi
legivesane rr
oneousanswerforothers.Forwhichofthef
ollowi
ngi nput
swilli
t
gi
veawr onga nswer?
Op1:a=1 0 b=200
Op2:a=200 b=1 0
Op3:a=50 b=1 00
Op4:a=1 00 b=50
Op5: 1
3
Cor
rectOp:1
Ques8.Pr
a shantt
ake
sasinpu
t2 int
ege
rnu
mbers,aandb,whosev
alu
ec anbebe
twe
en0a nd
127.Hestoresthe
ma s7bitnumber
s.Hewri
testhef
oll
owi
ngc
odetoproc
esst
hes
enumbe
rsto
produc
eat hir
dnumberc
.c=a-b
I
nhow ma
nymini
mum bi
tss
hou
ldPr
asha
nts
tor
ec?
Op1:6bit
s
Op2:7bits
Op3:8bits
Op4:9bits
Op5:
Cor
rec
tOp:3
Ques
9.Ankit
ata
k e
sasinpu
t2i nt
ege
rnumbe
rs,aa ndb,whos
ev a
luecanbebet
wee
n0 and31.
Hestor
esthe
ma s5 bi
tnumbe
rs.Hewri
test
hefol
lowi
ngcodetoproc
essthe
senu
mberst
oprodu
ce
athi
rdnumberc.c=2*(a-b)
I
nhow ma
nymini
mum bi
tss
hou
ldAnk
itas
tor
ec?
Op1:6bit
s
Op2:7bits
Op3:8bits
Op4:9bits
Op5:
Cor
rec
tOp:2
Ques
10.A char
acte
ri nnew progra
mmi ngla
ngu
agei sst
oredin2 byte
s.A st
ringi
srepr
ese
ntedas
anarrayofchar
acte
rs.A wor disstor
e da
sas tr
ing.Eachby t
einthememoryhasanaddres
s.The
wor
d" Mahat
maGa ndhi"i
sst ore
di nthememorywithstar
tingaddr
ess456.Thele
tte
r'd'wil
lbeat
whi
chme moryaddre
ss? Op1 :468
Op2:480
Op3:478
Op4:467
Op5:
Cor
rectOp:3
Ques1
1.St ut
iisma ki
ngaqu est
ionnai
reofTrue
-fal
seques
tions
.Shewa nt
stodef
inea
dat
a-typewhi c
hs t
orestheres
pons eofthec
andida
teforthequ e
sti
on.Whati
sthe
most
-suite
dda tatypeforthi
spu rpos
e?
Op1 :intege
r
Op2:bool e
an
Op3:f l
oat
Op4:c haract
er
Op5:
Cor
rectOp:2
Ques1
2.Wha twi
llbet
heou
tpu
toft
hef
oll
owi
ngps
eudo-
codes
tat
eme
nts
:
int
egera=456,b,c ,d=10
b=a /d
c=a-b
pri
ntc
Op1 :410
Op2:41 0.4
Op3:411
.4
Op4:411
Op5:
Cor
rec
tOp:4
Ques1
3.Wha twil
lbet heout
putofthef
oll
owi
ngpseu
do-c
odes
tat
ements
:
int
egera=984,b,c ,d=1 0
pri
ntr e
ma i
nder
(a ,d) // r
emainde
rwhenaisdiv
idedbyda=a /d
pri
ntr e
ma i
nder
(a ,d) // r
emainde
rwhenaisdiv
idedbyd
Op1 :48
Op2:Er r
or
Op3:84
Op4:44
Op5:
Corre
ctOp:1
Ques.Whatwi
llbet
heou
tpu
tofthef
oll
owi
ngc
odes
tat
eme
nts
?
int
egera=50,b=25,c=0
pri
nt( a> 45OR b> 50 AND c> 10)
Op1 :1
Op2:0
Op3:- 1
Op4:1 0
Op5:
Corre
ctOp:1
Ques1
4.Whatwi
llbet
heou
tpu
toft
hef
oll
owi
ngc
odes
tat
eme
nts
?
int
egera=50,b=25,c=5
pri
nta*b/ c+c
Op1 :120
Op2:1 25
Op3:255
Op4:250
Op5:
Corre
ctOp:3
Ques1
5.Wha twi
llbet
heou
tpu
toft
hef
oll
owi
ngc
odes
tat
eme
nts
?
int
egera=1 0,b=35,c=5
pri
nta*b/ c-c
Op1 :65
Op2:60
Op3:Er ror
Op4:70
Op5:
Corre
ctOp:1
Qu
es1
6.i
nte
gera=1
0,b=35,c=5
Commentabouttheout
putoft het
wos t
ate
ment
s?
pri
nta*b+c/ d
pri
ntc/ d+a*b
Op1 :Di
ff
erdu etole
ft-
to-
rightpr
ece
dence
Op2:Di f
ferby1 0
Op3:Di f
ferby20
Op4:Sa me
Op5:
Corr
ectOp:4
Ques1
7.i ntege
ra=40,b=35,c=20,d=1 0
Comme ntabouttheout
putoft
hef
oll
owi
ngt
wos
tate
ment
s:
pri
nta*b/ c-d
pri
nta*b/ (c-d)
Op1 :Diffe
rby80
Op2:Sa me
Op3:Di f
ferby50
Op4:Di f
ferby1 60
Op5:
Corr
ectOp:1
Ques1
8.inte
gera=60,b=35,c=- 30
Whatwil
lbet heou
tpu
toft
hef
oll
owi
ngtwos
tat
eme
nts
:
pri
nt( a> 45OR b> 50 AND c> 1
0)
pri
nt( ( a> 45OR b> 50) AND c> 10)
Op1 :0a nd1
Op2:0a nd0
Op3:1a nd1
Op4:1a nd0
Op5:
Corr
ectOp:4
Qu es19.Whatwi
llbetheout
putofthef
oll
owingps
eudo-
codes
tat
eme
nts
:
integera=984,b=1 0
//f loati
sadata
- t
ypetost
orerea
lnumbers
.
floatc
c=a/ b
pr i
ntc
Op1 :984
Op2:98. 4
Op3:98
Op4:Er r
or
Op5:
Cor rectOp:3
Ques
20.Wha
twil
lbet
heou
tpu
toft
hef
oll
owi
ngps
eudo-
codes
tat
eme
nts
:
i
nte
gera=984
//fl
oatisadat
a-t
ypet
ost
orer
ati
ona
lnu
mbe
rs.
fl
oatb=10,c
c=a/ b
pri
ntc
Op1 :984
Op2:Er ror
Op3:98. 4
Op4:98
Op5:
Corr
ectOp:3
Qu
es21
.Smr
itiwa
ntst
oma
keapr
ogr
amt
opr
intt
hes
um ofs
qua
reoft
hef
ir
st5 whol
enu
mbe
rs
(0.
..4).Shewr
ite
sthef
oll
owi
ngpr
ogr
am:i
nte
geri=0 // s
tat
eme
nt1
int
egersu m =0// s tat
ement2
whil
e( i< 5 ) // s t
atement3
{
sum =i*i// s ta
teme nt4
i=i+1// s tat
eme nt5
}
pri
nts u
m // s t
atement6
Isherpr ogramc orre
c t?Ifnot,whi
chstat
eme
ntwi
lly
oumodi
fyt
ocor
rec
tit
?
Op1 :Noe rr
or ,thepr ogramiscor
rec
t.
Op2:St ate
me nt1
Op3:St ate
me nt4
Op4:s t
a t
ement6
Op5:
Corre
ctOp:3
Ques22.Sha s
hiwa ntstoma k
eapr ogr
amt oprintt
hesum ofthef
ir
st1
0 mu
lti
ple
sof5.
Shewr it
esthefoll
owingprogram,wher
es t
ate
ment5 ismis
sing:
int
egeri=0
int
egersum =0
whil
e( i<=50)
{
sum =s um +i
--MI SSINGST ATEMENT5- -
}
pri
nts um
Whichoft hefoll
owingwil
lyouu s
eforsta
tement5?
Op1 :i=5
Op2:i=5*i
Op3:i=i+1
Op4:i=i+5
Op5:
CorrectOp:4
Que s23.Sha ntanuwa ntst
oma keaprogramt
oprintt
hes u
m ofthef i
rst7mul
tipl
esof
6.Hewr it
est hefoll
owingprogram:i
ntege
ri=0 // stat
ement1int
e gersu
m // stat
ement2
while( i<=42) // s t
a t
ement3
{
sum =s um +i// s tat
ement4 i=i+6;
}
prints um // s t
ate
me nt6
Doe sthisprogr am haveane rr
or?Ifyes,whi
chonest
atementwi
llyoumodifyt
oc orre
ctthe
progr am?
Op1 :Statement1
Op2:St at
eme nt2
Op3:St at
eme nt3
Op4:St at
eme nt4
Op5:
Cor r
e c
tOp:2
Ques24.Sha r
miliwantstoma keaprogramtopri
ntthesum ofal
lperfe
ctc
ube
s,whe
ret
hev a
lue
ofthec ubesgof rom 0 to100.Shewr i
test
hefol
lowi
ngprogra
m:inte
geri=0,a// st
ate
me nt1
int
egersu m =0;
a=( i*i*i)
whil
e( i< 1 00 ) // s t
atement2
{
sum =s um +a// s tate
ment3
i=i+1
a=( i*i*i) // s tat
eme nt4
}
pri
nts um
Doest hi
spr ogram hav
ea ne rr
or?Ifyes
,whichonestat
ementwil
lyoumodi
fyto
corre
ctthepr ogram?
Op1 :Sta t
eme nt1
Op2:St atement2
Op3:St atement3
Op4:St atement4
Op5:Noe rror
CorrectOp:2
Ques25.Bhavyawa
ntstoma keapr ogr
amtopr
intt
hes
um ofal
lperf
ectsquar
es,
wheretheval
ueofthesquare
sgof r
om 0 t
o50.Shewr
ite
sthef
oll
owingprogram:
int
egeri=1 ,a// sta
tement1
int
egersum =0
whil
e( a< 50 ) // s ta
tement2
{
sum =s u
m +a// s t
atement3
i=i+1
a=( i*i);// s tat
ement4
}
pri
ntsum
Doesthi
sprogram ha
vea
ner
ror
?Ify
es,whi
chones
tat
eme
ntwi
lly
oumodi
fyt
o
cor
rectt
heprogram?
Op1 :St
atement1
Op2:St at
ement2
Op3:St at
ement3
Op4:St at
ement4
Op5:Noe rr
or
Corr
ectOp:1
Ques27.Shr avant
iwri
testhefol
lowi
ngprogr
am:
int
egeri=0,j
whil
e( i< 2 )
{j=0;
whil
e( j<=3*i)
{pr i
ntj
pri
ntbl ankspace
j=j+3}
pri
nte nd-of
-li
ne\tak
est hecu
rsortothenextl
ine
i=i+1
}
Whatwil
lbetheou
tpu
toft
hepr
ogr
am?
Op1:0
03
Op2:03
03 6
Op3:0
03 6
03 69
Op4:03 6
03 69
03 691 2
Op5:
Cor
rec
tOp:1
Ques
29.Cha
ruwr
ite
sthef
oll
owi
ngpr
ogr
am:
i
nte
geri=1,j,a
whi
le( i<=4)
{
j=1 ;
a=0;
whi
le( a<=5*i)
{
a=2^j ;
pri
nta
pri
ntblankspace
j=j+1
}
pri
ntend-of
-li
ne\ta
kesthecur
sortothene
xtl
ine
i=i+1
}
Whatwillbetheout
putoftheprogr
am?
Op1 :2
24
248
2481 6 Op2:2 4
248
248 1 6
2481 632 Op3:24
248
248
2481 6Op4:2
24
24
2481 6Op5:Cor r
ectOp:3
Ques
31.Sha l
iniwa ntstoprogr
amt opri
ntthela
rge
stnu
mbe
routoft
hre
einpu
tte
dnu
mbe
rs.She
wri
testhefol
lowingpr ogr
am:intnumbe
r1,number2,nu
mbe
r3,te
mp;
i
nputnumber1,nu mber2,number3;
i
f(nu mber
1>nu mbe r
2)
te
mp=nu mbe r
1
els
e
temp=nu mber
2
endi f
if(??) // St atement1
temp=nu mber
3
endi f
printtemp
Fil
lint he?? inSt a
tement1
Op1 :numbe
r3 > number2
Op2:nu mber3> t e
mp
Op3:nu mber3< t e
mp
Op4:nu mber3 > numbe
r 1
Op5:
Cor r
ectOp:2
Qu es33.Roha nwritesthefol
lowingprogr
am whichinput
sanu mberandpri
nts" Tr
ipl
edi
git
"ift
he
numbe ri scompos e
doft hr
eedigitsand"Nottri
pledigi
t"ifitisnot.intnu
mbe r;
if(nu mbe r>99)
print" Tri
pledigit
"
els
e
print" Nott r
ipledigi
t"
endi f
Roha nt ri
est hefol
lowinginput
s:25a nd566.Thepr ogram worksfi
ne.Hea sk
shi s
brotherRa vit otrythepr ogr
am.Whe nRavient
ersanu mber,t heprogr
am doesn'
t
wor kc orr
ectl
y .Wha tdidRa v
ie nter
?
Op1 :99
Op2:1 00
Op3:0
Op4:1 000
Op5:
Cor r
e c
tOp:4
Qu es
34.Abhi navwa ntstofindt helargestnumberinagi v
enlis
tof20nu mbers.Whichofthe
fol
lowingisane ffi
ci
enta pproacht odot hi
s?
Op1 :Us ebubblesortt osortthel is
tinde sc
endingorde
ra ndthenprintthefi
rstnumberofthe
seri
es.
Op2:Us es e
lect
ions orttos or
tt helis
ti ndesc
endingorderandthenprintthefi
rstnumberofthe
seri
es.
Op3:I mpl
eme ntonei te
rati
onofs el
ect
ionsortfordesce
ndingorderandpr i
ntthe
fir
stnu mbe
ri nthes eri
es.
Op4:Noneoft hese
Op5:
CorrectOp:3
Qu
es35.L
ava
nyawa
ntst
ofi
ndt
hes
mal
le
stnu
mbe
rou
tof26i
npu
tte
dnu
mbe
rs.How ma
ny
mi
nimu
mcompa
ris
onsheha
stoma
ke? Op1
:25
Op2:1 3
Op3:26
Op4:52
Op5:
Cor
rec
tOp:1
Ques
37.Vikram wa
ntstowr iteapr
ogram whi
chc
hec
kswhet
hertheinpu
tte
dnu mberisdiv
isi
bleby
anyoft
hef i
rst6natura
lnu mber
s(exc
ludi
ng1).Hewri
test
hefol
lowi
nge f
fi
ci
entcodeforit
.
i
ntnumber
,n=2,i s
divi
sibl
e=0
i
nputnu
mber
whi
le( n<=6) // St ate
me nt1
{
if( r e mai
nder(nu mber,n) ==0)
isdiv
isible=1
end
n=n+1// St at
eme nt2
}
if(i sdivi
si
bleequal
s1 )
pr i
nt" Itisdiv
isi
ble
"
else
pr i
nt" Itisnotdivi
sibl
e"
end
Vikramt ake
sthepr ogramtoHari
.Har
ite
ll
sVi
kra
mtha
tthou
ght
hec
odei
scor
rec
t,i
t
Ques
38.Ra j
ivwant
stoma keaprogr
am whi
chinpu
tst
wonu mbe
rs:aandb(a>b)
andcompu
testhenumbe
roft er
msbetwe
enaa ndb(incl
udi
ngaa ndb).Wha
twil
l
becodest
atementt
odot hi
s:
Op1:a-b
Op2:a-b+1
Op3:a+b
Op4:a-b-1
Op5:
Cor
rectOp:2
Ques39.Ihaveapr obl
emt osolv
ewhichtake
sa sinputanu mbern.Thepr
obl
em hasapr
ope
rty
t
hatgi v
enthesol
uti
onfor(n- 1),Icane a
sil
ysolv
et heproble
mf orn.Whi
chprogr
ammi
ng
t
echniquewi
llIus
et osolv
es u
chapr obl
em? Op1 :Iter
ati
on
Op2:Dec
isi
on-maki
ng
Op3:Obj
ectOr i
ent
edPr
ogr
ammi
ng
Op4:Rec
ursi
on
Op5:
Cor
rec
tOp:4
Qu
es40.Wha
tist
heou
tpu
toft
hef
oll
owi
ngc
odes
tat
eme
nts
?Thec
ompi
le
rsa
vest
hef
ir
sti
nte
gera
t
t
heme
mor
yloc
ati
on4062.I
nte
geri
soneby
tel
ong.i
nte
gera
poi
nterb
a=20
b=&a
pri
nt*b
Op1 :4062
Op2:4063
Op3:20
Op4:1 0
Op5:
Corr
ectOp:3
Ques
41.Whatistheou tpu
toft hefol
lowi
ngcodestat
eme
nts?Thec ompi
le
rs ave
sthef
irs
ti nt
ege
rat
t
heme mor
ylocat
ion41 65a ndther e
statconse
cut
ivememoryspa
ce si
nor de
rofdecl
ara
tion.
I
nte
gerisonebytelong.intege
ra ,b
poi
nterc
,d
a=30
c=&a
b=*c
a=a+1 0
pri
ntb
Op1 :30
Op2:41 65
Op3:40
Op4:41 66
Op5:
Corr
ectOp:1
Ques
42.Whatist heou t
putofthef
oll
owingc odest
ate
ment
s?Thecompi
le
rsave
sthefir
stint
ege
rat
t
heme mor
yloca
tion41 65a ndther
estatc onsec
uti
vememorys
pac
esinorde
rofdecl
arat
ion.
I
nte
gerisonebytelong.intege
rapoint
erc ,d
a=30
c=&a
d=c
a=a+1 0
pri
nt*c
Op1 :30
Op2:41 65
Op3:40
Op4:41 66
Op5:
Corr
ectOp:3
Qu
es43.Whatisspacecomplex
ityofapr ogr
am?
Op1:Amountofhar
d- di
skspacerequi
redtos t
oret
heprogr
am
Op2:Amountofhard-dis
ks pa
cer e
quire
dt ocompi
let
heprogr
am
Op3:Amountofmemor yr e
qui
redbyt heprogramtorun
Op4:Amou
ntofme
mor
yre
qui
redf
ort
hepr
ogr
amt
ocompi
le
Op5:
Cor
rec
tOp:3
Qu es
44.T heme morys paceneededbya nalgor
ithm ha
saf ixe
dpa rtinde
pendentof
thepr obl
e minstancesolv
eda ndav a
ria
blepartwhichchangesaccor
dingtot he
problemi nst
ances ol
ved.Inge ner
al,whichofthesetwoiso fpri
mec oncer
nt oa n
algori
thm de s
igner?
Op1 :F ix
e dpa r
t
Op2:Va ria
blePa rt
Op3:Pr oductoff i
xedparta ndvari
ablepart
Op4:Noneoft hese
Op5:
CorrectOp:2
Ques45.Whi lecal
cul
ati
ngt imec ompl
exi
tyofa nal
gori
thm,thedesi
gne
rconc
ernshi
mse
lf/her
sel
f
pri
ma ri
lywiththeruntimea ndnotthec ompi
leti
me.Why? Op1 :Runti
meisalwa
ysmor etha
n
compil
et i
me .
Op2:Compi leti
meisa lwaysmor ethanr unti
me.
Op3:Compi leti
meisaf uncti
onofr u
nt ime.
Op4:A pr ogra
m needst obec ompil
edonc ebutcanberunsev
eralti
mes
.
Op5:
Corr
e c
tOp:4
Que
s47.Vr i
ndawr it
esa neff
ici
entpr ogr
amtosu
mt wos
quar
edi
agonalmatr
ice
s
(matr
ice
swi thel
eme ntsonl
yondi a
gonal).T
hesiz
eofeachmat
rixisnXn.Wha ti
sthe
t
imecomplexi
tyofVr inda
'salgori
thm?
Op1:&theta(n^2)
Op2:&t he
ta(n)
Op3:&t he
ta(n*log(n))
Op4:Noneoft
hes
e
Op5:
Cor
rec
tOp:2
Ques
48.T ara
ngwr i
tesa
nef
fic
ientpr
ogr
amt oaddtwouppertr
iangu
lar10X1
0 matr
ice
s(e
leme
nts
ondiagona
lreta
ine
d).How manytot
aladdi
ti
onswi
llhi
sprogr
am ma ke
? Op1 :1
00
Op2:55
Op3:25
Op4:1 0
Op5:
Cor
rectOp:2
Qu e
s53.Weha vet wo1 00X3(r owsXc olumn) ma tricescont a
ini
ngmi d- t
erme xam ma rk
sa nde nd-t
erm
exam ma rksof1 00 s tude nts.Ea chr ow r e fe
rst oapa rti
c u
lars t
udent,whi l
ec olu
mnsr efe
rt oma rksin
Engli
sh,Soc ialSc ie
nc esa ndMa ths.T hee nd-term
andmi d-t
erm ma rksofe achs t
u denti ne achs ubjectha vet obea dde dt oge thistotalscoreine ach
subject
,t obepu ti nat hirdma tri
x(1 00X3).Pa ri
nidhiwr it
esac ode(CodeA),whe r
et heouter
l
oopi t
eratesov e
rt her ows ,whi let hei nnerl oopi terate
sov e
rt hec olumns .Sha shiwrite
sac ode
(CodeB),whe r et heou t
erl oopi tera tesov ert hec olumns ,whi l
et hei nne rloopiterat
esov errows.
Whi c
hoft hef ol
lowi ngi st r
u ewi thr e ga rdtot he i
rc odei gnoringa nyc a chingorme morys tor
age
eff
ects? Op1 :CodeA i sf ast
e rt hanCodeB
Op2:CodeB i sf a st
ert hanCodeA
Op3:CodeA a ndCodeB wi llr uni nt hes amea mou ntoft ime
Op4:T hec ompa risonbe t
we e
nt hes pe e doft hec odesc annotbema de.
Op5:
CorrectOp:2
Qu es
54.A c odet akest hef ol
lowi ngc odes t
eps(e quivalentl
yt i
meu nit
)t oe xecute
:5*n3+6*n2+
1.Whi choft hef oll
owi ngi snott ruea bou tthet imec ompl exi
tyoft hepr ogr am?
Op1 :Itha sat imec ompl exit
yofO(n3
)
Op2:I thasat imec ompl e
x i
tyofO(n4
)
Op3:I thasat imec ompl e
x i
tyofO(n2
)
Op4:I thasat imec ompl e
x i
tyof&t het a(n3
)
Op5:
CorrectOp:3
Que
s55.Weha vetwopr
ogra
ms.Wek now t
hatt
hef
ir
stha
sat
imec
ompl
exi
tyO(n2),
whi
let
hesecondhasacompl
exi
ty&ome ga
(n2
).Forsu
ffi
cie
ntl
ylar
gen,whic
hoft he
fol
lowi
ngc annotbet rue
?
Op1 :Bothc ode shavesamecomplex
ity
Op2:T hefirstcodehashigherti
mec omplex
itythanthese
cond
Op3:T hes e
c ondcodehaslowerti
mec ompl
exi
tythanthefi
rstcode
.
Op4:Bot hc odesarethesame.
Op5:
Correc
tOp:2
Ques56.T heti
mec ompl
exi
tyofcodeA is&theta(n),whil
eforCodeB iti
s&t he
ta(l
og(n)).
Whichoft hefol
lowi
ngistruef
ors u
ffi
cie
ntl
ylargen? Op1:Bothcodehavethesametime
complex
ity
Op2:CodeA ha shi
ghe
rtimecomplexi
ty
Op3:CodeB ha shi
ghe
rt i
mecomplexi
ty
Op4:Noc ompari
soncanbema debetweenthetimecompl
exi
tyofthet
woc ode
s.
Op5:
Corr
e c
tOp:2
Ques57.Raji
nii sgivena neff
ici
entcodef
orsummi
ngtwonXnma t
ric
esandput
tingthe
res
ultinathirdma tr
ix.Sheisa sk
edt of
indi
t'
sti
mec ompl
exi
ty.Shere
a l
iz
est
ha tt
he
numberofite
ra t
ionsr equ
ire
dismor ethann.Whatca
ns hecla
im wit
hregardt
ot he
comple
xit
yoft hec ode?
Op1 :ItisO(n)
Op2:I ti
sO(n2
)
Op3:I ti
s&the
ta(n)
Op4:I ti
s&omega(n)
Op5:
Cor
rec
tOp:4
Ques58.Ga ut
ami sgiventwoc odes
,A a ndB,tos o
lveapr oble
m,whic
hhavec
omplex
ity&t
het
a(n)
and&t he
ta(n2
)r espec
tiv
ely
.Hi scl
ientwa ntst osol
veaprobl
em
ofsi
z ek,whichGa ut
am doe snotk now.WhichcodewillGau
t a
m del
iv
ertot
hecl
ient
,
sothatthee xe
cut
ionisf as
ter?
Op1 :CodeA
Op2:CodeB
Op3:Ga ut
amc annotdetermine
Op4:Bot hcodeshavet hes amee xec
uti
onti
me,s odel
iverany.
Op5:
Cor
re ctOp:3
Ques61.Pa v
ithraisgiv
entwocode
s,A andB,t
osol
veapr
obl
em,whi
chha
ve
complex
ity&theta(n3
)a nd&ome ga(n3
)r espec
tiv
ely.He rcl
ie
ntwant
stos ol
vea
probl
em ofsi
zek ,whichissuf
fi
ci
ent
lyl
a r
ge.Whi
chcodeshoul
dshede
li
vert
othe
cl
ientinthepres
entscenar
io?
Op1 :CodeA
Op2:CodeB
Op3:Bot hcode
sha v
et hesameexe
cut
ionti
me,sodeli
verany
.
Op4:Noneoft hes
e
Op5:
Correc
tOp:1
Ques61.CodeA hastoexecu
te4*n2 +64pr ogramsta
teme
nts
,whileCodeB hasto
exe
cute32*npr ogr
ams t
ate
me ntsforaprobl
em ofsi
zen.Thetimeforexe
cuti
nga
si
ngleprogramstat
eme
ntiss amef ora
llst
ate
me nt
s.Raj
eshwasgiv
enapr obl
em
wit
hac ert
ains
izekandhede l
ive
redCodeA.Wha tcoul
dbethepossi
bleval
ueofk?
Op1 :1000
Op2:5
Op3:1 0
Op4:3
Op5:
Correc
tOp:4
Ques
63.Sa umy awri
tesacodewhi
chhasafunc
tionwhi
chcal
lsit
sel
f.Whi
chpr
ogr
ammi
ngc
onc
ept
i
sSa umyausing?
Op1:T hi
sisba dprogra
mmingpra
cti
ceands
houldnotbedone.
Op2:Re cursi
on
Op3:De cis
ionMa ki
ng
Op4:Ov erloadi
ng
Op5:
Cor
rectOp:2
Qu es
64.Shr i
shtiwrit
est hec odef
oraf
unc
tiont
hatc
ompu
test
hef
act
ori
aloft
he
i
npu t
tednu mbern.
funct
ionfactori
al(n)
{
i
f(ne qual
s1 )
retur
n1
else
--MI SSINGST ATEMENT- -
end
}
Fil
lint hemi s
sings t
ateme nt
.
Op1 :r et
urnf act
orial
(n-1 )
Op2:r etur
nn*f a
ctori
al(n)
Op3:r etur
nn*(n- 1)
Op4:r etur
nn*f a
ctori
al(n- 1
)
Op5:
CorrectOp:4
Qu e
s65.T a
nujwrite
st hec
odeforaf
unc
tiont
hatt
ake
sasi
npu
tna
ndc
alc
ula
test
he
sum offi
rstnna tu
ralnumber
s.
Functi
onsum( n)
{
i
f(??)
retu
rn1
els
e
retu
rn(n+s um(n-1))
end
}
Fil
lin?? i nthecode.
Op1 :ne qual
s1
Op2:ne quals2
Op3:n>=1
Op4:n> 1
Op5:
CorrectOp:1
Qu
es66.Sa
loniwr
ite
sthec
odef
oraf
unc
tiont
hatt
ake
sasi
npu
tn,a
nev
eni
nte
gera
ndc
alc
ula
tes
t
hes
um off
ir
stne
venna
tur
alnu
mbe
rs.f
unc
tions
um( n)
{
i
f(ne qu
als2)
ret
urn2
els
e
ret
urn(n+s u
m(n-2))
end
}
Shethencal
lsthef
unc
tionbyt
hes
tat
eme
nt,s
um(30).How ma
nyt
ime
swi
llt
hef
unc
tions
um be
c
all
edt
ocompu
tet
hiss
um.
Op1:1
Op2:30
Op3:1 5
Op4:1 6
Op5:
Cor
rec
tOp:3
Qu es
67.Cons iderthefol
lowi
ngfu
ncti
on
functi
oncalcu
late( n)
{
i
f(ne qu
als5)
return5
else
return(n+c a l
cul
ate
(n-5))
end
}
Shishircal
lsthef u
ncti
onbyt hes
tat
ement
,ca
lcu
lat
e(20).Wha
tva
luewi
llt
he
fu
ncti
onret
urn?
Op1 :50
Op2:200
Op3:35
Op4:20
Op5:
Corr
ectOp:1
Ques68.Ra viiswrit
ingapr ograminC++.C++u s
esthe'for'k
eywor
df orl
oops
.Duetodis
tra
cti
on,
Raviwr i
tes'gor'i
nst
e a
dof' f
or'.Whatwil
lt hi
sr es
ultt
o? Op1 :Thecodewil
lnotc
ompi
le
.
Op2:T hecodewillgiveane rr
orwhil
eine xecut
ion
Op3:T hecodema ywor kforsomeinput
sa ndnotf orothe
r s
.
Op4:I twil
lc r
eat
enopr oblems.
Op5:
Cor
re c
tOp:1
Ques
69.Wha tdoe sac ompi
lerdo?
Op1:Conver
tsc odef r
om ahi ghle
vell
anguagetoalow le
vella
nguage
Op2:Ne c
essari
lyc onver
tsthecodeint
oa s
semblyl
anguage
Op3:Convertsc odefrom alow l
evell
angu
aget oahighleve
llangu
age
Op4:Ne c
essari
lyc onver
tsthecodeint
oma chi
nela
nguage
Op5:
Cor
rectOp:1
Ques
70.A pr ogrami scompi l
edbyT ar u
nonhi sma c
hine
.Whe
the
ritwi
llr
unona
di
ff
erentc
ompu terwilldependu pon:
Op1:Ope ra
tings yst
em ont hec omputer
Op2:Ha rdwa r
ec onfi
gurat
ionoft hec omput
er
Op3:Bot hope rat
ings y
stema ndha rdwareconf
igu
rati
on
Op4:T helanguageoft hepr ogram
Op5:
Cor
rectOp:3
Ques71.Sa kshiwr i
tesacodei
nahi gh-
lev
elprogr
ammingl
angu
ageonaPe nti
um-
III
machine,whic hs hewant
stoexec
uteonaMot orol
achi
p.Whatofthef
oll
owingwi
ll
sherunont hec ode?
Op1 :Ani nterpreter
Op2:A c ompi l
er
Op3:A c ross-compil
er
Op4:L i
nker
Op5:
Corr
e ctOp:3
Ques
72.Shahaanahasa1 0,000linecode.Sheistr
y i
ngtodebu
git.Sheknowsthe
reisalogi
cal
er
rorint
hef i
rst25 li
nesofthecode.Whichofthefoll
owi
ngwil
lbeaneff
ici
entwayofde
buggi
ng:
Op1:Compi
let hewhol
ec odeandstepint
oitli
nebyl i
ne
Op2:Useani nter
pret
ero nthef
irst25line
s.
Op3:Compi
let
hewhol
ecodea
ndr
uni
t
Op4:Noneoft
hes
e
Op5:
Cor
rec
tOp:2
Ques73.F a
rhanwr i
t esac odetofindthefa
c t
ori
alofaninput
tednumbe
r.Hiscode
gi
vesc orrectanswerf orsomei npu
tsandincorre
ctans
wer
sf orothe
rs.Wha
tk i
ndof
err
ordoe shi sprogra m have?
Op1 :Sy ntact
ica
le r
r or
Op2:Ru n-t
imeEr ror
Op3:L ogicalError
Op4:Noneoft hes
e
Op5:
Correc
tOp:3
Qu
es74.Re
sha
mai
sde
buggi
ngapi
eceofc
odewhi
cht
ake
sse
ver
ali
ter
ati
onsofmodi
fyi
nga
nd
e
xec
uti
ngc
ode
,whi
leMoha
mma
dha
stode
li
verapr
odu
ctt
othec
ust
ome
r,whi
cht
hec
ust
ome
rwi
ll
r
unmu
lti
plet
ime
s.Re
sha
mawa
ntshe
rde
bugc
ycl
etot
akemi
nimu
m pos
sibl
eti
me,whi
leMoha
mma
d
wa
ntst
hathi
spr
odu
ctsr
unt
imei
smi
nimu
m.Wha
ttool
sshou
ldRe
sha
maa
ndMoha
mma
d
r
espe
cti
vel
yus
eont
hei
rcode
?
Op1:Compi l
er,Int
erpret
er
Op2:I nt
erpre
ter
,Compi ler
Op3:Compi le
r,Compi l
er
Op4:I nt
erpre
ter
,I nt
erpret
er
Op5:
Cor
rec
tOp:2
Ques75.Ga uta
m wr i
tesaprogr
amt orunonaMotor
olaproc
essoronhisPenti
umcompute
r.He
want
st os eehow theprogr
am wil
lexec
uteont
heMotor
olaproc
e s
soru
singhisPent
ium machi
ne.
Whatt oolwil
lheu se? Op1:Compil
er
Op2:I nt
erpret
er
Op3:As sembler
Op4:Si mula
tor
Op5:
Corr
e c
tOp:4
Ques76.Consi
derthef
oll
owi
ngc
ode
:
f
uncti
onmodify
(y ,
z)
{
y=y+1 ;
z=z+1 ;
re
turny-z
}
f
uncti
oncalc
ulat
e()
{
i
ntegera=5,b=1 0,c
c=modi fy(a,b);
pri
nta
pri
ntspace
pri
ntc
}
Assu
met hataa ndbwer
epa
sse
dbyv
alu
e.Wha
twi
llbet
heou
tpu
tone
xec
uti
ng
fu
ncti
onc a
lcu
lat
e( )?
Op1 :11-5
Op2:1 0- 5
Op3:6- 5
Op4:5- 5
Op5:
Corr
ectOp:4
Qu es77.Consi
derthefol
lowi
ngc ode
:
functionmodi
fy(b,a
)
{
returna-b
}
functionca
lcu
lat
e()
{
integera=5,b=1 2,c
c=modi fy(a,b);
printc
}
As s
u methataa ndbwe r
epa ss
edbyr e
fer
enc
e.Wha
twi
llbet
heou
tpu
toft
hepr
ogr
am one
xec
uti
ng
f
unc
tionc
alc
ula
te( ) ? Op1
:7
Op2:- 7
Op3:Er r
or
Op4:8
Op5:
Cor
rec
tOp:1
Qu es78.Consi
derthef
oll
owi
ngc
ode
:
functi
onmodify(y,
z)
{
y=y+1
z=z+1
returny-z
}
functi
oncalc
ulat
e()
{
integera=1 2,b=20,c
c=modi f
y(a ,b);
printa
printspac
e
pri
ntc
}
Assu
met hataa ndbwe
repa
sse
dbyr
efe
renc
e.Wha
twi
llbet
heou
tpu
toft
he
fu
ncti
onc a
lcul
ate
()?
Op1 :12- 8
Op2:1 3- 8
Op3:1 28
Op4:1 38
Op5:
Corr
ectOp:2
Ques79.Af zalwri
tesapieceofc
ode
,wherease
tofthre
el i
nesoc
curarou
nd1 0time
s
indiff
ere
ntpa rtsoftheprogr
am.Whatpr
ogr
ammingc
onceptcanheus
et oshort
en
hisprogramc odelengt
h?
Op1 :Usef orloops
Op2:Us ef u
ncti
ons
Op3:Us ea rra
ys
Op4:Us ec l
asses
Op5:
Correc
tOp:2
Ques80.Ge eti
kawr it
esapi e
ceofc ode
,whe reasetofe ightli
nesoccu
ra round10
ti
mesi ndiffe
rentpa rt
softhepr ogr
am (CodeA).Shepa sse
sont hecodet oDeva.
Devapu t
st hes etofeightl
inesinaf u
nct
iondefi
nit
iona ndc al
lsthe
ma tthe1 0
poi
ntsint hepr ogram (CodeB).Whi chc odewi
llr u
nf ast
eru s
inganinte
r pr
ete
r?
Op1 :CodeA
Op2:CodeB
Op3:CodeA a ndCodeB wi l
lrunwitht
hes ames peed
Op4:Noneoft hes
e
Op5:
Corr
e c
tOp:1
Qu es81.Consi
derthefol
lowi
ngc
ode
:
functi
onmodi f
y(a,b)
{
integerc,d=2
c=a *d+b
returnc
}
functi
onc al
cul
ate
()
{
integera=5,b=20,c
integerd=1 0
c=modi fy(a,b);
c=c+d
printc
}
As
sumet
hataa
ndbwe
repa
sse
dbyv
alu
e.Wha
twi
llbet
heou
tpu
toft
hef
unc
tionc
alc
ula
te()?
Op1:80
Op2:40
Op3:32
Op4:72
Op5:
Cor
rec
tOp:2
Qu es82.Cons i
derthefol
lowi
ngcode
:
functionmodify
(w, u)
{
w =w +2
u=u-3
return(w -u )
}
functioncal
culat
e()
{
integera=1 0,b=20,c
c=modi f
y(a,b);
printa
prints pa
ce
printb
}
As s
u methatawa spass
edbyv a
lueandbwa
spa
sse
dbyr
efe
renc
e.Wha
twi
llbet
heou
tpu
toft
he
pr
ogr
am one
xec
uti
ngf
unc
tionc
alc
ula
te( ) ? Op1
:121
7
Op2:1 01 7
Op3:1 2 20
Op4:1 0 20
Op5:
Cor
rec
tOp:2
Qu es83.Consi
derthefol
lowingfunc
tion:
functi
onrun( )
{
integera=0 // St at
eme nt1
while(a< 5)
{
integerc=0 // St at
eme nt2
c=c+1// St at
ement3
a=a+1
}
printc// St at
ement4
}
Atwhi chstat
ementinthi
spr ogr
am wi l
lthec
ompi
le
rde
tec
tane
rror
?
Op1 :Sta
tement1
Op2:St ate
ment2
Op3:Sta
teme
nt3
Op4:Sta
teme
nt4
Op5:
Cor
rec
tOp:4
Ques
85.Whi choneoft hef
oll
owi
ngisthelowe
stl
evelfor
ma tt
owhi
cht
hec
ompu
terc
onv
ert
sa
hi
gherla
ngu a
gepr ogr
am befor
eexec
uti
on? Op1:Engl
is
hc ode
Op2:Ma c
hineCode
Op3:As semblyLanguage
Op4:Sy st
emL a
nguage
Op5:
Cor
rectOp:2
Ques
86.Ify ouwanttowr
iteaf
unc
tiont
hats
wapst
hev
alu
esoft
wov
ari
abl
es,y
ou
mustpas
st hem by
:
Op1 :Val
ueonly
Op2:Re fe
r e
nceonly
Op3:EitherA orB
Op4:Ne it
herA norB
Op5:
Cor
rectOp:2
Que
s87.Cons i
dert
hefol
lowi
ngc
ode
:
i
f(c ondi
ti
on1){
i
f(c ondi
ti
on2)
{ // State
mentA } el
se
i
f(c ondi
ti
on3)
{ // State
mentB } el
se
{ // State
mentC} e l
se
i
f(c ondi
ti
on4)
{ // State
mentD } el
se
{ // State
mentE}
}
Whic
hoft hef oll
owingcondi
tionswi l
la l
low execut
ionofs t
atementC?
Op1:c onditi
on1AND c onditi
on3
Op2:c ondi
tion1AND c ondi
tion4AND ! condit
ion2
Op3:NOT (c ondi
ti
on2) AND NOT (c ondit
ion3)
Op4:c ondi
tion1AND NOT (c ondi
ti
on2) AND NOT (condi
tion3)
Op5:
Cor
rectOp:4
Ques88.Cons iderthefoll
owingc ode
:
i
f(c onditi
on1 ){
i
f(c onditi
on2)
{ // St ateme ntA } els
e
i
f(c onditi
on3)
{ // St ateme ntB} else
{// St atementC} e ls
e
i
f(c onditi
on4) {// St at
eme ntD} e l
se
{// St atementE}
}
Whichoft hef oll
owingcondit
ionswillal
low executi
onofs t
atementE? Op1:condi
ti
on1AND
condi
ti
on3
Op2:NOT (c ondi
ti
on1) AND c ondi
ti
on2 AND NOT (c ondi
tion4)
Op3:NOT (c ondi
ti
on2) AND NOT (condit
ion3)
Op4:c ondit
ion1AND c ondi
tion4AND NOT (c ondit
ion2) AND NOT (condi
ti
on3) Op5:
Correc
tOp:2
Que
s90.Wha tdoe
sthefol
lowi
ngfu
nct
iondo?
f
unct
ionope
rati
on(inta
,i ntb)
{
i
f(a< b)
{r et
urnoperat
ion(b,a)} e l
se
{r et
urna}
}
Op1:Re t
urnsthema xof(a,b)
Op2:Re tur
nsthemi nof(a,b)
Op3:L oopsforev
er
Op4:Al waysretu
rnsthes
econdpar
ame
ter
Op5:
Cor
rectOp:1
Ques92.functi
ong(i ntn)
{
i
f(n> 0) r etur
n1 ;
el
ser et
urn- 1
;
}
fu
ncti
onf (inta ,intb)
{
i
f(a> b) r et
urng(b- a);
i
f(a< b) r et
urng(a -b);
ret
urn0;
}
I
ff (a,b) i
sc all
ed,wha tisre
turne
d?
Op1 :Always- 1
Op2:1i fa> b,- 1i
fa< b,0o the
rwi
se
Op3:- 1ifa> b,1i fa< b,0o the
rwi
se
Op4:0i fae qualsb,-1other
wise
Op5:
Correc
tOp:4
Que
s93.f
unc
tiong(i
ntn)
{
i
f(n> 0) r etur
n1 ;
el
ser e
turn- 1
;
}
fu
ncti
onf (inta ,intb)
{
i
f(a> b) r et
urng(a -b);
i
f(a< b) r et
urng(b- a);
ret
urn0;
}
I
ff (a,b) iscall
ed,whati sre
turned?
Op1 :1ifa> b,- 1ifa< b,0ot her
wis
e
Op2:Al ways+1
Op3:0i fae qualsb,+1otherwis
e
Op4:- 1ifa> b,1i fa< b,0o t
herwi
se
Op5:
Corre
ctOp:3
Ques94.functi
ong(i ntn)
{
i
f(n> 0) r etur
n1 ;
el
ser et
urn- 1
;
}
fu
ncti
onf (inta ,intb)
{
i
f(a> b) r et
urng(a -b);
i
f(a< b) r et
urng(- b+a);
ret
urn0;
}
I
ff (a,b) i
sc all
ed,wha tisre
turne
d?
Op1 :Always+1
Op2:1i fa> b,- 1i
fa< b,0o the
rwi
se
Op3:- 1ifa> b,1i fa< b,0o the
rwi
se
Op4:0i fae qualsb,-1other
wise
Op5:
Correc
tOp:2
Ques
95.func
tiong(intn)
{
i
f(n> 0) r e t
urn1;
el
seret
urn-1;
}
f
unct
ionf(i
nta ,intb)
{
i
f(a> b) r eturng(b-a);
i
f(a< b) r eturng(-a+b);
re
tur
n0;
}
I
ff(a,b) i
scall
ed,whati
sr e
turne
d?
Op1:Always+1
Op2:- 1ifa> b,1i fa< b,0o the
rwi
se
Op3:1i fa> b,- 1i
fa< b,0o the
rwi
se
Op4:0i fae qual
sb,-1other
wise
Op5:
Cor
rec
tOp:2
Ques96.Consi
derthefol
lowingcode:
fori=m toni nc
re me
nt2
{ print"He
ll
o!"}
Assu
mi ngm < na ndexa
c t
lyoneof(m,n) i
sev
en,how ma
nytimeswi
llHe
ll
obepr
int
ed?
Op1 :(n-m +1 )/2
Op2:1+(n-m)/2
Op3:1+(n-m)/2 i fm i seven,(n-m +1)/2 i
fm isodd
Op4:(n-m +1 )/2 i
fm i seven,1+(n-m)/2 ifm isodd
Op5:
Corr
e c
tOp:1
Ques97.Consi
derthefol
lowi
ngc ode:
fori=m toni nc
re me
nt2
{ pr i
nt"He
ll
o!"}
Assumingm < na nd(m, n) ar
ee it
herbot
hev
enorbothodd,How ma
nyt
ime
swi
ll
Hell
obepr i
nte
d?
Op1 :(n-m +1 )/2
Op2:1+(n-m)/2
Op3:1+(n-m)/2 i fm i seven,(n-m +1 )/2 i
fm isodd
Op4:(n-m +1 )/2 i
fm i seven,1+(n-m)/2 i fm isodd
Op5:
CorrectOp:2
Ques98.As s
umingn> 2,Whatv a
luedoe
sthef
oll
owi
ngf
unc
tionc
ompu
tef
oroddn?
fu
ncti
onf(i ntn)
{
i
f(ne qual
s1 ){ re
turn1}
i
f(ne qual
s2) { retu
rnf(n-
1) +n/2 }
ret
urnf (n-
2) +n;
}
Op1 :1+2 +3+4 +. .
.+n
Op2:1+3 +5+7 +. ..+n
Op3:n/2+(1+3+5 +7+. .
.+n)
Op4:1+(1+3+5 +7 +. ..+n)
Op5:
Correc
tOp:2
Que
s99.Ass
umi
ngn> 2,Wha
tva
luedoe
sthef
oll
owi
ngf
unc
tionc
ompu
tef
ore
venn?
i
ntf(intn)
{
i
f(ne qu
als1){ ret
urn1}
i
f(ne qu
als2) { r
etur
nf (n-
1) +n/2 }
ret
urnf(n-2) +n
}
Op1 :1+2 +3+4 +. ..+n
Op2:1+(2+4+6 +8 +. .
.+n)
Op3:1+n/2+(4+6 +8+. .
.+n)
Op4:2+4 +6+8 +. ..+n
Op5:
Corre
ctOp:4
Ques
100.T heforloopise quiv
alenttoawhi
lel
oopwhe
n
Op1:T he
reisnoi nit
ial
izati
one x
pressi
on
Op2:T hereisnoi nc
r e
me ntexpress
ion
Op3:A a ndB c ombineda retrue
Op4:I tisneverequi
v al
ent
Op5:
Cor
rectOp:3
Ques
101.Consi
derthest
ate
ment
whi
le(a< 1 0.0) { a=a *a}
Ass
umingai sposi
ti
ve,f
orwhatva
lueofawi
llt
hisc
odes
tat
eme
ntr
esu
lti
nan
i
nfi
nit
eloop?
Op1 :a< 1.0
Op2:a< s qr
t(10)
Op3:a> s qr
t(10)
Op4:a=0
Op5:
Cor
rectOp:1
Ques102.inta rea(dou bl
er adi
us)
{
ret
urnPI *radius
*r adi
us;
}
Whichoft hef ol
lowingi salwaystruea
boutthef
uncti
onarea?
Op1 :Itr e
turnst hea reaofac irc
lewit
hinthel
imit
sofdoublepreci
si
on.
Op2:I tretur
nst heareaofac i
rcl
ewithi
ntheli
mitsoftheconst
antPI.
Op3:I tretur
nst heareaofac i
rcl
ewithi
ntheli
mitsofprec
isi
onofdouble
,ort
he
const
antPI ,whi cheve
ri slower.
Op4:Noneoft hea bove.
Op5:
CorrectOp:4
Que
s103.Whatdoe
sthi
sfu
nct
ionc
ompu
tef
orpos
iti
ven?
f
unct
ionf(i
ntn)
{
i
f(ne qu
als1
)
{r et
urn1} e l
se
{r et
urnf(n-1
)/f(n-1) +n}
}
Op1:1+n
Op2:1+2 +3+. ..+n
Op3:1+n,i fn> 1 ,1othe
rwi
se
Op4:Noneoft heabove
Op5:
Cor
rectOp:3
Ques
104.Whi c
hoft
hes
eisnotada
tat
ype
?
Op1:inte
ger
Op2:c hara
cter
Op3:boolean
Op4:a rr
ay
Op5:
Cor
rectOp:4
Ques
105.T hec onst
ruct"
if(condi
ti
on) t
henA e
lseB"i
sforwhi
choft
hef
oll
owi
ngpu
rpos
es?
Op1:De ci
sion-Making
Op2:I t
eration
Op3:Re cursion
Op4:Obj ectOr ie
ntedProgr
amming
Op5:
Cor
rectOp:1
Ques
106.Inas eque
nti
alprogra
mmi ngl
angu
age
,codes
tat
eme
ntsa
ree
xec
ute
dinwhi
cho
rde
r?
Op1:Alla r
ee xecut
edsimul
taneou
sly
Op2:F rom topt obot
tom
Op3:F rom bott
om totop
Op4:Noneoft hese
Op5:
Cor
rectOp:2
Ques
107.A for-l
oopisus
edf
orwhi
choft
hef
oll
owi
ngpu
rpos
es?
Op1:De ci
si
on-Making
Op2:I t
erat
ion
Op3:Re curs
ion
Op4:Noneoft hes
e
Op5:
Cor
rectOp:2
Qu
es1
08.Therearetwoloopswhic
ha renes
ted.Thi
simpl
ie
swhi
choneoft
hef
oll
owi
ng?
Op1:Twol
oop,onea f
tertheother
Op2:Twoloops
,onei ns
idetheother
s
Op3:Oneloopwithtwodiff
ere
ntiter
ati
oncount
s
Op4:T wol
oopswi
tht
hes
amei
ter
ati
onc
ount
Op5:
Cor
rec
tOp:2
Ques
109.How wi l
l47bes
tor
eda
sanu
nsi
gne
d8-
bitbi
nar
ynu
mbe
r?
Op1:1 01
111
01
Op2:001 01111
Op3:1 011
1000
Op4:001 01101
Op5:
Cor
rectOp:2
Ques
110.Ani
nte
gerXi
ssa
veda
sanu
nsi
gne
d8-
bitnu
mbe
r,00001
011
.Wha
tisX?
Op1:22
Op2:1 1
Op3:1 0
Op4:Noneofthes
e
Op5:
Cor
rectOp:2
Ques
111
.A variablecannotbeused…
Op1:Be f
oreitisde cla
red
Op2:Af t
eritisde c
lare
d
Op3:I nthefunctionitisdec
lar
e din
Op4:Ca na l
way sbeu sed
Op5:
Cor
rectOp:1
Ques
112.Whati simpl
iedbytheargu
mentofafunc
tion?
Op1:T hevar
iablespas
sedtoitwheniti
scal
le
d
Op2:T hevalu
ei tret
urnsonexec
uti
on
Op3:T heexecut
ioncodeins
idei
t
Op4:I tsr
etur
nt ype
Op5:
Cor
rectOp:1
Ques
113.Whi
choft hef ol
lowi
ngistruea bou
tc omme
nts
?
Op1:T he
yareexecut
edonl yonce.
Op2:T heya
renote xecuted
Op3:A goodpr ogra
m do esnotcontai
nt hem
Op4:T heyi
ncr
ea s
epr ograme x
ecut
iontime.
Op5:
Cor
rectOp:2
Ques1
14.Ne
ela
m want
stos har
ehe rcodewit
hac ol
le
ague
,whoma ymodifyi
t.T
huss
hewa nt
sto
i
nclu
dethedat
eoftheprogra
mc r
eat
ion,t
hea u
thorandothe
rinf
orma
tionwi
tht
heprogr
am.What
compone
nts
houlds
heuse
? Op1 :Headerf
il
es
Op2:I t
erat
ion
Op3:Comme nts
Op4:Pr eproce
ssordi
rec
tiv
e
Op5:
Cor
rec
tOp:3
Ques1
15.Shashiwri
tesapr ograminC++andpasse
sitontoPankaj
.Pank
a jdoe
ssomei
nde
nta
tion
i
ns omestat
ementsofthec ode
.Wha twi
llt
hisl
eadto? Op1
:Fa
s t
erExe
cut
ion
Op2:L owerme moryrequ
irement
Op3:Cor r
ecti
onofe rr
ors
Op4:Be tt
err e
adabi
li
ty
Op5:
Cor
r e
ctOp:4
Ques
116.Ze naba ndSha shiindepende ntl
ywr i
teapr ogramtofindt hethema s
sofonemoleof
wat
er,whi c
hi ncl
u desma ssofhy droge nandox yge
n.Ze nabdef
inest hevari
abl
es:
i
nte
gerhy drogen,ox ygen,wa t
er// CodeA
whi
leShashide fi
ne sthet hreequ anti
tiesa s
:
i
nte
gera ,b,c// CodeB
Whic
hi sabe t
terpr ogrammi ngpr acticeandwhy ?
Op1:CodeB i sbe tte
rbe c
ausev ariablenamesa reshorte
r
Op2:CodeA i sbe t
terbe causethev ari
ablenamesa reunde
rst
a nda
bl eandnonconf
usi
ng
Op3:CodeA wi l
lr unc orrect
ly,whi leCodeB wi llgiveanerr
or .
Op4:CodeB wi l
lr unc orrect
ly,whi leCodeA wi llgiveanerr
or .
Op5:
Cor
rectOp:2
Ques1
17.Forsolvi
ngapr oble
m,whi choftheseisthefirs
tst
epi
nde
vel
opi
ngawor
kingpr
ogr
am
fori
t?
Op1 :Wri
tingthepr ogramint heprogramminglangu
age
Op2:Wr iti
ngas tep-by-st
epa l
gorit
hm tosolv
ethepr obl
em.
Op3:Compi li
ngthel ibr
arie
sr equ
ired.
Op4:Codede bu
gging
Op5:
Corr
ectOp:2
Ques
118.A robus tprogra
m haswhi choneoft
hef
oll
owingf
eat
ure
s?
Op1:I tr
unsc orrect
lyons omei npu
ts
Op2:I tisrobustt ohardwareda mage
Op3:I tcanha ndleincorre
ctinputdataorda
tat
ypes
.
Op4:Noneoft hese
Op5:
Cor
rectOp:3
Ques
119.Tar
unwant
stowr
iteacodet
odivi
detwonumbe
rs.Hewant
stowa rnt
heu s
er
andtermi
nat
ethepr
ogr
amifheorsheent
ers0 a
sthediv
isor
.Whi
chprogr
amming
cons
tru
ctc anheusetodot
his
?
Op1 :It
erat
ion
Op2:De c
isi
on-ma
king
Op3:Re c
ursi
on
Op4:Noneoft hes
e
Op5:
Corr
ectOp:2
Ques1
20.T os olv
eapr oble
m,i ti
sbrokeni
nt oase
que
nceofsmal
le
rs u
b-probl
ems,ti
lla
st
agethatt hesub-proble
mc a
nbee a
sil
ysol
ved.Wha
tisthi
sde
signapproa
chc al
le
d?
Op1 :Top-downAppr oa
ch
Op2:Bot t
om- UpAppr oach
Op3:Pr ocedu
ralPr ogramming
Op4:Noneoft hese
Op5:
Corr
ectOp:1
Ques
121.T
hetimec ompl
exi
tyofl
ine
ars
ear
cha
lgor
ithm ov
era
nar
rayofne
leme
ntsi
s
Op1:O (log2 n)
Op2:O (n)
Op3:O (nl og2n)
Op4:O (n2
)
Op5:
Cor
rectOp:2
Qu
es1
22.Ra
jes
himpl
eme
ntsqu
euea
sas
ingl
y-l
ink
edl
ink
edl
is
t.T
hequ
eueha
sn
el
ement
s.Thet i
mecompl
exi
tyt
oADD ane
wel
eme
ntt
othequ
eue
:
Op1 :O (1)
Op2:O (l og2n)
Op3:O (n)
Op4:O (nl og2n)
Op5:
Corr
ectOp:1
Ques
123.T het i
mere
qui
redt
oins
erta
nel
eme
nti
nas
tac
kwi
thl
ink
edl
is
t
i
mplement
ationi s
Op1:O (1 )
Op2:O (l og2n)
Op3:O (n)
Op4:O (nl og2n)
Op5:
Cor
rectOp:1
Ques
124.Inthefol
lowi
ngs
ort
ingpr
oce
dur
es,whi
chonewi
llbet
hes
lowe
stf
ora
ny
gi
venarra
y?
Op1:Qu i
cksor
t
Op2:He apsor
t
Op3:Me rgeSort
Op4:Bu bbl
esort
Op5:
Cor
rectOp:4
Ques1
25.Pa nkajs
tor
esnda t
aelement
sinahas
htabl
e.Heisabl
etogetthebe
st
ef
fi
cie
ncyachie
vabl
ebyaha shta
ble.Whati
stheti
mecompl
exi
tyofa
cce
ssi
ngany
el
ementfr
om thishas
htabl
e?
Op1 :O(1)
Op2:O(n2
)
Op3:O(l ogn)
Op4:O(n)
Op5:
Corr
ectOp:1
Ques1
26.Ev e
rye l
ementofada
tastru
ctu
reha sana
ddres
sa ndakeyass
oci
ate
dwithi
t.A s
ear
ch
mechani
sm deal
swithtwoormoreval
uesass
igne
dtothesameaddr
essbyusi
ngtheke
y.Whatis
t
hissearchmechani
sm? Op1:Li
nea
rSe ar
ch
Op2:Bina
rysear
ch
Op3:HashCodedSe a
rch
Op4:Noneofthese
Op5:
Cor
rec
tOp:3
Ques
127.T heor de
rofma gni
tudeoft
hewor
stc
asepe
rfor
manc
eofaha
shc
ode
dse
arc
h
(overN elements)i s
Op1:N
Op2:N l og2N
Op3:l og2N
Op4:notde pendentuponN
Op5:
Cor
rectOp:1
Ques1
28.A s orti
ngal
gori
thm t
rav
ers
esthr
oughal i
st,compa
ringa dj
ace
ntel
ement
sandswi
tchi
ng
the
mu nderce r
tai
ncondi
ti
ons.Whatist
hissor
tingalgo
rit
hm cal
le
d? Op1 :i
nse
rti
onsor
t
Op2:he aps ort
Op3:qu ic
ks ort
Op4:bu bblesort
Op5:
Corre
ctOp:4
Ques1
29.A s ort
inga lgori
thm i
ter
ati
vel
ytrav
ers
esthrou
ghalis
ttoexcha
ngethef
ir
st
el
ementwi t
ha nyeleme ntles
sthanit.Itt
henrepe
atswithanewfi
rstel
eme
nt.What
i
st hi
ss ort
inga l
gorithm call
ed?
Op1 :inser
tions or
t
Op2:s el
ecti
ons ort
Op3:he aps ort
Op4:qu i
cks ort
Op5:
Corre
ctOp:2
Qu
es1
30.A s
ortwhi
chu
sest
hebi
nar
ytr
eec
onc
epts
ucht
hata
nynu
mbe
rint
het
reei
sla
rge
rtha
n
a
llt
henu
mbe
rsi
nthes
ubt
reebe
low i
tisc
all
edOp1
:se
lec
tions
ort
Op2:i ns
ert
ions or
t
Op3:he apsort
Op4:qu i
cks or
t
Op5:
Cor
rec
tOp:3
Ques1
31.T heave
rageti
mere
qui
redtope
rfor
m as
ucc
ess
fuls
equ
ent
ials
ear
chf
ora
n
el
ementina narrayA(1:n) i
sgiv
enby
Op1 :(n+1 ) /2
Op2:l og2n
Op3:n(n+1 ) /2
Op4:n2
Op5:
Corr
ectOp:1
Qu
es1
32.How ma
nyc
ompa
ris
onsa
rene
ede
dtos
orta
nar
rayofl
engt
h5 i
fas
tra
ights
ele
cti
ons
ort
i
sus
eda
nda
rra
yisa
lre
adyi
ntheoppos
iteor
der
? Op1
:1
Op2:1 0
Op3:50
Op4:20
Op5:
Cor
rec
tOp:2
Ques
133.Qu euesser
veama j
orrolei
n
Op1:s i
mula
tionofr e
curs
ion
Op2:s imu
lationofarbi
trar
ylink
edli
st
Op3:s imu
lationofli
mit
edr es
ourcea
lloc
ati
on
Op4:e xpr
essioneval
uat
ion
Op5:
Cor
rectOp:3
Ques
134.Theavera
gesear
chtimeofha
shi
ngwi
thl
ine
arpr
obi
ngwi
llbel
essi
fthel
oadf
act
or
Op1:isfarle
ssthanone
Op2:e qu
alsone
Op3:i sf
argreat
erthanone
Op4:noneoft he
se
Op5:
Cor
rectOp:1
Ques
135.Nu mberofve
rti
cesofoddde
gre
einagr
aphi
s
Op1:isa l
wayseven
Op2:a l
waysodd
Op3:e i
therevenorodd
Op4:a l
waysz e
ro
Op5:
Cor
rectOp:1
Ques
136.T healgori
thm des
ignt
echni
queu
sedi
nthequ
icks
orta
lgor
ithm i
s
Op1:Dy namicprogramming
Op2:Ba c
kt r
acking
Op3:Di vi
dea ndc onqu
er
Op4:Gr eedySe arc
h
Op5:
Cor
rectOp:3
Ques
137.Linkedli
stsarenots
uit
abl
efor
Op1:Inser
tionsort
Op2:Bi narysear
ch
Op3:Qu eueimplement
ati
on
Op4:Noneoft hese
Op5:
Cor
rectOp:2
Qu
es1
38.A c
onne
cte
dgr
aphi
stheonewhi
ch
Op1:Cannotbepart
iti
one
dwi t
houtremovi
nganedge
Op2:Canbepa rt
it
ionedwit
houtremovi
nga ne
dge
Op3:doesnotcontai
nac ycl
e
Op4:Ha seve
nnumbe rofvert
ice
s
Op5:
Cor
rec
tOp:1
Ques
140.St ackisusef
ulfori
mpl
eme
nti
ng
Op1:r a
dixs ea
rch
Op2:br eadthfir
stsearc
h
Op3:r ecu
r s
ion
Op4:noneoft hese
Op5:
Cor
rectOp:3
Ques1
41.Whichoft
hef
oll
owi
ngi
sus
efu
lint
rav
ers
ingagi
vengr
aphbybr
eadt
hfi
rst
sea
rch?
Op1 :st
ack
Op2:s et
Op3:l i
st
Op4:qu eue
Op5:
Corre
ctOp:4
Ques
142.Whi c
hoft
hef
oll
owi
ngi
sus
efu
lini
mpl
eme
nti
ngqu
icks
ort
?
Op1:s t
ack
Op2:s et
Op3:l i
st
Op4:qu eue
Op5:
Cor
rectOp:1
Ques1
43.Whi c
hoft
hef
oll
owi
nga
bst
rac
tda
tat
ype
sca
nbeu
sedt
ore
pre
sentama
nyt
o-ma
ny
rel
ati
on?
Op1 :Tre
e
Op2:St ack
Op3:Gr aph
Op4:Qu e
ue
Op5:
Corre
ctOp:3
Ques1
45.Whi choft hefollowingsort
ingal
gor
ithmsy
iel
dapprox
imat
elyt
hesa
mewors t
cas
ea nd
ave
rage-
caser unni
ngtimebe havi
ourinO (nlogn)? Op1 :Bubbl
esor
tandSe
lec
tionsort
Op2:He aps orta ndMe rges or
t
Op3:Qu i
cks ortandRa dixs or
t
Op4:T reesor tandMe dian-of-
3 Quicks
ort
Op5:
Corr
ectOp:2
Qu
es1
46.A c
ompl
etebi
nar
ytr
eewi
th5l
eve
lsha
show ma
nynode
s? (Rooti
sLe
vel1
) Op1
:15
Op2:25
Op3:63
Op4:31
Op5:
Cor
rec
tOp:4
Que s
147.T hemaxi
mum numberofnode
sonl
eve
lIo
fabi
nar
ytr
eei
swhi
choft
he
fol
lowing? (Rooti
sLev
e l1)
Op1 :2l -
1
Op2:3l -1
Op3:2l
Op4:2l-1
Op5:
CorrectOp:1
Ques1
48.Consi
deranar
rayonwhic
hbubbl
es orti
sus
ed.Thebubbl
esortwoul
d
comparet
heeleme
ntA[x]t owhi
chofthefoll
owi
ngel
eme
ntsinas i
ngl
eite
rati
on.
Op1 :A [x+1
]
Op2:A [x +2]
Op3:A [x +2x]
Op4:Al loft
hese
.
Op5:
Corr
ectOp:1
Que
s149.Ina nimple
mentati
onofal i
nkedli
st,e
achnodecontai
nsda
taa
nda
ddr
ess
.
Whi
choft hefol
lowi
ngc ou
ldtheaddres
sfie
ldpossi
blyc
ont
ain?
Op1:Addr e
ssofnextnodei nse
quence
Op2:I t
'sowna ddr
ess
Op3:Addr essofla
stnode
Op4:Addr essoffi
rstnode
Op5:
Cor
rec
tOp:1
Ques1
50.Su rbhiwantstoi
mple
mentapart
icu
lardatast
ruc
tureusi
ngas t
ati
carr
ay.Sheu
sest
he
conc
eptofc ir
cul
arlis
ttoimpl
ementt
hedat
as tr
uct
ure,bec
ausethi
sall
ows
hertoe ff
ici
entl
yusea l
lfi
el
dsofthear
ray.Whi c
hda t
as tr
uct
ureisSurbhi
impl
eme nt
ing?
Op1 :as tack
Op2:aqu eue
Op3:Bi naryTree
Op4:Noneoft hese
Op5:
Correc
tOp:2
Ques
151.Whi choft hefol
lowi
ngi
saba
dimpl
eme
nta
tionf
oraqu
eue
?
Op1:Cir c
u l
arLis
t
Op2:Dou bl
ylinkedlis
t
Op3:Si nglyli
nkedL i
st
Op4:L inearStati
cAr ray
Op5:
Cor
rectOp:4
Ques.Whi
choft hef ol
lowings t
atementsar
etru
eabou
tadoubl
y-l
ink
edli
st?
Op1 :i
tmaybee it
herl i
nearorc irc
u l
ar
Op2:i tmustcontai
nahe a
de rnode
Op3:i twi
lloc
c upys a
meme moryspaceastha
tofli
nea
rli
nke
dlist
,bot
hha v
ing
samenumberofnode s
Op4:Noneoft hese
Op5:
Corr
ectOp:1
Ques.Whic
hoft hefol
lowi
ngdat
as tr
uctu
rema ygiv
eov e
rfl
ow e
rror
,event
hou
ghthecur
rent
numberofele
me ntinitisles
sthanitssiz
e? Op1 :Qu e
ueimpleme
nte
dinali
nea
ra r
ray
Op2:Qu eueimpl e
mentedinacirc
ular
lyconne
cte
da rr
ay
Op3:St ac
ki mplement
e di
nal i
neararray
Op4:noneoft he se
Op5:
Corr
ectOp:1
Ques
.Nu mbe
rofpos
sibl
eor
der
edt
ree
swi
th3 node
sA,B,Ci
s
Op1:1 6
Op2:1 2
Op3:1 3
Op4:1 4
Op5:
Cor
rectOp:2
Ques
.T hebes tsort
ingme
thodsi
fnu
mbe
rofs
wappi
ngdonei
stheonl
yme
asu
reofe
ffi
ci
enc
yis
Op1:Bu bbl
es or
t
Op2:Se lec
tions ort
Op3:I nse
rti
ons or
t
Op4:Qu i
cks ort
Op5:
Cor
rectOp:3
Ques
.A hashtabl
ecanstor
eama ximum of10rec
ords
.Cu r
rent
lytherear
ere
cor
dsi
nloc
a t
ions1,
3,4,7,8,9,1 0.Theproba
bil
it
yofane wre
cordgoingi
ntoloc
a t
ion2,wi
thaha
shfuncti
on
re
sol
vingc
oll
is
ionsbyl
ine
arprobi
ngi sOp1 :0.
6
Op2:0.1
Op3:0.2
Op4:0.5
Op5:
Cor
rec
tOp:1
Ques
.A f u
llbi
nar
ytre
ewi
thnl
eav
esc
ont
ains
Op1:2n+1node s
Op2:l og2nnodes
Op3:2n-1node s
Op4:2nnode s
Op5:
Cor
rectOp:3
QuesAnarra
ycont
ainsthef
oll
owingel
ement
sinorder
:76 12 30 18.Insert
ions
ort
i
su s
edtosortt
hearrayinas
cendingor
der.How ma
nyti
meswilla
ni ns
e r
tionbe
made?
Op1 :2
Op2:3
Op3:4
Op4:5
Op5:
Cor
rectOp:1
Qu
es.Ana
rra
yof5nu
mbe
rsha
sthef
oll
owi
nge
ntr
iesi
nor
der
:7 45 1
08.Pr
asha
nt
use
ss el
ect
ionsorttosortthisa
rrayi
nde
sce
ndi
ngo
rde
r.Wha
twi
llt
hea
rra
ycont
ain
af
tertwoitera
tionsofse
lec
t i
onsor
t?
Op1 :108 754
Op2:1 0 8 574
Op3:81 0 574
Op4:Noneoft he
se
Op5:
Corre
ctOp:2
Ques.Sris
htiwri
tesaprogr
amtofi
ndane l
ementi
nthearr
ayA[5] wi
tht
hef ol
lowi
nge
lement
s
i
nor der:8304045 70.Sher u
nstheprogr
amtofindanumbe
rX.Xisfou
ndi nthef
irs
t
i
ter
ationofbina
rys e
arc
h.Whati
stheval
ueofX? Op1 :40
Op2:8
Op3:70
Op4:30
Op5:
Cor
rec
tOp:1
Ques.Thea rr
ayA hasne l
ements.Wewa nttodet
ermi
netheposi
ti
onofXint hearr
ay.Wek now
thatXi spres
entinthearr
ayA a ndXc a
nbepr ese
ntatanyloc
ati
oninthearraywi
thequ
al
probabi
li
ty.How manycompar
isonswi
llberequi
redonave
ragetofindt
heele
me ntXusi
ngli
near
searc
h? Op1 :n
Op2:(n+1)/2
Op3:2*n
Op4:n^2
Op5:
Cor
rec
tOp:2
Ques
.A isanemptysta
ck.Thefoll
owingope
rati
onsa
redoneonit.
PUSH(1)
PUSH(2)
POP
PUSH(5)
PUSH(6)
POP
Whatwil
lthes
tac
kc ont
aina
fte
rt heseope
rat
ions
.(Topofthest
ackisu
nde
rli
ned)
Op1:56
Op2:15
Op3:56
Op4:15
Op5:
Cor
rectOp:2
Que
s.A st
acki
simple
ment
edasali
neara
rrayA[0…N-1
].F ar
hanwr
ite
sthef
oll
owi
ngf
unc
tions
f
orpus
hinganel
ementEintothes
tac
k.fu
nct
ionPUSH( t
op,E,N )
{
if
(X)
{
top=t op+1
A[t op] =E
}
else
{
print"Ov er
flow"
}
returntop
}
Fil
lint hec ondi
ti
onX
Op1 :top< N
Op2:t op<n- 1
Op3:t op> 0
Op4:t op> 1
Op5:
Cor r
ectOp:2
Qu esA stac
ki simple
me nt
eda
sal
ine
ara
rra
yA[0…N-
1].Noorwr
ite
sthef
oll
owi
ngf
unc
tionsf
or
popping
ane lementfrom thest
ack.
funct
ionPOP( t o p,N )
{
if
(X)
{
top=t op-1
}
else
{
print"Underf
low"
}
returntop
}
Fil
lint hecondit
ionX
Op1:top< N-1
Op2:t op<n
Op3:t op>1
Op4:t op>=0
Op5:
Cor
rec
tOp:4
Ques267.A que
u eisimple
ment
eda sa(si
ngl
ylink
ed) l
ink
ed-l
is
tforeas
ya ddi
ti
ona ndde
let
ionof
el
ements.
Eachnodeha sa
ne lementandpoi
ntert
oanot
hernode
.Whi chnodewi
llpoi
nttoe mpty
/no
l
ocati
on?
Op1 :Front
Op2:Re ar
Op3:Bot h
Op4:Noneoft hes
e
Op5:
Corr
e c
tOp:2
Ques
268.A stacki simplement
eda sa(s ingl
y-l
inke
d) linke
d-li
st,wher
ee a
chnodec ont
ainsda
ta
andaddre
ssofa nothernode.Thet opnodewillcontai
nt headdressofwhi
chnode? Op1 :Nonode.
I
twillbeempty
Op2:T henodec ontai
ningthefir
ste l
ementpushedintothes t
ack.
Op3:T henodec ontai
ningtheelementwhichwa spushedjustbef
orethetopel
ement
.
Op4:Noneoft he se
Op5:
Cor
rec
tOp:3
Ques269.A qu eueisimplemente
dbyal ineararr
ayofs ize10 (andnota saci
rcular
lyconne
cte
d
arra
y).F ront
andRe a rarer e
pr e
sent
eda sa ninde
xi nt hearr
ay.T oa ddane l
ement,ther
earindexis
i
ncreme nteda nd
theeleme ntisa dded.T odelet
ea nelement,thefrontindexisinc
remente
d.Thefoll
owingoper
ati
ons
aredoneo na ne mptyqueue.
ADD 1;DEL ET E;ADD 2;ADD 3;ADD 4;DEL ETE,DEL ETE
Aft
ert hiss e
tofope rat
ions
,wha tisthema xi
mumc apaci
t yoft
hequ eu
e?
Op1 :6
Op2:7
Op3:1 0
Op4:Noneoft hese
Op5:
Correc
tOp:2
Ques271.Jaswinde
rha sabookoft i
cke
tsandwa nt
st ost
oreti
cke
tnumbersi
nadatast
ruc
tur
e.
Newt i
cket
s
areaddedt othee ndofthebook
let
.T i
cke
ta tt
het opofthest
ackisi
ssu
edtothec
ust
omer.Whic
h
dat
a
st
ructu
reshouldJ a
s wi
nde
rusetor e
pres
enttheti
cketbook
let
?
Op1 :Queue
Op2:St ack
Op3:Ar r
ay
Op4:Gr a
ph
Op5:
Corr
e c
tOp:1