Here N represents the number of elements in the multi-tree. Please state the algorithm that you have used to do so. It would be great if you can implement this in Java/C++ too and post the code as well.
Also I used union-find to initialize the tree. You can consider or not consider this algorithm. I just need the algorithm to search for the maximum element in a multi-tree. That would clear my problem.