Docsity

Comparison of B-Trees, AVL Trees, Red-Black Trees, and m-Way Search Trees, Slides of Computer Science

Toggle sidebar
bg1
1
B-Trees
•Large degree B-trees used to represent very large
dictionaries that reside on disk.
•Smaller degree B-trees used for internal-memory
dictionaries to overcome cache-miss penalties.
AVL Trees
•n = 230 = 109(approx).
•30 <= height <= 43.
•When the AVL tree resides on a disk, up to
43 disk access are made for a search.
•This takes up to (approx) 4seconds.
•Not acceptable.
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Comparison of B-Trees, AVL Trees, Red-Black Trees, and m-Way Search Trees and more Slides Computer Science in PDF only on Docsity!

B-Trees

  • Large degree B-trees used to represent very largedictionaries that reside on disk.
  • Smaller degree B-trees used for internal-memorydictionaries to overcome cache-miss penalties.

AVL Trees

• n = 2^30 = 10^9 (approx).

• 30 <= height <= 43.

• When the AVL tree resides on a disk, up to 43 disk access are made for a search.

• This takes up to (approx) 4 seconds.

• Not acceptable.

Red-Black Trees

• n = 2^30 = 10^9 (approx).

• 30 <= height <= 60.

• When the red-black tree resides on a disk,up to 60 disk access are made for a search.

• This takes up to (approx) 6 seconds.

• Not acceptable.

m-way Search Trees

• Each node has up to m – 1 pairs and m children.

• m = 2 => binary search tree.

Capacity Of m-Way Search Tree

h = 3 m = 2 7 m = 2008 * 10^6 - 1

h = 5 31 3.2 * 10^11 - 1

h = 7 127 1.28 * 10^16 - 1

Definition Of B-Tree

• Definition assumes external nodes(extended m-way search tree).

• B-tree of order m.

ƒ ƒ mNot empty-way search tree. => root has at least 2 children.

ƒ Remaining internal nodes (if any) have at least ceil(m/2) children.

ƒ External (or failure) nodes on same level.

2-3 And 2-3-4 Trees

• B-tree of order ƒ m-way search tree. m.

ƒ ƒ Not emptyRemaining internal nodes (if any) have at least => root has at least 2 children.

ƒ ceil(m/2)External (or failure) nodes on same level.^ children.

• 2-3 tree is B-tree of order 3.

• 2-3-4 tree is B-tree of order 4.

B-Trees Of Order 5 And 2

• B-tree of order ƒ m-way search tree. m.

ƒ Not empty => root has at least 2 children.

ƒ Remaining internal nodes (if any) have at least ceil(m/2) children.

ƒ External (or failure) nodes on same level.

• B-tree of order 2 -node though). 5 is 3-4-5 tree (root may be

• B-tree of order 2 is full binary tree.

Choice Of m

• Worst-case search time. ƒ (time to fetch a node + time to search node) * height

ƒ (a + b*m + c * log where a, b and c are constants. 2 m) * h

m

searchtime

Insert

splitting pass.^ Insertion into a full leaf triggers bottom-up node

Split An Overfull Node

• ai is a pointer to a subtree.

• pi is a dictionary pair.

m a 0 p 1 a 1 p 2 a 2 … pm am

ceil(m/2)-1 a 0 p 1 a 1 p 2 a 2 … pceil(m/2)-1 aceil(m/2)-

m-ceil(m/2) aceil(m/2) pceil(m/2)+1 aceil(m/2)+1 … pm am

• pparent.ceil(m/2) plus pointer to new node is inserted in

Insert

  • Insert a pair with key = 2.
  • New pair goes into a 3 -node.

Insert

  • Insert a pair with key = 2 plus a pointer into parent.

Insert

  • Now, insert a pair with key = 18.

Insert Into A Leaf 3-node

• Insert new pair so that theascending order. 3 keys are in

• Split the overflowed node.

• Insert middle key and pointer to new nodeinto parent.

Insert

  • Insert a pair with key = 18.

Insert

  • Now, insert a pair with key = 7.

Insert

  • Insert a pair with key = 6 plus a pointer into parent.

Insert

  • Insert a pair with key = 4 plus a pointer into parent.

Insert

  • Insert a pair with key = 8 plus a pointer into parent.
  • There is no parent. So, create a new root.