tree or linklist

Posted on 2005-04-11
Last Modified: 2010-04-17
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.
Question by:danchuee
    LVL 1

    Expert Comment

    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
    LVL 3

    Accepted Solution


    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.

    LVL 4

    Expert Comment

    I agree with mathbiol

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Adobe Customization Wizard XI issues 26 137
    lucky13 challenge 11 96
    Problem to setup 18 67
    powerN  challenge 3 36
    This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
    A short article about a problem I had getting the GPS LocationListener working.
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now