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

Constructor

Program gif gives the code for the PartitionTree constructor. The constructor creates a tree comprised of a single node. It takes an argument which specifies the element of the universal set that the node is to represent. The parent field is set to null to indicate that the node has no parent. Consequently, the node is a root node. Finally, the rank field is initialized to zero. The running time of the constructor is O(1).

Program gif shows the constructor for the PartitionAsForest class. The constructor takes a single argument N which specifies that the universe shall be tex2html_wrap_inline66431. It creates an initial partition of the universe consisting of N parts. Each part contains one element of the universal set and, therefore, comprises a one-node tree.

   program28682
Program: PartitionAsForest constructors.


next up previous contents index

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