GATE / CS ARCHIVE

GATE CSE 2003 / QUESTION 35

Summing integer square-root increments

Algorithms · Asymptotic Analysis & Recurrences · Full GATE CSE 2003 paper

GATE 2003, Q35 2 marks · MCQ
Report issue

Asymptotic Analysis & Recurrences

Question 35, GATE 2003: Given T(1)=1, find T(m²) for integer m≥1. GFG prints T(n+1)=T(n)+floor(sqrt(n−1)), n≥1; GateForum instead prints floor(sqrt(n+1)). Preserve both versions. Options: A. (m/6)(21m−39)+4; B. (m/6)(4m²−3m+5); C. (m/2)(3m^(2.5)−11m+20)−5; D. (m/6)(5m³−34m²+137m−104)+5/6.
Question 35, GATE 2003: Given T(1)=1, find T(m²) for integer m≥1. GFG prints T(n+1)=T(n)+floor(sqrt(n−1)), n≥1; GateForum instead prints floor(sqrt(n+1)). Preserve both versions. Options: A. (m/6)(21m−39)+4; B. (m/6)(4m²−3m+5); C. (m/2)(3m^(2.5)−11m+20)−5; D. (m/6)(5m³−34m²+137m−104)+5/6.
Tap to enlarge
Your answer
Answer & solution

Answer: As printed (n−1) the value differs from the options; B holds for the n+1 recurrence (no official key was published)

1. In the block k²≤j<(k+1)² the value is k and the block length is 2k+1. Use sum k=(m−1)m/2 and sum k²=(m−1)m(2m−1)/6 to simplify. The shifted range omits the final terms m and m−1 and adds the initial 1, explaining the difference −2m+2.

2. For the latter, T(m²)=sum_(j=1)m²floor(sqrt(j)). Group j from k² through(k+1)²−1: for k<m there are 2 k+1 copies of k, followed by the final m. Hence sum_(k=1)m−1k(2 k+1)+m=m(4 m²−3 m+5)/6, option B. Literal the paper instead gives 1+sum_(j=0)m²−2floor(sqrt(j))=m(4 m²−3 m+5)/6−2 m+2, including m=1. These are not silently equated; original wording/key are needed to resolve the source discrepancy.

Original paper, page 4