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
  Ternary search trees by zem42 2006-11-19 12:55:59
Some variant on the ternary search tree might be helpful. Here is a nice introduction.

Otherwise, you could consider having every node store a hash table of records with the same key, the hash function being computed via the secondary key.

(I assume you have some sort of secondary key that you use to pick out a unique record, e.g. first name when disambiguating "smith", otherwise you do need to cycle through every record anyway, because your definition of a 'target' record becomes unclear).

A third option is to incorporate your secondary key into the <=> function, so that every record does get a unique key when passed to the binary tree's comparator. Could be something as simple as the standard "if (key1a == key1b) return (key2a <=> key2b)".

HTH

zem

[ Reply ]

 

[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.)