Click to See Complete Forum and Search --> : TreeView Search


AlexKrat
May 29th, 2002, 12:31 PM
Is there a smart way to search the TreeView control?
thank you.

jparsons
May 30th, 2002, 10:34 AM
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

AlexKrat
May 30th, 2002, 01:37 PM
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!

jparsons
May 31st, 2002, 08:04 AM
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.

AlexKrat
June 3rd, 2002, 10:10 AM
I guess if we remove a branch we are back to the same problem.