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 Tomcat 2002-06-12 05:51:20
First, the definitive reference is Fundamental Algorithms by Donald Knuth.

I have taken two approaches. First is exactly what you suggest, that the "greater" pointer is greater than or equal to. When I'm traversing the tree, I want to find every value. Typically the node contains the index value and a pointer to the rest of the data associated with it, which is what's really of interest. What may or may not be important is whether you get them in the order in which they were added (stability). If you rebalance the tree, you probably won't.

The second option is to add a value to your keys to make them unique, but then you have to write lots of extra code to handle that. I don't recommend it, and I've never done it that way.

I hope this helps.

[ Reply ]
    Traversing entire tree by mikosullivan2002-06-12 06:15:50
      Not necessarily by ninewands2002-06-12 08:16:10
        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.)