CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #6
    Join Date
    May 2009
    Posts
    2,413

    Re: methods of visiting the nodes on a level of a tree

    Quote Originally Posted by para15000 View Post
    Yes you are right this is a good improvement. It doesn't prevent all the nodes from being visited.
    No it doesn't, but you don't have to visit any nodes below desiredlevel and that can be a substantial saving considering that the bulk of the nodes tend to be at the deepest levels.

    I see.And this would also be done when the tree is constructed? Right?
    That's a possibility but in principle it can be done at any time. And of course if the tree is changed structurally the "level lists" must be updated to reflect that.

    This solution is the fastest because you visit only exactly the nodes at desiredlevel. The drawback is that it requires an additional data structure which needs to be updated each time the tree changes. To what extent this is a problem depends on how often the tree is changed of course. If it never changes the only cost is the extra data structure.
    Last edited by nuzzle; January 25th, 2010 at 01:11 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured