11-7 notes - 11-7 NotesAlgorithms and Data Structures•Every node of a B-tree must contain at least t-1 keys and at most 2t-1 keys(except root may

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 11-7 NotesAlgorithms and Data Structures•Every node of a B-tree must contain at least t-1 keys and at most 2t-1 keys (except root may have as few as one key)M/ \DH QTX/ | \ / | | \BC FG JKL NP RS UW YZ•Find out how are we going to implement insertion and deletion in a B-Tree that is guaranteed?•InsertionoKey: how do we (1) not create new levels at a level below current leaves, (2) insert if a leaf is already full?oIdea: node splittingT = 3 (full = 5 keys)Leaf: PQRST Parent: NWSplit leaf at RNew Leaves: PQ && ST new Parent: NRWRedistribute any sub-leavesoCodeSPLIT(x)//x is fullK kt(x)Create node xLfrom k1(x)…kt-1(x)Create xRfrom kt+1(x)…k2t-1(x)Move k into parent of xAdd pointers to xL, xRon either side of koProblems:What if the parent is full?•Make sure it never happensWhat if x is root?•create a new rootWhat is the parent?•Always go down, never upoIdea: do recursive DoINsert(x,k)o*Invariant: when we call DoInsert(x,k),Either x is rootOr x’s parent is not fulloCode:Insert(T, k)DoInsert(T.root, k)DoInsert(T....
View Full Document

This note was uploaded on 12/05/2011 for the course ENGINEERIN 131 taught by Professor Cytron during the Spring '11 term at Washington University in St. Louis.

Page1 / 3

11-7 notes - 11-7 NotesAlgorithms and Data Structures•Every node of a B-tree must contain at least t-1 keys and at most 2t-1 keys(except root may

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online