[Home]
[Chapter]
[Contents]
[Previous Algorithm]
[Next Algorithm]


B-tree search


procedure search( key : typekey; t : btree ); var i : integer; begin if t=nil then {*** Not Found ***} notfound( key ) else with t^ do begin i := 1; while ( i<d ) and ( key>k[i] ) do i := i+1; if key = k[i] then {*** Found ***} found( t^, i ) else if key < k[i] then search( key, p[i-1] ) else search( key, p[i] ) end end;

C source (342.srch.c) Pascal source (342.srch.p)



© Addison-Wesley Publishing Co. Inc.