GATE 2010
82 questions
MCQ 821-mark 39 · 2-mark 43
Questions 31–35 of 82
Consider a B+-tree in which the maximum number of keys in a node is 5. What is the minimum number of keys in any non-root node?
Answer: (B)
The node can hold at most 5 keys so the most children it can have (the order) is 6.
Any non-root node needs at least children. So the least number of keys is 3 1 = 2.
Answer: 2
Any non-root node needs at least children. So the least number of keys is 3 1 = 2.
Answer: 2
A hash table of length 10 uses open addressing with hash function h(k)=k mod 10, and linear probing. After inserting 6 values into an empty hash table, the table is as shown below
How many different insertion sequences of the key values using the same hash function and linear probing will result in the hash table shown above?
How many different insertion sequences of the key values using the same hash function and linear probing will result in the hash table shown above?
Answer: (C)
Checking each key:
- 42, 23, 34 and 46 sit in their home slots.
- 52 (home 2) landed in slot 5, so 42, 23, 34 come before it.
- 33 (home 3) landed in slot 7, so it is last.
Keys 42, 23, 34 can go in any order, then 52: 3! = 6 ways. Place 46 in any of 5 positions: 5 ways.
6 5 = 30
Answer: 30
- 42, 23, 34 and 46 sit in their home slots.
- 52 (home 2) landed in slot 5, so 42, 23, 34 come before it.
- 33 (home 3) landed in slot 7, so it is last.
Keys 42, 23, 34 can go in any order, then 52: 3! = 6 ways. Place 46 in any of 5 positions: 5 ways.
6 5 = 30
Answer: 30
A hash table of length 10 uses open addressing with hash function h(k)=k mod 10, and linear probing. After inserting 6 values into an empty hash table, the table is as shown below
Which one of the following choices gives a possible order in which the key values could have been inserted in the table?
Which one of the following choices gives a possible order in which the key values could have been inserted in the table?
Answer: (C)
Check the order 46, 34, 42, 23, 52, 33:
- 46 6, 34 4, 42 2, 23 3
- 52: slots 2, 3, 4 are full, so 5
- 33: slots 3, 4, 5, 6 are full, so 7
This gives the table shown. (In the other options, 52 or 33 ends up in a wrong slot.)
Answer: 46, 34, 42, 23, 52, 33
- 46 6, 34 4, 42 2, 23 3
- 52: slots 2, 3, 4 are full, so 5
- 33: slots 3, 4, 5, 6 are full, so 7
This gives the table shown. (In the other options, 52 or 33 ends up in a wrong slot.)
Answer: 46, 34, 42, 23, 52, 33
Two alternative packages A and B are available for processing a database having records. Package A requires 0.0001 time units and package B requires time units to process n records. What is the smallest value of k for which package B will be preferred over A?
Answer: (C)
Package B is better when .
Put . This gives: .
- k = 5: is ? No
- k = 6: is ? Yes
Answer: 6
Put . This gives: .
- k = 5: is ? No
- k = 6: is ? Yes
Answer: 6
The weight of a sequence of real numbers is defined as A subsequence of a sequence is obtained by deleting some elements from the sequence, keeping the order of the remaining elements the same. Let X denote the maximum possible weight of a subsequence of and Y the maximum possible weight of a subsequence of . Then X is equal to
Answer: (B)
Y is the maximum weight of a subsequence of , that is, the sequence without .
A subsequence of either leaves out or keeps it.
Leaves out : it is a subsequence of with the same weights as in Y (there is the first element and has weight 1). The best value is Y.
Keeps : is first, so it adds . Every other chosen element sits one place further along than it would in a subsequence of , so its weight is halved. If those chosen elements have weight w on their own, the total is . This is largest when w is largest, that is , so the best value is .
X is the larger of the two cases: .
Answer: (B)
A subsequence of either leaves out or keeps it.
Leaves out : it is a subsequence of with the same weights as in Y (there is the first element and has weight 1). The best value is Y.
Keeps : is first, so it adds . Every other chosen element sits one place further along than it would in a subsequence of , so its weight is halved. If those chosen elements have weight w on their own, the total is . This is largest when w is largest, that is , so the best value is .
X is the larger of the two cases: .
Answer: (B)