GATE 2005
203 questions
MCQ 2031-mark 203
Questions 171–175 of 203
In a computer system, four files of size 11050 bytes, 4990 bytes, 5170 bytes and 12640 bytes need to be stored. For storing these files on disk, we can use either 100 byte disk blocks or 200 byte disk blocks (but can't mix block sizes). For each block used to store a file, 4 bytes of bookkeeping information also needs to be stored on the disk. Thus, the total space used to store a file is the sum of the space taken to store the file and the space taken to store the book keeping information for the blocks allocated for storing the file. A disk block can store either bookkeeping information for a file or data from a file, but not both. What is the total space required for storing the files using 100 byte disk blocks and 200 byte disk blocks respectively?
Answer: (C)
For each file, count the data blocks (rounded up), then the blocks needed for the 4-byte bookkeeping entries (one per data block, rounded up). Bookkeeping blocks are separate from data blocks.
100-byte blocks (each block holds 25 bookkeeping entries):
- 11050 bytes: 111 data blocks, 444 bytes of bookkeeping gives 5 blocks, total 116
- 4990 bytes: 50 data blocks, 200 bytes gives 2 blocks, total 52
- 5170 bytes: 52 data blocks, 208 bytes gives 3 blocks, total 55
- 12640 bytes: 127 data blocks, 508 bytes gives 6 blocks, total 133
Blocks = 116 + 52 + 55 + 133 = 356, so space = 356 100 = 35600 bytes.
200-byte blocks (each block holds 50 bookkeeping entries):
- 11050 bytes: 56 data blocks, 224 bytes gives 2 blocks, total 58
- 4990 bytes: 25 data blocks, 100 bytes gives 1 block, total 26
- 5170 bytes: 26 data blocks, 104 bytes gives 1 block, total 27
- 12640 bytes: 64 data blocks, 256 bytes gives 2 blocks, total 66
Blocks = 58 + 26 + 27 + 66 = 177, so space = 177 200 = 35400 bytes.
Answer: (C)
100-byte blocks (each block holds 25 bookkeeping entries):
- 11050 bytes: 111 data blocks, 444 bytes of bookkeeping gives 5 blocks, total 116
- 4990 bytes: 50 data blocks, 200 bytes gives 2 blocks, total 52
- 5170 bytes: 52 data blocks, 208 bytes gives 3 blocks, total 55
- 12640 bytes: 127 data blocks, 508 bytes gives 6 blocks, total 133
Blocks = 116 + 52 + 55 + 133 = 356, so space = 356 100 = 35600 bytes.
200-byte blocks (each block holds 50 bookkeeping entries):
- 11050 bytes: 56 data blocks, 224 bytes gives 2 blocks, total 58
- 4990 bytes: 25 data blocks, 100 bytes gives 1 block, total 26
- 5170 bytes: 26 data blocks, 104 bytes gives 1 block, total 27
- 12640 bytes: 64 data blocks, 256 bytes gives 2 blocks, total 66
Blocks = 58 + 26 + 27 + 66 = 177, so space = 177 200 = 35400 bytes.
Answer: (C)
A B-Tree used as an index for a large database table has four levels including the root node. If a new key is inserted in this index, then the maximum number of nodes that could be newly created in the process are
Answer: (A)
Worst case: the new key splits the leaf and every node above it on the path to the root. With 4 levels, the splits make 4 new nodes. The root also splits, so one more new root is made. Total is 5.
Answer: 5
Answer: 5
Which one of the following is a key factor for preferring - trees to binary search trees for indexing database relations?
Answer: (D)
A disk is read and written in blocks, and one disk access is very slow compared with memory. A B+ tree node is made as big as one disk block, so it holds hundreds of keys and has a very high fanout. The tree is then very shallow, and a search needs only a few block reads. A binary search tree has two children per node, so it is much deeper and would need many block reads. So the key factor is (D).
(A) A large number of records matters only because the data sits on disk, so it is not the deciding reason. (B) Sorting on the primary key does not separate the two: a binary search tree is also ordered by key. (C) A B+ tree does not need less memory; it also stores keys in internal nodes and its nodes are often not full.
Answer: (D)
(A) A large number of records matters only because the data sits on disk, so it is not the deciding reason. (B) Sorting on the primary key does not separate the two: a binary search tree is also ordered by key. (C) A B+ tree does not need less memory; it also stores keys in internal nodes and its nodes are often not full.
Answer: (D)
A company maintains records of sales made by its salespersons and pays them commission based on each individual's total sales made in a year. This data is maintained in a table with following schema:
salesinfo = (salespersonid, totalsales, commission)
In a certain year, due to better business results, the company decides to further reward its salespersons by enhancing the commission paid to them as per the following formula:
If commission , enhance it by 2%
If 50000 < commission , enhance it by 4%
If commission > 100000, enhance it by 6%
The IT staff has written three different SQL scripts to calculate enhancement for each slab, each of these scripts is to run as a separate transaction as follows:
T1
T2
T3
Which of the following options of running these transactions will update the commission of all salespersons correctly
salesinfo = (salespersonid, totalsales, commission)
In a certain year, due to better business results, the company decides to further reward its salespersons by enhancing the commission paid to them as per the following formula:
If commission , enhance it by 2%
If 50000 < commission , enhance it by 4%
If commission > 100000, enhance it by 6%
The IT staff has written three different SQL scripts to calculate enhancement for each slab, each of these scripts is to run as a separate transaction as follows:
T1
Update salesinfo
Set commission = commission * 1.02
Where commission < = 50000; T2
Update salesinfo
Set commission = commission * 1.04
Where commission > 50000 and commission is < = 100000; T3
Update salesinfo
Set commission = commission * 1.06
Where commission > 100000; Which of the following options of running these transactions will update the commission of all salespersons correctly
Answer: (D)
The right order is , then , then : the highest slab goes first. A raise moves a commission up, and it may cross into a higher slab. If that higher slab's transaction has already run, nobody raises the commission a second time. So each person gets exactly one raise.
In the other options, some people get the raise two times.
(A) then then : say the starting commission is . This is in the slab , so . Now it is in the second slab, so gives . The person gets two raises, but should get only one.
(B) and (C): runs at the same time as the others, so it may run before has done its update. Then the case above happens again. In (B) there is a second problem: followed by can raise to , which then raises again.
Answer: (D)
In the other options, some people get the raise two times.
(A) then then : say the starting commission is . This is in the slab , so . Now it is in the second slab, so gives . The person gets two raises, but should get only one.
(B) and (C): runs at the same time as the others, so it may run before has done its update. Then the case above happens again. In (B) there is a second problem: followed by can raise to , which then raises again.
Answer: (D)
Amongst the ACID properties of a transaction, the 'Durability' property requires that the changes made to the database by a successful transaction persist
Answer: (D)
Durability says that once a transaction has committed, its changes must stay in the database whatever kind of failure happens later: an operating system crash, a disk crash or a power failure.
Say we book a ticket months ahead on IRCTC, and the transaction succeeds. Later, when we come to board the train, they say that a system, disk or power crash has lost our seat information, so we are not allowed on the seat. This is a serious problem. So the result must persist after every kind of failure, and options (A), (B) and (C), which allow an exception, are wrong.
Answer: (D)
Say we book a ticket months ahead on IRCTC, and the transaction succeeds. Later, when we come to board the train, they say that a system, disk or power crash has lost our seat information, so we are not allowed on the seat. This is a serious problem. So the result must persist after every kind of failure, and options (A), (B) and (C), which allow an exception, are wrong.
Answer: (D)