Slideshow:
Record lookup( x ) { n = root node; // Start at the root /* ======================================== Traverse internal nodes to reach a leaf ======================================== */ while ( n ≠ leaf node ) { n is indexed using component i; if ( x.compi < n.key ) n = n.left; else n = n.right; } /* ============================ We have reached a leaf node ============================ */ if ( x ∈ n (leaf node) ) { return Record for x } else { return No Found; } } |
Example: lookup age = 35 and salary = 500K
insert ( Record x ) { Use the search key in x to find: the leaf node L that will hold x if ( L has space store store x ) { insert record x in (block) L; } else { Let i = search dimension in parent node of L Let j = the next dimension after i /* ========================================= Split the leaf node L in dimension j ========================================= */ K = the median of search key values in dimension j; Move all records with key < K into block L1; Move all records with key >= K into block L2; Replace L by an internal node with key K; Set: K.left = L1; K.right = L2; } } |
|
|