25.11.2014 Views

Algorithms and Data Structures

Algorithms and Data Structures

Algorithms and Data Structures

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

B<br />

(LL)<br />

B C A B C<br />

A<br />

C<br />

A<br />

B<br />

(LR)<br />

A C A B C<br />

A<br />

C<br />

B<br />

B<br />

(RR)<br />

A B A B C<br />

A<br />

C<br />

C<br />

B<br />

(RL)<br />

A C A B C<br />

A<br />

C<br />

B<br />

Fig. 4.49. Insertion in SBB-trees<br />

It is advisable to stick no longer to the notion of pages out of which this organization had developed, for<br />

we are only interested in bounding the maximum path length to 2*log(N). For this we need only ensure that<br />

two horizontal pointers may never occur in succession on any search path. However, there is no reason to<br />

forbid nodes with horizontal pointers to the left <strong>and</strong> right, i.e. to treat the left <strong>and</strong> right sides differently. We<br />

therefore define the symmetric binary B-tree as a tree that has the following properties:<br />

1. Every node contains one key <strong>and</strong> at most two (pointers to) subtrees.<br />

2. Every pointer is either horizontal or vertical. There are no two consecutive horizontal pointers on any<br />

search path.<br />

3. All terminal nodes (nodes without descendants) appear at the same (terminal) level.<br />

From this definition it follows that the longest search path is no longer than twice the height of the tree.<br />

Since no SBB-tree with N nodes can have a height larger than log(N), it follows immediately that 2*log(N)<br />

is an upper bound on the search path length. In order to visualize how these trees grow, we refer to Fig.<br />

4.50. The lines represent snapshots taken during the insertion of the following sequences of keys, where<br />

every semicolon marks a snapshot.

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

Saved successfully!

Ooh no, something went wrong!