473,473 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

tree vs a flat hashtable.

I am doing a dns zone type of project which has an inverted tree like you
all know.
test.com. (top node. value contains arraylist of all test.com records)
www.test.com. (node. value contains arraylist of all matching rrs)
www.sub1.test.com.
....

Bind and (probably) MSs dns, use a tree structure (i.e. red-black tree, etc)
to store and search this data. However, I am thinking this is not required.
I could just use a hash table with the ownerNames as keys. Any rr with
duplicate ownerName is stored in the node (i.e. the value object), so not
sure why I would need/want a tree when I could just use the key for a direct
lookup with the hash code. Naturally, the tree would make it easier to
convert to a GUI Tree control, but that can built by walking the hash and
figuring the heirarcy out in one pass. Although this is a dns specific
example, I am sure others have had similar dev issues with other tree like
data and could provide some thoughts. Cheers!

--
William Stacey, MVP
Nov 16 '05 #1
2 2192
William,

I think this is perfectly feasable. If anything, looking at the
examples you gave, if you process the DNS names backwards, you can cycle
through this easily. Basically, you have this:

www.test.com -> com, test, www
www.sub1.test.com -> com, test, sub1, www

When cycling through the parts, you access them backwards. Your initial
hashtable starts with com, and gets the hashtable using that as the key.
You then take the next part, and search for that entry (in this case, test).
That returns another hashtable to you. In that one, you then search for
www, or sub1 (depending on which input you are using) and so on, and so on.

It would be pretty easy to implement, if you ask me.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"William Stacey [MVP]" <st***********@mvps.org> wrote in message
news:eB**************@tk2msftngp13.phx.gbl...
I am doing a dns zone type of project which has an inverted tree like you
all know.
test.com. (top node. value contains arraylist of all test.com records)
www.test.com. (node. value contains arraylist of all matching rrs)
www.sub1.test.com.
...

Bind and (probably) MSs dns, use a tree structure (i.e. red-black tree, etc) to store and search this data. However, I am thinking this is not required. I could just use a hash table with the ownerNames as keys. Any rr with
duplicate ownerName is stored in the node (i.e. the value object), so not
sure why I would need/want a tree when I could just use the key for a direct lookup with the hash code. Naturally, the tree would make it easier to
convert to a GUI Tree control, but that can built by walking the hash and
figuring the heirarcy out in one pass. Although this is a dns specific
example, I am sure others have had similar dev issues with other tree like
data and could provide some thoughts. Cheers!

--
William Stacey, MVP

Nov 16 '05 #2
Thanks Nicholas. That is what I was thinking as well. Direct hits would be
faster then a tree as you would find it in one hash operation.
www.test.com -> com, test, www
www.sub1.test.com -> com, test, sub1, www

When cycling through the parts, you access them backwards. Your initial hashtable starts with com, and gets the hashtable using that as the key.
You then take the next part, and search for that entry (in this case,

test).

I was thinking it could be even simpler with no nesting other then
collecting same named records in the value object of that hash key. Both of
the above are unique names, so don't have to nest (I think.) If
www.sub1.test.com exists, I find it with one operation. If I look for
"sub1.test.com.", it does not exist, so return not found. Using a tree,
"sub1" would an empty node, but I don't think I need it here. I am getting
that feeling that this can not be this easy and maybe I am missing
something. But I can't think of how this fails at the moment. This method
will take more string space, because I have to use all the labels and not
just the next label as a tree would allow, but not sure that is big thing
unless talking 100s of thousands of records. Does clr string "interning"
eliminate this issue? hmmm. Cheers!
--
wjs

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Xah Lee | last post by:
Here's the belated Java solution. import java.util.List; import java.util.ArrayList; import java.lang.Math; class math { public static List range(double n) { return range(1,n,1); }
0
by: Bonj | last post by:
hello this is a purely algorithmical question but if i have posted to an irrelevant group, apologies. can anyone point me at some good tutorials or info about the steps involved in creating a...
1
by: Jesper DK | last post by:
Hi, I have docked a tree view to the left on a form. When I start to populate this tree view with nodes, a horizontal scroll box appears in the bottom of the tree view even though thee tree...
5
by: JezB | last post by:
I have trawled through the System.Collections namespace looking for some structure that will enable me to represent and manipulate tree structures, as yet to no avail. Of course I can represent...
3
by: Saradhi | last post by:
Hi All, Here I am facing a performance problem with the TreeView Node renaming. I am displaying a hierarchy Data in a treeview in my Windows C# Application. My tree view represents an...
6
by: Kishor | last post by:
Hi, In Visual basic6 there are so many grids using which we can display the tree structure (Multiple column). Same thing I am planning to display the result of query in a tree format,...
8
by: asrs63 | last post by:
Hi, I am a newbee and have a comma seperated flat-file and a DTD. I need to write a C# program which will read the text file and convert it to a XML file as per the the definition in the DTD. I...
3
by: piotrek | last post by:
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...
5
by: Just Another Victim of the Ambient Morality | last post by:
I need a red-black tree in Python and I was wondering if there was one built in or if there's a good implementation out there. Something that, lets face it, does whatever the C++ std::map<allows...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.