Finding Minimum Key and Predecessor in B-Tree

user2558869 picture user2558869 · Jul 8, 2013 · Viewed 7.5k times · Source

Explain how to find the minimum key stored in a B-tree and how to find the predecessor of a given key stored in a B-tree.

Answer

SRF picture SRF · Jul 8, 2013

To Find Minimum Key

  • Go to leftmost children recursively until you find NULL

To find the predecessor

  • First find the given element, by recursively traversing the tree top to bottom
  • Then there are two cases

  • If that element have left children, find the largest in that sub-tree rooted at that left children

  • If that element haven't left children, you have to go upward