The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

Binary trees, non-unique values by mikosullivan2002-06-12 05:04:11
  A couple of possibilities... by Tomcat2002-06-12 05:51:20
    Traversing entire tree by mikosullivan2002-06-12 06:15:50
      Not necessarily by ninewands 2002-06-12 08:16:10
You could use the surname field as the key field for each node of the tree, and have the data field be a pointer to either a substructure that contained all the records that satisfied that key (linked list, another tree, whatever suits your application best).

Alternatively, the key field could just be letters of the alphabet cascading to subtrees of letters of the alphabet so that s-m-i-t-h would be the traversal path to reach the Smiths, while s-u-l-l-i-v-a-n would lead you to the Sullivans. The overhead for this technique is horrendous, but it's hellaciously fast to search.

However, unless this is for something like a homework assignment where you're REQUIRED to use a tree, or you're working with a HUGE database that would completely fill up your RAM, I'd recommend using a hash table of last names instead of a tree. The searches will (usually, generally, almost always) be MUCH faster (best case O(1) is pretty close to the average case if the table size is more than 2n).
[ Reply ]
        hash tables by mikosullivan2002-06-12 09:18:47
          couldn't each by tigermouse2002-06-12 09:45:44

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)