By: Prof. Dr. Fazal Rehman | Last updated: September 23, 2024
MCQs on Indexing (B-trees, Hash Indexing) in DBMS
What is the primary purpose of using B-trees in indexing?A. To store data sequentially
B. To maintain sorted data and allow searches, insertions, deletions in logarithmic time
C. To provide direct access to records
D. To minimize disk space usage
Answer: B. To maintain sorted data and allow searches, insertions, deletions in logarithmic time
In a B-tree of order m, what is the maximum number of children a node can have?A. m-1
B. m
C. m+1
D. 2m
Answer: B. m
Which property is unique to B+ trees compared to B-trees?A. All values are stored at leaf nodes and internal nodes store only keys
B. Values can be stored at both internal and leaf nodes
C. Nodes can have a variable number of children
D. Leaf nodes are linked together to form a linked list
Answer: A. All values are stored at leaf nodes and internal nodes store only keys
What is a major advantage of using a B+ tree over a B-tree for indexing?A. Faster insertions and deletions
B. Sequential access to records is easier
C. Better handling of duplicate keys
D. Requires less memory
Answer: B. Sequential access to records is easier
In a hash index, what is the purpose of a hash function?A. To sort the keys
B. To encrypt the data
C. To compute the address of the data record
D. To compress the data
Answer: C. To compute the address of the data record
Which of the following is a disadvantage of hash indexing?A. Inefficient for range queries
B. Slow search performance
C. High memory usage
D. Complexity in implementation
Answer: A. Inefficient for range queries
In B-trees, what happens when a node becomes full and a new key is inserted?A. The node is split into two nodes
B. The new key is discarded
C. The tree is rebalanced
D. The node is expanded to accommodate the new key
Answer: A. The node is split into two nodes
What is the height of a B-tree with ‘n’ keys and minimum degree ‘t’?A. log_t(n)
B. log_t(n+1)
C. log_t((n+1)/2)
D. log_t((n-1)/2)
Answer: C. log_t((n+1)/2)
Which type of index is more efficient for exact-match queries?A. B-tree index
B. B+ tree index
C. Hash index
D. Dense index
Answer: C. Hash index
How does a B+ tree handle insertions when the leaf node is full?A. By creating a new tree
B. By splitting the leaf node and adjusting the parent node
C. By shifting the existing keys
D. By merging with an adjacent node
Answer: B. By splitting the leaf node and adjusting the parent node
In a hash table, what is a ‘collision’?A. When two keys generate the same hash value
B. When a key is not found
C. When the table is resized
D. When a key is deleted
Answer: A. When two keys generate the same hash value
Which of the following statements is true about B+ trees?A. They allow binary search
B. They do not maintain sorted order
C. They have all data at the leaf level
D. They do not support sequential access
Answer: C. They have all data at the leaf level
What is ‘rehashing’ in the context of hash indexing?A. Computing a new hash value for an existing key
B. Removing a key from the hash table
C. Increasing the size of the hash table and redistributing the keys
D. Sorting the keys in the hash table
Answer: C. Increasing the size of the hash table and redistributing the keys
In a B-tree, what is the minimum number of keys a node (except root) can have if the order is ‘m’?A. m-1
B. m/2
C. (m/2) – 1
D. (m/2) + 1
Answer: C. (m/2) – 1
Which type of index is generally preferred for large databases with frequent insertions and deletions?A. B-tree index
B. B+ tree index
C. Hash index
D. Bitmap index
Answer: B. B+ tree index