Is there a smart way to search the TreeView control?
thank you.
Printable View
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 SearchQuote:
Originally posted by AlexKrat
Is there a smart way to search the TreeView control?
thank you.
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.Quote:
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!
I guess if we remove a branch we are back to the same problem.