Adding a record when the leaf page is full but the

Info icon This preview shows pages 43–46. Sign up to view the full content.

View Full Document Right Arrow Icon
Adding a record when the leaf page is full but the index page is not Now, we’re going to insert another record with a key value of 70 into our B+ tree. This record should go in the leaf page containing 50, 55, 60, and 65. Unfortunately, this page is full. This means that we must split the page as follows: Left Leaf Page Right Leaf Page 50 55 60 65 70 The middle key of 60 is placed in the index page between 50 and 75. The following table shows the B + tree after the addition of 70. Adding a record when both the leaf page and the index page are full As our last example, we’re going to add another record containing a key value of 95 to our B + tree. This record belongs in the page containing 75, 80, 85, and 90. Since this page is full we split it into two pages: Left Leaf Page Right Leaf Page 75 80 85 90 95 The middle key, 85, rises to the index page. Unfortunately, the index page is also full, so we split the index page: Left Index Page Right Index Page New Index Page 25 50 75 85 60
Image of page 43

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

View Full Document Right Arrow Icon
40 The following figure illustrates the addition of the record containing 95 to the B+ tree. Deleting records from a B + Tree We must consider three scenarios when we delete a record from a B + tree. Each scenario causes a different action in the delete algorithm. The scenarios are: Leaf Page Below Fill Factor Index Page Below Fill Factor Action NO NO Delete the record from the leaf page. Arrange keys in ascending order to fill void. If the key of the deleted record appears in the index page, use the next key to replace it. YES NO Combine the leaf page and its sibling. Change the index page to reflect the change. YES YES 1. Combine the leaf page and its sibling. 2. Adjust the index page to reflect the change. 3. Combine the index page with its sibling. Continue combining index pages until you reach a page with the correct fill factor or you reach the root page. Illustrations of the delete algorithm Deleting a record that leaves the leaf page below fill factor, but not the index page We begin by deleting the record with key 70 from the B + tree. This record is in a leaf page containing 60, 65 and 70. This page will contain 2 records after the deletion. Since our fill factor 3 is 50% or (2 records) we simply delete 70 from the leaf node. The following figure shows the B + tree after the deletion: 3 Fill factor: The minimum number of keys that can exist in a node / page. Its value is n / 2 .
Image of page 44
41 Deleting a record that leaves none of the pages below fill factor Next, we delete the record containing 25 from the B+ tree. This record is found in the leaf node containing 25, 28, and 30. The fill factor will be 50% after the deletion; however, 25 appears in the index page. Thus, when we delete 25 we must replace it with 28 in the index page. The following figure shows the B + tree after this deletion: Deleting a record that leaves both of the pages below fill factor As our last example, we’re going to delete 60 from the B+ tree. This deletion is interesting for several reasons: 1. The leaf page containing 60 (60 65) will be below the fill factor after the deletion. Thus, we must combine leaf pages.
Image of page 45

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

View Full Document Right Arrow Icon
Image of page 46
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