0
0
DBMS Theoryknowledge~20 mins

B-tree index structure in DBMS Theory - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
B-tree Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
How does a B-tree maintain balance?

In a B-tree index, what mechanism ensures that the tree remains balanced after insertions and deletions?

ABy storing all keys in a single sorted list
BBy rotating nodes left or right like in AVL trees
CBy rebuilding the entire tree after every insertion
DBy splitting or merging nodes to keep all leaf nodes at the same depth
Attempts:
2 left
💡 Hint

Think about how B-trees keep their height minimal and uniform.

query_result
intermediate
1:30remaining
Number of keys in a B-tree node

Consider a B-tree of order 4 (each node can have at most 4 children). What is the maximum number of keys a single node can hold?

A3
B4
C5
D2
Attempts:
2 left
💡 Hint

Remember, a node with n children has n-1 keys.

📋 Factual
advanced
2:30remaining
Identify the correct B-tree insertion step

Which SQL-like pseudocode correctly describes the step to split a full B-tree node during insertion?

DBMS Theory
IF node.isFull() THEN
  median = node.keys[middle_index]
  leftNode = node.keys[0 to middle_index-1]
  rightNode = node.keys[middle_index+1 to end]
  parent.insertKey(median)
  parent.insertChild(leftNode)
  parent.insertChild(rightNode)
END IF
AMerge node with sibling and push median down to child
BDelete median key and redistribute keys evenly
CSplit node into two nodes around median key and push median up to parent
DReplace node keys with median key only
Attempts:
2 left
💡 Hint

Think about how B-tree insertion handles full nodes.

optimization
advanced
2:00remaining
Choosing B-tree order for disk storage

Why is a higher order (more children per node) preferred for B-trees used in disk-based databases?

ABecause it allows storing keys in random order
BBecause it reduces the tree height and number of disk reads
CBecause it increases the number of keys per node, causing more disk reads
DBecause it makes the tree unbalanced and faster to traverse
Attempts:
2 left
💡 Hint

Consider how disk access speed affects search performance.

🔍 Analysis
expert
3:00remaining
Diagnose B-tree search failure

A B-tree search for key 42 returns no result, but the key exists in the tree. Which issue below most likely causes this problem?

AThe tree nodes are not properly linked after a node split
BThe key comparison uses <= instead of <
CThe tree height is too large
DThe root node has fewer keys than allowed
Attempts:
2 left
💡 Hint

Think about what happens if pointers between nodes are incorrect.