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
  Cycle through ... not necessarily. by scissors 2002-06-12 06:14:12
You could make a "ternari" tee, using your proposition: each node has tits index value, and THREE pointers: GreaterThan, LesserThan (as the original binary tree does) and ... Equal.
The original binary tree has its records in its leafs, the nodes are merely there for organizing/traversing the data. This part is left intact, but you change the leaves.
If your "search" yealds a "record found" signal, that is: you found your "Smith" node, then all Smith records are in a subtree of this node.
Say, you are a phone company, not having 12 nodes named Smith, but 1200, then your subtree is a new binary/ternary tree, containing all Smith records, sorted by a key that can discriminate between them.
So you binary-search until you hit "TheRightKey", then see it isn't unique, so you search within the "equals" subtree.

As long as you did NOT hit the top-level "ThisNode", you have BinarySearch1, looking for Smith. After you found "Smith", you'll be searching for John (search2, confined to the subtree), when John isn't unique either, search for other data.

Do you have records in your database that are ENTIRELY IDENTICAL? Then re-read J.C. Date's book on Databases and SQL, or look for something explaining "database normalisation" and "relational databases".

Having IDENTICAL RECORDS, as in indistinguishably identical, is of no use for you: you either added the same client/article/order/employee twice (no use for that), OR you forgot to define/fill-in a crucial field: the one that lets you give a raise to John-Smith-the-mailman, without upsetting John-Smith-the-vice-president. The former will be surprised , the latter really mad if their pacheck turns out the same.
[ 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.)