tree or linklist

I'm working on a chat system right now.

Say I have one State (or room) (name Ohio) and within that state are counties, say 2 of them ( name Orange, Apple) and within each county is a city (name A,B,C,D,E,F). Each person can be part of a group. Now because someone is part of a group doesn't mean that they are in the same county.

Each person can only be in one state, county and city at a time. A person can be in county and not in a city. A person can't be county and in a city.

                    /     \
              Orange        Apple
             /   |   \    /   |   \
            A    B    C  D    E    F

I'm planning to handle 5-10 people at a time. (I would like to have something to handle more but it's not needed right now). I'm trying to find out which would be faster and more effecient and how to code it. I'm thinking a tree would be better suited to handle this because I wouldn't have to go thru each member if I know exactly which level of the tree I wanted to transmit too. (did I say that right).

But then I run into the problem that 'Hey I want to tell my friend hi'. Well the program doesn't know where exactly that person is so it would have to go thru the whole tree to find that person. Then maybe a linklist would be better since I wouldn't have to create a tree and the code would be much smaller.

Maybe I could use a database to store where people are? That way, I could find them pretty quickly? But then if people are telling people hi alot, then processing for the database would rise significantly.

I haven't started with the actual code because I want to get some information and a better idea on what might be better.
Who is Participating?

I vote for database over tree.  They're pretty fast and powerful now; remember, they're designed to handle large data sets.  No opinion about hash table.

Consider using a hash map to identify exactly where the user is. I assume that usernames are unique, so the hash key would just me the username (or user ID number, if such an animal exists). Also, this is nice because it will easily handle massive numbers of users.

Hope this helps!

--- Eric
I agree with mathbiol
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.