b_book1.gif (162 bytes)Data - Structures (Tree)

B+-tree

dadstr04.gif (5531 bytes)

Finding a record in a B+-tree

dadstrf1.gif (5019 bytes)

  1. Label the pointers from 0-N
  2. Is the key you want smaller than the first key?
    YES - follow pointer 0
    NO - go to 3.
  3. Is the key >= (greater than or equal) the first key but smaller than the second
    YES - follow pointer 1
    NO - follow the next highest pointer
Inserting a record in a B+-tree
  1. Find a place to insert. (Use the find algorithm above).
  2. If there is room put the record in and stop.
  3. If there isn't room, make a new leaf.
    Split the records in the overcrowded leaf into equal parts. If an odd number, put the extra on the RHS. Use the smallest key value of the RH leaf as a new parent in the higher level parent node.
  4. If there isn't room in the parent node, split into equal parts and bump the middle value up one level.

[Rev 14/03/99] 14/3/99 © 1999 V/2-Com (Verhaart), P O Box 8415, Havelock North, New Zealand.