GATE / CS ARCHIVE

GATE CSE 2011 / QUESTION 32

Generated SQL table recurrence

Database Management Systems · SQL & Queries · Full GATE CSE 2011 paper

GATE 2011, Q32 2 marks · MCQ
Report issue

SQL & Queries

Question 32, GATE 2011: Table T has integer columns X,Y and starts with (1,1). Let MX and MY be their current respective maxima. Perform 128 additional inserts of (MX+1,2*MY+1), recomputing maxima after each insert. What does SELECT Y FROM T WHERE X=7 return?

(A) 127
(B) 255
(C) 129
(D) 257
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Our answer: A under successful mathematical-integer insertions

The rows obey X=k and Y=2k−1 by induction from(1, 1): the next maximum Y is doubled and increased by 1. Hence the row X=7 has Y=127, A. Completing all 128 additional inserts would require representing 2129−1 in the final row, beyond common fixed-width SQL INTEGER types. The problem’s statement that all inserts occur therefore assumes sufficiently large integers or an abstract unbounded-integer model; the requested early row itself is representable.

The early rows make the indexing clear: (1,1),(2,3),(3,7),(4,15),(5,31),(6,63),(7,127). Since X increases strictly, there is exactly one row with X=7. For a formal recurrence, set Z=Y+1; then Z doubles at each step, with Z=2 initially, so at X=k it equals 2k. The query is not asking for the final maximum after all 128 inserts; that confusion produces inappropriate much larger powers.

Original paper, page 9 · Answer key