B-tree: insert

From Algowiki
Revision as of 15:56, 25 September 2014 by Lkw (talk | contribs) (Created page with "<code> B-TREE-INSERT(''T'', ''k'') 1 ''r'' = ''T.root'' 2 '''if''' ''r.n'' == 2''t'' - 1 3 ''s'' = ALLOCATE-NODE() 4 ''T.root'' = ''s'' 5 ''s.leaf''...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

B-TREE-INSERT(T, k)
 1 r = T.root
 2 if r.n == 2t - 1
 3      s = ALLOCATE-NODE()
 4      T.root = s
 5      s.leaf = FALSE
 6      s.n = 0
 7      s.c1111 = r
 8      B-TREE-SPLIT-CHILD(s, 1)
 9      B-TREE-INSERT-NONFULL(s, k)
10 else B-TREE-INSERT-NONFULL(r, k)