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

Finding an Item

The definition of the Find method of the ChainedHashTable class is given in Program gif. The Find method takes as its argument any ComparableObject. The purpose of the Find operation is to return the object in the container that is equal to the given object.

   program11342
Program: ChainedHashTable class Find method.

The Find method simply hashes its argument to select the linked list in which it should be found. Then, it traverses the linked list to locate the target object. As for the Withdraw operation, the worst case running time of the Find method occurs when all the objects in the container have collided, and the item that is being sought does not appear in the linked list. In this case, the running time of the find operation is tex2html_wrap_inline61999.


next up previous contents index

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