GATE CSE 2023 Q54: Comparing a halving loop with a 100n loop
- Algorithms
- 2 marks
- MSQ
- No negative marking
Question
Consider functions Function_1 and Function_2 expressed in pseudocode as follows:
Function_1
while n > 1 do
for i = 1 to n do
x = x + 1;
end for
n = ⌊n/2⌋;
end while
Function_2
for i = 1 to 100 * n do
x = x + 1;
end forLet and denote the number of times the statement “” is executed in Function_1 and Function_2, respectively.
Which of the following statements is/are TRUE?
Try it: multiple select: one or more correct options
Select all correct options. No negative marking, no partial marks.
Show answer and explanation
Answer: A, D (official GATE 2023 final answer key)
Concept used: A geometric series is at most .
First step: Write and , then compare.
Full step-by-step solution
Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.
Share this question
Source: official GATE 2023 CS question paper and final answer key, organised by IIT Kanpur. Question paper · Answer key
More Algorithms PYQs
- 2026 Session 1 · Q17Solve nested recurrences T1 = 4T1(n/2) + T2, T2 = 5T2(n/4) + log n
- 2026 Session 1 · Q41Shortest paths with at most k edges: two statements
- 2026 Session 1 · Q47Condition forcing a vertex into every minimum vertex cover
- 2026 Session 1 · Q49Cycle and cut properties of MSTs with distinct weights
- 2026 Session 1 · Q50Impossible DFS discovery/finish orderings for a DAG edge
- 2026 Session 1 · Q55Properties of 2-colorable (bipartite) graphs