Program defines the constructor and getM methods 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 getM method shown in Program 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 getM method is clearly O(1).