I think you are in the right direction. Using DFS, the complexity is O(m+n) = O(n). No better complexity I think.
2009/6/26 cgirl <dmitche...@twmi.rr.com>: > > I am trying to determine if an n-ary tree is balanced or not, I have > been stuck trying several approaches and am getting nowhere. My new > thought is that i will have to step through each node of the tree, and > compare the lengths of the roots of the children, making sure there is > not a difference greater than one in the values for all of the > children. Am i thinking in the right direction, or is there a simpler > solution? > > thanks, > kim > > > > -- __________________________________________________ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/algogeeks -~----------~----~----~----~------~----~------~--~---