Data Structures and Algorithms with Object-Oriented Design Patterns in C#
next up previous contents index

Implementing Search Trees

Since search trees are designed to support efficient searching, it is only appropriate that they implement the SearchableContainer interface. Recall from Section gif that the searchable container interface includes the operations Find, IsMember, Insert, and Withdraw.

   figure18564
Figure: Object class hierarchy

Program gif defines the SearchTree interface. The SearchTree interface extends the Tree interface defined in Program gif and the SearchableContainer interface defined in Program gif.

   program18578
Program: SearchTree interface.

In addition, two properties are defined--Min and Max. The Min property provides a get accessor that returns the object contained in the search tree having the smallest key. Similarly, the Max provides a get accessor that returns the contained object having the largest key.




next up previous contents index

Bruno Copyright © 2001 by Bruno R. Preiss, P.Eng. All rights reserved.