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

isEmpty Method

The purpose of the isEmpty method is to determine whether a given N-ary tree is the empty tree. The implementation of this method is given in Program gif. In this implementation, the key field is null if the tree is the empty tree. Therefore, isEmpty method simply tests the key field. Clearly, this is a constant time operation.

   program16146
Program: NaryTree methods.


next up previous contents index

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