mis 3500 * exercise: creating b+tree (updated 2014)

1
MIS 3500 * Exercise: Creating B+Tree (Updated 2015) ee can be designed in different ways, depending on what values are stored in nodes. tree is nearly balanced in relation to the root. dle path between edge values at a node (above, values between 8442 and 8777) can have different opera w the edge paths are designed. ts: lues must appear at the leaf level, and all leaves are on the same level. starts at the root level, and moves through nodes to leaves. Some leaf values are repeated in nodes. can be empty slots on the leaf level ready to receive new data. e the set of values below to design a B+ tree with m=3 (i.e., the max number of values per node is 3 number of values is 2. Use the example below for modeling the bigger, equal and smaller than operato 8442 -- 8556 7368 – 8442 7547- 8556 8777 -- 9114 < <= < <= 1038 1164 23143678 41645931 6104 9114 7368 7547 8442 8556 8777 Example: A procedure for creating a B+-tree: 1.Line up all key values at the leaf level in increasing order. 2.Specify “triplets” and/or pairs of key values (as shown here). 3.To get a balanced tree, set the root value (a single number on the top of the tree) should be around the mid-point of the key values set. This will determine which values will be on the left and which on the right side of the tree. 4.Move up to the first node level above the leaves and specify a range (e.g., 8442--8777 in the example below) or a single value at the node, while respecting the relational operators (e.g., values down the left side of the 8442--8777 node must be either equal or smaller than 8442). 5. Repeat step 4 until your reach the root. Leaf values:

Upload: armand-gutierrez

Post on 31-Dec-2015

23 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: MIS 3500   *   Exercise: Creating B+Tree  (Updated 2014)

MIS 3500 * Exercise: Creating B+Tree (Updated 2015)

- The tree can be designed in different ways, depending on what values are stored in nodes. - A good tree is nearly balanced in relation to the root. - The middle path between edge values at a node (above, values between 8442 and 8777) can have different operators, depending on how the edge paths are designed.

Some hints:- All values must appear at the leaf level, and all leaves are on the same level.- Search starts at the root level, and moves through nodes to leaves. Some leaf values are repeated in nodes.- There can be empty slots on the leaf level ready to receive new data.

Task: Use the set of values below to design a B+ tree with m=3 (i.e., the max number of values per node is 3, andthe min. number of values is 2. Use the example below for modeling the bigger, equal and smaller than operators.

8442 -- 8556

7368 – 8442 7547- 8556 8777 -- 9114

<<= < <=

1038 11642314 3678 4164 5931 61049114 7368 7547 8442 8556 8777

Example:

A procedure for creating a B+-tree:1.Line up all key values at the leaf level in increasing order.2.Specify “triplets” and/or pairs of key values (as shown here).3.To get a balanced tree, set the root value (a single number on the top of the tree) should be around the mid-point of the

key values set. This will determine which values will be on the left and which on the right side of the tree. 4.Move up to the first node level above the leaves and specify a range (e.g., 8442--8777 in the example below) or a single

value at the node, while respecting the relational operators (e.g., values down the left side of the 8442--8777 node must be either equal or smaller than 8442).

5. Repeat step 4 until your reach the root.

Leaf values: