By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,402 Members | 1,107 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,402 IT Pros & Developers. It's quick & easy.

How to store data - binary tree?

P: n/a
Hi

I would like to ask you a question.

Ian creating app. that download from server directory structure ( whole
tree ) and those data are placed in proper places into my treeview control.
I decided that the most effective way would be : When i connect to the
server once, I download the list and disconnect, instead of connecting every
time i go, to the lower node in my tree hierarhy.
Thus i have a problem - how to store data.
On the C++ i once created binary tree - i tought it might be good idea.
But when i googleed, i found an interesting for me note:
"In most cases binary trees can be replaced by use of one of the .NET
Framework container classes."

Can you tell me few words about this?
Do you think that in my case i should use container class, binary tree or
you have better idea.

Thanks
PK
Jan 26 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
You're right to look for an alternative to writing your own binary tree
system, though there are some you could buy for .Net. Writing a very basic
one is not exactly trivial but then it is not terribly difficult either.

As an alternative, you could use something like a Hashtable or ArrayList to
store your structure, with each succeeding level being stored as another
Hashtable or ArrayList stored as an element of the first collection. But I
wouldn't. Keeping track of your levels of objects and the parent objects,
etc. can be as difficult as writing a simple binary tree.

Another option is to create a custom collection extending CollectionBase and
add a property to your custom collection that is another instance of its own
type. But, again, you'd have to code your own navigation implementation.

I suggest that you create an XmlDocument in memory and build your tree
there. XML is great for storing data in tree-like structures.
--
Dale Preston
MCAD C#
MCSE, MCDBA
"piotrek" wrote:
Hi

I would like to ask you a question.

Ian creating app. that download from server directory structure ( whole
tree ) and those data are placed in proper places into my treeview control.
I decided that the most effective way would be : When i connect to the
server once, I download the list and disconnect, instead of connecting every
time i go, to the lower node in my tree hierarhy.
Thus i have a problem - how to store data.
On the C++ i once created binary tree - i tought it might be good idea.
But when i googleed, i found an interesting for me note:
"In most cases binary trees can be replaced by use of one of the .NET
Framework container classes."

Can you tell me few words about this?
Do you think that in my case i should use container class, binary tree or
you have better idea.

Thanks
PK

Jan 27 '06 #2

P: n/a
Thank you.

I have been thinking about XML, but i seetled that file operations will be
slower than in-memory operations.
Anyway i try with XML.
Jan 27 '06 #3

P: n/a
You can do XML completely in memory.

The benefit is that all the tools are there to navigate and search your tree
structured data. The negative is that there all that functionality comes at
a price. If your set of data is very small it may not be worth the overhead.
If your set of data is very large, it may not be efficient. For what comes
in between, it may be just the ticket.
--
Dale Preston
MCAD C#
MCSE, MCDBA
"piotrek" wrote:
Thank you.

I have been thinking about XML, but i seetled that file operations will be
slower than in-memory operations.
Anyway i try with XML.

Jan 27 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.