CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed ...
-
Upload
timothy-short -
Category
Documents
-
view
212 -
download
0
Transcript of CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed ...
![Page 1: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/1.jpg)
LECTURE 39: GREEK TRAGEDY & BALANCED TREES
CSC 213 – Large Scale Programming
![Page 2: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/2.jpg)
Today’s Goals
Review a new search tree algorithm is needed What real-world problems occur with old
tree? Why does garbage collection make problem
worse? What was ideal approach? How could we
force this? Consider how to create other search
tree types Not limit nodes to 1 element & what could
happen? How to perform insertions on multi-nodes? What about withdrawal? How can we
remove data? Can this sound dirtier? And do I hear
banjos playing?
![Page 3: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/3.jpg)
Dictionary ADT
Dictionary and Map maps keys to values O(1) time with hash, but only if hash is good Can guarantee better -- O(log n) with
balanced BST Assumes data fits in memory since locality
will suck But, honestly, how big can a tree be?
![Page 4: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/4.jpg)
Dictionary ADT
Dictionary and Map maps keys to values O(1) time with hash, but only if hash is good Can guarantee better -- O(log n) with
balanced BST Assumes data fits in memory since locality
will suck But, honestly, how big can a tree be?
Library of Congress – 20 TB in text database
Amazon.com – 42 TB of combined data ChoicePoint – 250 TB of data on everyday
Americans World Data Center for Climate – 4 PB of
climate data
![Page 5: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/5.jpg)
Dictionary ADT
Dictionary and Map maps keys to values O(1) time with hash, but only if hash is good Can guarantee better -- O(log n) with
balanced BST Assumes data fits in memory since locality
will suck But, honestly, how big can a tree be?
Library of Congress – 20 TB in text database
Amazon.com – 42 TB of combined data ChoicePoint – 250 TB of data on everyday
Americans World Data Center for Climate – 4 PB of
climate data(Numbers gathered from Feb. 2007 article)
![Page 6: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/6.jpg)
Optimal Tree Partition
![Page 7: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/7.jpg)
Optimal Tree Partition
But no GC algorithm produces this!
![Page 8: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/8.jpg)
Real-World Big Search Trees
Excellent way to test roommates system
![Page 9: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/9.jpg)
Real-World Big Search Trees
Excellent way to test roommates system
![Page 10: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/10.jpg)
Real-World Big Search Trees
Excellent way to test roommates system
![Page 11: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/11.jpg)
(a,b) Trees to the Rescue!
General solution to frequent hikes to Germany Linux & MacOS to track files & directories MySQL & other databases use this to hold
all the data Found in many other places where paging
occurs Simple rules define working of any (a,b)
tree Grows upward so that all leaves found at
same level At least a children for each internal node Every internal node has at most b children
![Page 12: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/12.jpg)
What is “the BTree?”
Common multi-way tree implementation Describe B-Tree using order (“BTree of order
m”) m/2 to m children per internal node Root node can have m or fewer elements
Many variants exist to improve some failing Each variant is specialized for some niche
use Minor differences only between each
variant Will just describe most basic B-Tree during
lecture
![Page 13: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/13.jpg)
BTree Order
Select order minimizing paging when created Elements & references to kids in full node fills
page Nodes have at least m/2 elements, even at
their smallest In memory guarantees each page is at least
50% full How many pages touched by each
operation?
![Page 14: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/14.jpg)
Multi-Way Search Tree
Nodes contain multiple elements Tree grows up with leaves always at same
level Each internal node:
At least 2 children 1 fewer Entrys than children Entrys sorted from smallest to largest
11 24
2 6 8 15 27 30
![Page 15: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/15.jpg)
Multi-Way Search Tree
Children v1 v2 v3 … vd & keys k1 k2 … kd-1
Keys in subtree v1 smaller than k1
Keys in subtree vi between ki-1 and k2
Keys in subtree vd greater than kd-1
11 24
27 302 6 8 15
![Page 16: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/16.jpg)
Inorder Traversal
Visit each child, vi , before visiting Entry ei
As with BST, visits keys in increasing order
11 24
2 6 8 15 27 301 2 3 7
4 6
5 8
![Page 17: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/17.jpg)
Multi-Way Searching
Similar to BST treeSearch finding a keyfor i = 0 to numChildren – 1 doif k < e[i].getKey() then return search(child[i])if k == e[i].getKey() then return e[i]
endfor
if k > e[e.length-1].getKey() then return search(child[child.length-1])11 24
2 6 8 15 27 30
![Page 18: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/18.jpg)
Multi-Way Searching
for i = 0 to numChildren – 1 doif k < e[i].getKey() then return search(child[i])if k == e[i].getKey() then return e[i]
endfor
if k > e[e.length-1].getKey() then return search(child[child.length-1])
Example: find(8)
11 24
2 6 8 15 27 30
![Page 19: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/19.jpg)
Multi-Way Searching
for i = 0 to numChildren – 1 doif k < e[i].getKey() then return search(child[i])if k == e[i].getKey() then return e[i]
endfor
if k > e[e.length-1].getKey() then return search(child[child.length-1])
Example: find(8)
11 24
2 6 8 15 27 30
![Page 20: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/20.jpg)
Multi-Way Searching
for i = 0 to numChildren – 1 doif k < e[i].getKey() then return search(child[i])if k == e[i].getKey() then return e[i]
endfor
if k > e[e.length-1].getKey() then return search(child[child.length-1])
Example: find(8)
11 24
2 6 8 15 27 30
![Page 21: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/21.jpg)
Multi-Way Searching
for i = 0 to numChildren – 1 doif k < e[i].getKey() then return search(child[i])if k == e[i].getKey() then return e[i]
endfor
if k > e[e.length-1].getKey() then return search(child[child.length-1])
Example: find(8)
11 24
2 6 8 15 27 30
![Page 22: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/22.jpg)
Multi-Way Searching
for i = 0 to numChildren – 1 doif k < e[i].getKey() then return search(child[i])if k == e[i].getKey() then return e[i]
endfor
if k > e[e.length-1].getKey() then return search(child[child.length-1])
Example: find(8)
11 24
2 6 8 15 27 30
![Page 23: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/23.jpg)
Multi-Way Searching
for i = 0 to numChildren – 1 doif k < e[i].getKey() then return search(child[i])if k == e[i].getKey() then return e[i]
endfor
if k > e[e.length-1].getKey() then return search(child[child.length-1])
Example: find(8)
11 24
2 6 8 15 27 30
![Page 24: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/24.jpg)
Multi-Way Searching
for i = 0 to numChildren – 1 doif k < e[i].getKey() then return search(child[i])if k == e[i].getKey() then return e[i]
endfor
if k > e[e.length-1].getKey() then return search(child[child.length-1])
Example: find(8)
11 24
2 6 8 15 27 30
![Page 25: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/25.jpg)
Multi-Way Searching
for i = 0 to numChildren – 1 doif k < e[i].getKey() then return search(child[i])if k == e[i].getKey() then return e[i]
endfor
if k > e[e.length-1].getKey() then return search(child[child.length-1])
Example: find(8)
11 24
2 6 8 15 27 30
![Page 26: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/26.jpg)
Multi-Way Searching
for i = 0 to numChildren – 1 doif k < e[i].getKey() then return search(child[i])if k == e[i].getKey() then return e[i]
endfor
if k > e[e.length-1].getKey() then return search(child[child.length-1])
Example: find(8)
11 24
15 27 302 6 8
![Page 27: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/27.jpg)
(2,4) Trees
Multi-way search tree with 2 properties: Node-Size Property
Internal nodes have at most 4 children
Depth PropertyAll external nodes at same depth
Nodes are either 2-node, 3-node or 4-node Node’s number of children used as basis
for name
10 15 24
2 8 12 27 3218
![Page 28: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/28.jpg)
Insertion
Start by searching for key k Entry added to last internal node
searched Depth property preserved by enforcing this
Example: insert(30)
10 15 24
2 8 12 27 3218
![Page 29: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/29.jpg)
Insertion
Start by searching for key k Entry added to last internal node
searched Depth property preserved by enforcing this
Example: insert(30)
10 15 24
2 8 12 27 3218
![Page 30: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/30.jpg)
Insertion
Start by searching for key k Entry added to last internal node
searched Depth property preserved by enforcing this
Example: insert(30)
10 15 24
2 8 12 27 3218
![Page 31: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/31.jpg)
Insertion
Start by searching for key k Entry added to last internal node
searched Depth property preserved by enforcing this
Example: insert(30)
10 15 24
2 8 12 27 3218
![Page 32: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/32.jpg)
Insertion
Start by searching for key k Entry added to last internal node
searched Depth property preserved by enforcing this
Example: insert(30)
10 15 24
2 8 12 27 3218
![Page 33: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/33.jpg)
Insertion
Start by searching for key k Entry added to last internal node
searched Depth property preserved by enforcing this
Example: insert(30)
10 15 24
2 8 12 27 3218
![Page 34: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/34.jpg)
Insertion
Start by searching for key k Entry added to last internal node
searched Depth property preserved by enforcing this
Example: insert(30)
10 15 24
2 8 12 27 3218
![Page 35: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/35.jpg)
Insertion
Start by searching for key k Entry added to last internal node
searched Depth property preserved by enforcing this
Example: insert(30)
10 15 24
2 8 12 27 3218
![Page 36: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/36.jpg)
Insertion
Start by searching for key k Entry added to last internal node
searched Depth property preserved by enforcing this
Example: insert(30)
10 15 24
2 8 12 27 3218
![Page 37: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/37.jpg)
Insertion
Start by searching for key k Entry added to last internal node
searched Depth property preserved by enforcing this
Example: insert(30)
10 15 24
2 8 12 27 3218
![Page 38: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/38.jpg)
Insertion
Start by searching for key k Entry added to last internal node
searched Depth property preserved by enforcing this
Example: insert(30)
10 15 24
2 8 12 27 3218
![Page 39: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/39.jpg)
Insertion
Start by searching for key k Entry added to last internal node
searched Depth property preserved by enforcing this
Example: insert(30)
10 15 24
2 8 12 27 30 3218
![Page 40: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/40.jpg)
Insertion
Insertion may cause overflow! 5-node created by the insertion This would make it violate Node-Size
property
27 32 35
15 24
12 18
![Page 41: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/41.jpg)
Insertion
Insertion may cause overflow! 5-node created by the insertion This would make it violate Node-Size
property
27 30 32 35
15 24
12 18
![Page 42: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/42.jpg)
In Case Of Overflow Split Node Split 5-node into 2 new nodes
Entrys e1 e2 & children v1 v2 v3 become a 3-node 2-node created with Entry e4 & children v4 v5
15 24
12 18 27 30 32 35
![Page 43: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/43.jpg)
In Case Of Overflow Split Node Split 5-node into 2 new nodes
Entrys e1 e2 & children v1 v2 v3 become a 3-node 2-node created with Entry e4 & children v4 v5
Promote e3 to parent node If overflow occurs in root node, create new root Overflow can cascade when parent already was
4-node15 24
12 18 27 30 32 35 12 27 3018 35
15 24 32
![Page 44: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/44.jpg)
Parent Overflow
In case of cascade, repeat overflow process Works identically to when children are
external Example: insert(29)
27 32 3512 18 25
15 24 26
![Page 45: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/45.jpg)
Parent Overflow
In case of cascade, repeat overflow process Works identically to when children are
external Example: insert(29)
27 32 3512 18 25
15 24 26
![Page 46: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/46.jpg)
Parent Overflow
In case of cascade, repeat overflow process Works identically to when children are
external Example: insert(29)
27 32 3512 18 25
15 24 26
![Page 47: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/47.jpg)
Parent Overflow
In case of cascade, repeat overflow process Works identically to when children are
external Example: insert(29)
27 32 3512 18 25
15 24 26
![Page 48: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/48.jpg)
Parent Overflow
In case of cascade, repeat overflow process Works identically to when children are
external Example: insert(29)
27 29 32 3512 18 25
15 24 26
![Page 49: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/49.jpg)
Parent Overflow
In case of cascade, repeat overflow process Works identically to when children are
external Example: insert(29)
27 29 32 3512 18 25
15 24 26
![Page 50: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/50.jpg)
Parent Overflow
In case of cascade, repeat overflow process Works identically to when children are
external Example: insert(29)
27 29 32 3512 18 25
15 24 26
![Page 51: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/51.jpg)
Parent Overflow
In case of cascade, repeat overflow process Works identically to when children are
external Example: insert(29)
12 18 25
15 24 26 32
27 29 35
![Page 52: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/52.jpg)
Parent Overflow
In case of cascade, repeat overflow process Works identically to when children are
external Example: insert(29)
12 18 25
15 24 26 32
27 29 35
![Page 53: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/53.jpg)
Parent Overflow
In case of cascade, repeat overflow process Works identically to when children are
external Example: insert(29)
12 18 25
15 24
27 29 35
32
26
![Page 54: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/54.jpg)
Parent Overflow
In case of cascade, repeat overflow process Works identically to when children are
external Example: insert(29)
12 18 25
15 24
27 29 35
32
26
![Page 55: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/55.jpg)
Adding to MultiWay Tree
Leaves all at same level, so trees grow upwards Add to last internal node from initial tree
search Addition not done – check if node too
large Push 1 item up into parent and split into 2
nodes May pass problem along, so check if parent
too large Traverse until overflow stops or made new
root node
![Page 56: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/56.jpg)
Deletion
Must first find Entry to be deleted Remove Entry & an external child if it is on
leaf Example: delete(27)
10 15 24
2 8 12 18 27 32 35
![Page 57: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/57.jpg)
Deletion
Must first find Entry to be deleted Remove Entry & an external child if it is on
leaf Example: delete(27)
10 15 24
2 8 12 18 27 32 35
![Page 58: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/58.jpg)
Deletion
Must first find Entry to be deleted Remove Entry & an external child if it is on
leaf Example: delete(27)
10 15 24
2 8 12 18 27 32 35
![Page 59: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/59.jpg)
Deletion
Must first find Entry to be deleted Remove Entry & an external child if it is on
leaf Example: delete(27)
10 15 24
2 8 12 18 27 32 35
![Page 60: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/60.jpg)
Deletion
Must first find Entry to be deleted Remove Entry & an external child if it is on
leaf Example: delete(27)
10 15 24
2 8 12 18 27 32 35
![Page 61: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/61.jpg)
Deletion
Must first find Entry to be deleted Remove Entry & an external child if it is on
leaf Example: delete(27)
10 15 24
2 8 12 18 27 32 35
10 15 24
2 8 12 18 32 35
![Page 62: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/62.jpg)
Deletion
If Entry's child internal, replace with successor Go 1 to right and then go left just like with
a BST
![Page 63: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/63.jpg)
Deletion
If Entry's child internal, replace with successor Go 1 to right and then as far left as
possible; like BST Example: delete(24)
10 15 24
2 8 12 18 27 32 35
![Page 64: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/64.jpg)
Deletion
If Entry's child internal, replace with successor Go 1 to right and then go left just like with
a BST Example: delete(24)
10 15 24
2 8 12 18 27 32 35
10 15 27
2 8 12 18 32 35
![Page 65: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/65.jpg)
15
9 14
Underflow and Fusion
Entry deletion may cause underflow Node becomes 1-node Choice of solution depends on situation
Example: remove(15)
102 5 7
![Page 66: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/66.jpg)
15
9 14
Underflow and Fusion
Entry deletion may cause underflow Node becomes 1-node Choice of solution depends on situation
Example: remove(15)
102 5 7
![Page 67: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/67.jpg)
15
9 14
Underflow and Fusion
Entry deletion may cause underflow Node becomes 1-node Choice of solution depends on situation
Example: remove(15)
102 5 7
![Page 68: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/68.jpg)
Entry deletion may cause underflow Node becomes 1-node Choice of solution depends on situation
Example: remove(15)
9 14
Underflow and Fusion
102 5 7
![Page 69: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/69.jpg)
Entry deletion may cause underflow Node becomes 1-node Choice of solution depends on situation
Example: remove(15)
9 14
Underflow and Fusion
102 5 7
![Page 70: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/70.jpg)
Case 1: Transfer
Has adjacent 3- or 4-node sibling Steal parent’s Entry closest to the 1-node Prevent loneliness & promote sibling’s Entry
No further processing needed in this case Example: remove(10)
4 9
6 82 10
![Page 71: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/71.jpg)
Case 1: Transfer
Has adjacent 3- or 4-node sibling Steal parent’s Entry closest to the 1-node Prevent loneliness & promote sibling’s Entry
No further processing needed in this case Example: remove(10)
4 9
6 82 10
![Page 72: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/72.jpg)
Case 1: Transfer
Has adjacent 3- or 4-node sibling Steal parent’s Entry closest to the 1-node Prevent loneliness & promote sibling’s Entry
No further processing needed in this case Example: remove(10)
4 9
6 82 10
![Page 73: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/73.jpg)
Case 1: Transfer
Has adjacent 3- or 4-node sibling Steal parent’s Entry closest to the 1-node Prevent loneliness & promote sibling’s Entry
No further processing needed in this case Example: remove(10)
4 9
6 82 10
![Page 74: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/74.jpg)
Case 1: Transfer
Has adjacent 3- or 4-node sibling Steal parent’s Entry closest to the 1-node Prevent loneliness & promote sibling’s Entry
No further processing needed in this case Example: remove(10)
4 9
6 82
![Page 75: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/75.jpg)
Case 1: Transfer
Has adjacent 3- or 4-node sibling Steal parent’s Entry closest to the 1-node Prevent loneliness & promote sibling’s Entry
No further processing needed in this case Example: remove(10)
4 9
6 82
![Page 76: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/76.jpg)
Case 1: Transfer
Has adjacent 3- or 4-node sibling Steal parent’s Entry closest to the 1-node Prevent loneliness & promote sibling’s Entry
No further processing needed in this case Example: remove(10)
4
6 82 9
![Page 77: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/77.jpg)
Case 1: Transfer
Has adjacent 3- or 4-node sibling Steal parent’s Entry closest to the 1-node Prevent loneliness & promote sibling’s Entry
No further processing needed in this case Example: remove(10)
4
6 82 9
![Page 78: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/78.jpg)
Case 1: Transfer
Has adjacent 3- or 4-node sibling Steal parent’s Entry closest to the 1-node Prevent loneliness & promote sibling’s Entry
No further processing needed in this case Example: remove(10)
4 8
62 9
![Page 79: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/79.jpg)
Case 1: Transfer
Has adjacent 3- or 4-node sibling Steal parent’s Entry closest to the 1-node Prevent loneliness & promote sibling’s Entry
No further processing needed in this case Example: remove(10)
4 8
62 9
![Page 80: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/80.jpg)
Emptied node has adjacent 2-node sibling Merge node & sibling into one Look to parent and steal Entry between
siblings May propagate underflow to parent!
Example: remove(15)
Case 2: Fusion Mom
9 14
102 5 7
![Page 81: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/81.jpg)
Emptied node has adjacent 2-node sibling Merge node & sibling into one Look to parent and steal Entry between
siblings May propagate underflow to parent!
Example: remove(15)9 14
Case 2: Fusion
102 5 7
Mom
![Page 82: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/82.jpg)
Emptied node has adjacent 2-node sibling Merge node & sibling into one Look to parent and steal Entry between
siblings May propagate underflow to parent!
Example: remove(15)9
Case 2: Fusion
10 142 5 7
Mom
![Page 83: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/83.jpg)
Emptied node has adjacent 2-node sibling Merge node & sibling into one Look to parent and steal Entry between
siblings May propagate underflow to parent!
Example: remove(15)9
Case 2: Fusion
10 142 5 7
Mom
![Page 84: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/84.jpg)
Emptied node has adjacent 2-node sibling Merge node & sibling into one Look to parent and steal Entry between
siblings May propagate underflow to parent!
Example: remove(15)9
Case 2: Fusion
10 142 5 7
Mom
![Page 85: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/85.jpg)
Deletion from MultiWay Tree
Removal like BST: swap element to legal node If removal causes underflow, check its nearest
siblings If 3-node or 4-node as sibling, then solution is
easy…… move sibling up and bring parent down into node
Merge with sibling & parent data if no big neighbor…… but must then check if parent has an underflow
![Page 86: CSC 213 – Large Scale Programming. Today’s Goals Review a new search tree algorithm is needed What real-world problems occur with old tree? Why.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e035503460f94aeeccb/html5/thumbnails/86.jpg)
For Next Lecture
Wednesday will be quiz on real-world stuff Garbage collection, cache behavior & trees
(oh, my) End of day Wednesday lab project is
due Will have regular hour during lab, too
At end of day on Friday will have Project #3 due