CS3223 Tutorial 2

Click here to load reader

download CS3223 Tutorial 2

of 38

description

CS3223 Tutorial 2. Fan Qi [email protected] Database Lab 1, com1 #01-08. B+ Tree. Data Entry: Format 1: actual data record Format 2: key + RID Format 3: key, RID-List Properties & Attributes: Height Balanced Every node except root must be half full, [ d,2d] - PowerPoint PPT Presentation

Transcript of CS3223 Tutorial 2

CS3223 Tutorial 2

Fan Qi [email protected] Lab 1, com1 #01-08CS3223 Tutorial 2B+ TreeData Entry:Format 1: actual data record Format 2: key + RIDFormat 3: key, RID-ListProperties & Attributes:Height BalancedEvery node except root must be half full, [d,2d]Fanout: # of pointers out of a non-leaf node

B+ TreeOperations:Search: Insert: If siblings do not have space, split Delete: If siblings are just of d, Merge, else borrow one (redistribution)

Redistribution in insertion is not frequently used in practiceQuestion 150125673858183240810182732395258738041459199Question 150125673858183240810182732395258738041459199g): Insert 59Question 150125673858183240810182732395258738041459199g): Insert 59Question 150125673858183240810182732395258738041459199g): Insert 59Question 15012567385818324081018273239525859738041459199g): Insert 59Question 15012567385818324081018273239525859738041459199g): Insert 59 Delete 91Question 15012567385818324081018273239525859738041459199g): Insert 59 Delete 91Question 15012567385818324081018273239525859738041459199g): Insert 59 Delete 91Question 150125673858183240810182732395258597380414599g): Insert 59 Delete 91Underflow!Question 1501256738183240810182732395258597380994145g): Insert 59 Delete 91Redistribution FailedMerge!Question 1501256738183240810182732395258597380994145g): Insert 59 Delete 91Underflow again!Question 1401256507381832810182732395258597380994145g): Insert 59 Delete 91RedistributionQuestion 2818324012561256Question 310203080ABC35425065909836385152566030314243989910010568697079818294959697Question 310203080ABC35425065909836385152566030314243989910010568697079818294959697Question 310203080ABC35425065909836385152566030314243989910010568697079818294959697Question 310203080ABC35425065909836385152566030314243989910010568697079818294959697Question 310203080ABC35425065909836385152566030314243989910010568697079818294959697b): Insert a recode with key 109Split!!Question 310203080ABC35425065909810036385152566030314243989968697079818294959697b): Insert a recode with key 109100105109Question 310203080ABC35425065909836385152566030314243989910010568697079818294959697d):Which value would resultIncreasing in tree height?65-79, assume internal nodes do not re-distributeQuestion 411, 5, 3, 31,19,2,7,17,23,29,4,50,40,44Top-downQuestion 411, 5, 3, 31,19,2,7,17,23,29,4,50,40,44Top-down35113131Question 411, 5, 3, 31,19,2,7,17,23,29,4,50,40,44Top-downSplit1119313511Question 411, 5, 3, 31,19,2,7,17,23,29,4,50,40,44Top-down11235711171931Question 411, 5, 3, 31,19,2,7,17,23,29,4,50,40,44Top-down111923571117Split192331Question 411, 5, 3, 31,19,2,7,17,23,29,4,50,40,44Top-down11192357111719232931Question 411, 5, 3, 31,19,2,7,17,23,29,4,50,40,44Top-down41119231117Split19232931457Question 411, 5, 3, 31,19,2,7,17,23,29,4,50,40,44Top-down4111929231117Split1923457293150Question 411, 5, 3, 31,19,2,7,17,23,29,4,50,40,44Top-down4111929231117192345729314050Question 411, 5, 3, 31,19,2,7,17,23,29,4,50,40,44Top-down411192923111719234572931Split404450Question 411, 5, 3, 31,19,2,7,17,23,29,4,50,40,44Top-down41123111719234572931Further Split404450294019Question 411, 5, 3, 31,19,2,7,17,23,29,4,50,40,44Bulk Loading7234423457111719232931404445Pros and Cons ?35Self Thinking QuestionWhen data has duplication, how to handle it in B+ tree ?Try to implement a B+ tree by yourself

B+ Tree In Reality

Further Doubts?TA Contact:Fan Qi [email protected] Lab 1, com1 #01-08

Happy Chinese New Year !