• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

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.

                     Ohio
                    /     \
              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.
0
danchuee
Asked:
danchuee
1 Solution
 
wad4everCommented:
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
0
 
mathbiolCommented:
danchuee,

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.

mathbiol
0
 
boy8964Commented:
I agree with mathbiol
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now