CSE 140 Questions and
Answers Updated 2026
for(iB=B0;BiB<B100;Bi++)
{
sum+=A[i];
}
$s0B=B&A
$v0B=BsumB-BAnswerBaddB$t0,B$t0,B$zeroB#letBiB=B0
addiB$t1,B$zero,B100B#tempB=B100
LOOP:BlwB$t3,B0($s0)B#temp1B=BA[i]
addB$v0,B$v0,B$t3B#sumB+=Btemp1
addiB$s0,B$s0,B4B#addrBofBA[i+1]
addiB$t0,B$t0,B1B#iB=Bi+1
bneB$t1,B$t0,BLOOPB#ifBiB<B100
ToBimplementBtheBfollowingBCBcode,BwhatBareBthe
instructionsBthatBweBshouldBputBinBtheBbox?
for(iB=B0;BiB<B100;Bi++)
A[i]B=Bi;
addB$t0,B$zero,B$zero
addiB$t1,B$zero,B100
LOOP:B??
??
addiB$t0,B$t0,B1
,beqB$t0,B$t1,BLOOPB-BAnswerBswB$t0,B0($s2)
addiB$s2,B$s2,B4
WhichBofBtheBfollowingBisBNOTBcorrectBaboutBtheseBtwo
ISAs?
A.Bx86BprovidesBmoreBinstructionsBthanBMIPS
B.Bx86BusuallyBneedsBmoreBinstructionsBtoBexpressBaBprogram
C.BAnBx86BinstructionBmayBaccessBmemoryBforB3Btimes
D.BAnBx86BinstructionBmayBbeBshorterBthanBaBMIPSBinstruction
E.BAnBx86BinstructionBmayBbeBlongerBthanBaBMIPSBinstructionB-
BAnswerBB.Bx86BusuallyBneedsBmoreBinstructionsBtoBexpressBaBprogram
AssumeBthatBweBhaveBanBapplicationBcomposedBwithBaBtotalBofB500000
instructions,BinBwhichB20%BofBthemBareBtheBload/storeBinstructionsBwithBan
averageBCPIBofB6Bcycles,BandBtheBrestBinstructionsBareBintegerBinstructions
withBaverageBCPIBofB1Bcycle.BIfBtheBprocessorBrunsBatB1GHz,BhowBlongBis
theBexecutionBtime?
A.B500000Bns
B.B1000000Bns
C.B1750000Bns
D.B3500000Bns
E.BNoneBofBtheBabove
500000B-BAnswerBB.B1000000Bns
500000B*B(0.8*1+0.2*6)B*B1BnsB=B1000000Bns
http://cseweb.ucsd.edu/classes/su12/cse141-a/slides/Performance_20120809.pdf
, •BAssumeBthatBweBhaveBanBapplicationBcomposedBwithBaBtotalBofB500000
instructions,BinBwhichB20%BofBthemBareBtheBload/storeBinstructionsBwith
anBaverageBCPIBofB6Bcycles,BandBtheBrestBinstructionsBareBinteger
instructionsBwithBaverageBCPIBofB1Bcycle.
•BIfBweBdoubleBtheBclockBrateBtoBbeB2GHzBwithoutBimproveBthe
memoryBlatency,BtheBaverageBCPIBforBload/storeBinstructionBwillBalso
beBdoubledBtoB12Bcycles.BWhat'sBtheBperformanceBimprovementBafter
thisBchange?
A.BNoBchange
B.B1.25
C.B1.5
D.B2
E.BNoneBofBtheBaboveB-BAnswerBB.B1.25
ETnewB=B500000B*B(0.8*1+0.2*12)B*B0.5BnsB=B800000Bns
SpeedupB=BETold/ETnew=1000000/800000B=B1.25
http://cseweb.ucsd.edu/classes/su12/cse141-a/slides/Performance_20120809.pdf
WhyBdoesBanBIntelBCoreBi7B@B2.8BGHzBusually
performBbetterBthanBanBIntelBCoreB2BExtremeB@B3.2
GHzBorBAMDBPhenomBIIBX4@3.4GHz?
A.BBecauseBtheBinstructionBcountBofBtheBprogramBareBdifferent
B.BBecauseBtheBclockBrateBofBPhenomBIIBisBhigher
C.BBecauseBtheBCPIBofBCoreBi7BisBbetter
D.BBecauseBtheBclockBrateBofBPhenomBIIBisBhigherBandBCPIBofBCoreBi7BisBbetter
E.BNoneBofBtheBaboveB-BAnswerBC.BBecauseBtheBCPIBofBCoreBi7BisBbetter
Answers Updated 2026
for(iB=B0;BiB<B100;Bi++)
{
sum+=A[i];
}
$s0B=B&A
$v0B=BsumB-BAnswerBaddB$t0,B$t0,B$zeroB#letBiB=B0
addiB$t1,B$zero,B100B#tempB=B100
LOOP:BlwB$t3,B0($s0)B#temp1B=BA[i]
addB$v0,B$v0,B$t3B#sumB+=Btemp1
addiB$s0,B$s0,B4B#addrBofBA[i+1]
addiB$t0,B$t0,B1B#iB=Bi+1
bneB$t1,B$t0,BLOOPB#ifBiB<B100
ToBimplementBtheBfollowingBCBcode,BwhatBareBthe
instructionsBthatBweBshouldBputBinBtheBbox?
for(iB=B0;BiB<B100;Bi++)
A[i]B=Bi;
addB$t0,B$zero,B$zero
addiB$t1,B$zero,B100
LOOP:B??
??
addiB$t0,B$t0,B1
,beqB$t0,B$t1,BLOOPB-BAnswerBswB$t0,B0($s2)
addiB$s2,B$s2,B4
WhichBofBtheBfollowingBisBNOTBcorrectBaboutBtheseBtwo
ISAs?
A.Bx86BprovidesBmoreBinstructionsBthanBMIPS
B.Bx86BusuallyBneedsBmoreBinstructionsBtoBexpressBaBprogram
C.BAnBx86BinstructionBmayBaccessBmemoryBforB3Btimes
D.BAnBx86BinstructionBmayBbeBshorterBthanBaBMIPSBinstruction
E.BAnBx86BinstructionBmayBbeBlongerBthanBaBMIPSBinstructionB-
BAnswerBB.Bx86BusuallyBneedsBmoreBinstructionsBtoBexpressBaBprogram
AssumeBthatBweBhaveBanBapplicationBcomposedBwithBaBtotalBofB500000
instructions,BinBwhichB20%BofBthemBareBtheBload/storeBinstructionsBwithBan
averageBCPIBofB6Bcycles,BandBtheBrestBinstructionsBareBintegerBinstructions
withBaverageBCPIBofB1Bcycle.BIfBtheBprocessorBrunsBatB1GHz,BhowBlongBis
theBexecutionBtime?
A.B500000Bns
B.B1000000Bns
C.B1750000Bns
D.B3500000Bns
E.BNoneBofBtheBabove
500000B-BAnswerBB.B1000000Bns
500000B*B(0.8*1+0.2*6)B*B1BnsB=B1000000Bns
http://cseweb.ucsd.edu/classes/su12/cse141-a/slides/Performance_20120809.pdf
, •BAssumeBthatBweBhaveBanBapplicationBcomposedBwithBaBtotalBofB500000
instructions,BinBwhichB20%BofBthemBareBtheBload/storeBinstructionsBwith
anBaverageBCPIBofB6Bcycles,BandBtheBrestBinstructionsBareBinteger
instructionsBwithBaverageBCPIBofB1Bcycle.
•BIfBweBdoubleBtheBclockBrateBtoBbeB2GHzBwithoutBimproveBthe
memoryBlatency,BtheBaverageBCPIBforBload/storeBinstructionBwillBalso
beBdoubledBtoB12Bcycles.BWhat'sBtheBperformanceBimprovementBafter
thisBchange?
A.BNoBchange
B.B1.25
C.B1.5
D.B2
E.BNoneBofBtheBaboveB-BAnswerBB.B1.25
ETnewB=B500000B*B(0.8*1+0.2*12)B*B0.5BnsB=B800000Bns
SpeedupB=BETold/ETnew=1000000/800000B=B1.25
http://cseweb.ucsd.edu/classes/su12/cse141-a/slides/Performance_20120809.pdf
WhyBdoesBanBIntelBCoreBi7B@B2.8BGHzBusually
performBbetterBthanBanBIntelBCoreB2BExtremeB@B3.2
GHzBorBAMDBPhenomBIIBX4@3.4GHz?
A.BBecauseBtheBinstructionBcountBofBtheBprogramBareBdifferent
B.BBecauseBtheBclockBrateBofBPhenomBIIBisBhigher
C.BBecauseBtheBCPIBofBCoreBi7BisBbetter
D.BBecauseBtheBclockBrateBofBPhenomBIIBisBhigherBandBCPIBofBCoreBi7BisBbetter
E.BNoneBofBtheBaboveB-BAnswerBC.BBecauseBtheBCPIBofBCoreBi7BisBbetter