25.11.2014 Views

Algorithms and Data Structures

Algorithms and Data Structures

Algorithms and Data Structures

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

N.Wirth. <strong>Algorithms</strong> <strong>and</strong> <strong>Data</strong> <strong>Structures</strong>. Oberon version 184<br />

key: INTEGER; p: Page<br />

END;<br />

PageRec = RECORD<br />

m: INTEGER; (*no. of entries on page*)<br />

p0: Page;<br />

e: ARRAY 2*N OF Entry<br />

END;<br />

VAR root: Page; W: Texts.Writer;<br />

PROCEDURE search (x: INTEGER; VAR p: Page; VAR k: INTEGER);<br />

VAR i, L, R: INTEGER; found: BOOLEAN; a: Page;<br />

BEGIN<br />

a := root; found := FALSE;<br />

WHILE (a # NIL) & ~found DO<br />

L := 0; R := a.m; (*binary search*)<br />

WHILE L < R DO<br />

i := (L+R) DIV 2;<br />

IF x

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!