• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: binary search trees & binning
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: binary search trees & binning


  • Subject: Re: binary search trees & binning
  • From: Jens Alfke <email@hidden>
  • Date: Tue, 15 Apr 2008 14:56:53 -0700


I need to place many thousands of doubles into size-class groups whose boundaries can be explicitly specified (much like one would do in constructing a histogram, though that's not what I'm doing). The number of size-classes won't be great, usually fewer than 100, say. It occurred to me that using a binary search tree would be a reasonably simple approach

If you had millions of doubles, or even hundreds of thousands, I'd agree. But the time required to toss a few thousand numbers into buckets is likely to be unnoticeably short on today's hardware. Why not implement it in the simplest possible way first, minimizing implementation time instead of runtime, and then benchmark it and see how it does?


In other words, I'd probably first try using a C array of 100 NSMutableArrays, and wrap the doubles in NSNumbers. On every insert you can do a simple binary search to figure out which of the 100 buckets it should go in.
If that's too slow because of the overhead of allocating all those NSNumber objects, I'd switch to using C arrays of double[ ] instead, growing them in chunks using realloc.


—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: binary search trees & binning
      • From: John Stiles <email@hidden>
References: 
 >binary search trees & binning (From: Boyd Collier <email@hidden>)
 >Re: binary search trees & binning (From: Jean-Daniel Dupas <email@hidden>)

  • Prev by Date: Re: [ANN] JSKit - JavaScript Embedding Framework
  • Next by Date: Re: Frameworks in bundles?
  • Previous by thread: Re: binary search trees & binning
  • Next by thread: Re: binary search trees & binning
  • Index(es):
    • Date
    • Thread