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

Thread: TreeView Search

  1. #1
    Join Date
    Aug 2000
    Posts
    69

    TreeView Search

    Is there a smart way to search the TreeView control?
    thank you.

  2. #2
    Join Date
    May 2002
    Location
    Atlanta,GA
    Posts
    262

    Re: TreeView Search

    Originally posted by AlexKrat
    Is there a smart way to search the TreeView control?
    thank you.
    That depends. If you are looking for somehting you know will almost always close to the root, say 1 or 2 steps away then a Breadth first search is appropriate. On the other hand, if you think that it will often be a leaf then you migth want to try a Depth First Search
    Jared

  3. #3
    Join Date
    Aug 2000
    Posts
    69
    In both cases search time is exponential. ( I don't realy know there it is in the tree).
    I thought about a hashtable that holds all tree elements but wasn't sure if it worth the maintance.

    thank you for your help!

  4. #4
    Join Date
    May 2002
    Location
    Atlanta,GA
    Posts
    262
    Originally posted by AlexKrat
    In both cases search time is exponential. ( I don't realy know there it is in the tree).
    I thought about a hashtable that holds all tree elements but wasn't sure if it worth the maintance.

    thank you for your help!
    Hashtables are great for things like that. Also it's relatively easy to maintain. Just create functions for adding and deleting from the tree and make sure they update the Hashtable.
    Jared

  5. #5
    Join Date
    Aug 2000
    Posts
    69
    I guess if we remove a branch we are back to the same problem.

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