The GATE Grind

GATE 2011 CS (CS1) – Question 42

Databases · Relational Model: Relational Algebra, Tuple Calculus, SQL · 2 marks · Multiple choice

An integer table T(X,Y) initially contains (1,1). Let MX,MY be current maxima of its columns. Insert (MX+1,2MY+1), recomputing maxima each time, 128 times. What does SELECT Y FROM T WHERE X=7 return?

  1. 127
  2. 255
  3. 129
  4. 257

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (A) 127

Explanation

New rows have X=2,3,… and their Y values satisfy Yₖ=2Yₖ₋₁+1 with Y₁=1. Solving gives Yₖ=2ᵏ−1. At X=7 the value is 128−1=127, A. Later inserts do not alter that existing row.

More Relational Model: Relational Algebra, Tuple Calculus, SQL questions

All Relational Model: Relational Algebra, Tuple Calculus, SQL questions →