Consider the following pseudo code. What is the total number of multiplications to be performed? D = 2 for i = 1 to n do for j = i to n do for k = j + 1 to n do D = D * 3
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2014 Set 1 · Q42
Time
D = 2
for i = 1 to n do
for j = i to n do
for k = j + 1 to n do
D = D * 3Select one answerSingle correct
Solution
Official answer: C) One-sixth of the product of the 3 consecutive integers.
Asymptotic AnalysisTo find the total number of multiplications, count the number of times the statement D = D * 3 is executed.
The statement executes for each combination of indices such that:
For a fixed and , runs from to , which gives executions.
Summing over from to :
Now summing over from to : Let . As varies from to , takes values from down to :
Using the identity with :
Here, is the product of three consecutive integers. Thus, the total number of multiplications is one-sixth of the product of the 3 consecutive integers.
Hence, the correct option is (C).
Try the question first, then check your work.
Examiner trap
Set up a nested summation over , , and , or recognize this as choosing 3 elements with constraints.
This Asymptotic Analysis previous year question is Q42 of the GATE CSE 2014 Set 1 paper. Find more GATE CSE PYQs on Asymptotic Analysis in Algorithms, or browse all GATE CSE PYQs.
Free diagnostic
Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Asymptotic Analysis PYQs now with no account.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
Asymptotic Analysis has 31 GATE CSE PYQs across 19 papers from 2011 to 2026. 12 of them are 2-mark MCQs like this one, and it is the only one in GATE CSE 2014 Set 1.
How GATE tests Asymptotic AnalysisIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.