Bucket structure is used only if search key is not a

Info icon This preview shows pages 42–44. Sign up to view the full content.

View Full Document Right Arrow Icon
Bucket structure is used only if search key is not a primary key, and file is not sorted in search key order. head2right Pointer P n ( n th pointer in the leaf node) is used to chain leaf nodes together in linear order (search key order). This allows efficient sequential processing of the file. head2right Each leaf has between ( n – 1) / 2 and n – 1 values. The ranges of values in each leaf do not overlap. head2right If the B + -tree index is to be a dense index, every search key value must appear in some leaf node. Non-leaf nodes head2right Non-leaf nodes form a multilevel sparse index on leaf nodes. The structure of the non-leaf nodes is same as that of leaf nodes, except that all pointers are pointing to tree nodes. head2right Each non-leaf node in the tree has between n / 2 and n pointers , where n is fixed for a particular tree. The number of pointers in a node is called the fan-out of the node. Root node Unlike other nonleaf nodes, the root node can hold fewer than n / 2 pointers ; however, it must hold at least two pointers, unless the tree consists of only one node. Operations on a B + Tree The figure beside shows a B + tree. As the example illustrates, this tree does not have a full index page (we have room for one more key and pointer in the root page). In addition, one of the data pages contains empty slots. The key-value determines a record’s placement in a B + tree. The leaf pages are maintained in sequential order and a linked list (not shown) connects each leaf page with its sibling page(s). This linked list speeds data movement as the pages grow and contract. Adding Records to a B + Tree We must consider three scenarios when we add a record to a B+ tree. Each scenario causes a different action in the insert algorithm. The scenarios are: Figure: B+ tree structure with n = 3. Note that no bucket structure is used as the search-key is a primary key and the file is sorted in the search-key order. P n - 1 K n - 1 P n P 1 K 1 P 2 Figure: Typical node of a B + tree.
Image of page 42

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
39 Leaf Page Full Index Page Full Action NO YES / NO Place the record in sorted position in the appropriate leaf page. YES NO 1. Split the leaf page. 2. Place Middle Key in the index page in sorted order. 3. Left leaf page contains records with keys below the middle key. 4. Right leaf page contains records with keys equal to or greater than the middle key. YES YES 1. Split the leaf page. 2. Records with keys < middle key go to the left leaf page. 3. Records with keys >= middle key go to the right leaf page. 4. Split the index page. 5. Keys < middle key go to the left index page. 6. Keys > middle key go to the right index page. 7. The middle key goes to the next (higher level) index. If the next level index page is full, continue splitting the index pages. Illustrations of the insert algorithm Adding a record when the leaf page is not full We’re going to insert a record with a key value of 28 into the B + tree. The following figure shows the result of this addition.
Image of page 43
Image of page 44
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern