Question
Consider a database table containing two columns and each of type integer. After the creation of the table, one record is inserted in the table.
Let and denote the respective maximum values of and among all records in the table at any point in time. Using and , new records are inserted in the table 128 times with and values being , respectively. It may be noted that each time after the insertion, values of and change.
What will be the output of the following SQL query after the steps mentioned above are carried out?
SELECT Y FROM T WHERE X=7;
Official answer and solution
- Official answer
- A
- From
- Official GATE 2011 answer key
Solution
Formulate recurrences for the sequence of inserted records and compute the value of Y when X equals 7.
- The table initially contains the single record . Thus initially .
- Each subsequent insertion creates a record with and .
- Solving the recurrence with :
- :
- :
- :
- In general, for record , and .
- For the query
WHERE X = 7, we have :
A
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2011 Computer Science and Information Technology (CS)
- Question
- 32 of 65, printed as CS Q.32
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.