In Database System Concepts, 6th edition, chapter 11, in "Figure 11.11 Querying a B+-tree.", there is a procedure printAll(value V)
. It is used to print all records with search key value V (there can be duplicates). It calls find(V)
, which returns the first leaf node that has key V, and the first index i in that leaf that has that key.
Why doesn't the code include Set i = 1
when i > number of keys in L
?
procedure printAll(value V)
/* prints all records with search key value V */
Set done = false;
Set (L,i) = find(V);
if ((L,i) is null) return
repeat
repeat
Print record pointed to by L.Pi
Set i = i + 1
until (i > number of keys in L or L.Ki > V)
if (i > number of keys in L)
then L = L.Pn // No need to set i to 1?
else Set done = true;
until (done or L is null)