Cover Data Structures and Algorithms with Object-Oriented Design Patterns in Java
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 Comparable object. The purpose of the find operation is to return the object in the container that is equal to the given object.

   program11239
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_inline61732.


next up previous contents index

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