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

Constructor and M Property

Program gif defines the constructor and the M property of the MWayTree class. The constructor takes a single, integer-valued argument that specifies the desired value of M. Provided M is greater than or equal to two, the constructor creates two arrays of length M. Note, a node in an M-way tree contains at most M-1 keys. In the implementation shown, key[0] is never used. Because the constructor allocates arrays of length M, its worst-case running time is O(M).

The M property shown in Program gif provides a get accessor that returns the value of M. That is, it returns the maximum number of subtrees that a node is allows to have. This is simply given by the length of the subtree array. The running time of the accessor is clearly O(1).


next up previous contents index

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