From: John Carr <jfc@mit.edu>
To: Goswin von Brederlow <goswin-v-b@web.de>
Cc: Francois Berenger <berenger@riken.jp>, caml-list@inria.fr
Subject: Re: [Caml-list] Fwd: interval trees
Date: Thu, 16 Feb 2012 07:20:58 -0500 [thread overview]
Message-ID: <201202161220.q1GCKwnq010821@outgoing.mit.edu> (raw)
In-Reply-To: <87y5s3mb1z.fsf@frosties.localnet>
Goswin von Brederlow <goswin-v-b@web.de> wrote:
> Francois Berenger <berenger@riken.jp> writes:
> >
> > let rec interval_tree intervals =
> > match intervals with
> > [] -> Empty
> > | _ ->
> > let x_mid = median intervals in
> > let left, mid, right = partition intervals x_mid in
> > let left_list = L.sort leftmost_bound_first mid in
> > let right_list = L.sort rightmost_bound_first mid in
> > Node (x_mid,
> > left_list, right_list,
> > interval_tree left, interval_tree right)
> >
> > I'm afraid my program could crash on a very long list of intervals.
>
> Each recursion halves the lists, right? That means you need a very very
> very long list to exceed the recursion depth.
How good is median selection? If it works like quicksort, approximating
the median, typical stack depth is logarithmic and worst case stack
depth is linear. If median selection is precise, creating a balanced
tree, I wouldn't worry about stack depth.
next prev parent reply other threads:[~2012-02-16 12:21 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-10 1:07 Francois Berenger
2012-02-10 18:29 ` Richard W.M. Jones
2012-02-11 17:38 ` Goswin von Brederlow
2012-02-11 17:49 ` Eliot Handelman
2012-02-13 9:13 ` Sebastien Ferre
2012-02-15 1:28 ` Francois Berenger
2012-02-15 15:21 ` Goswin von Brederlow
2012-02-15 17:22 ` Edgar Friendly
2012-02-16 2:48 ` Francois Berenger
2012-02-16 2:32 ` Francois Berenger
2012-02-16 2:42 ` Francois Berenger
2012-02-16 8:34 ` Goswin von Brederlow
2012-02-16 12:20 ` John Carr [this message]
2012-02-16 10:21 ` Gabriel Scherer
2012-02-17 0:59 ` Francois Berenger
2012-02-17 8:11 ` Christophe Raffalli
2012-02-11 20:49 ` Edgar Friendly
2012-02-11 23:54 ` Philippe Veber
2012-02-11 10:54 ` Philippe Veber
2012-02-11 17:33 ` Goswin von Brederlow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201202161220.q1GCKwnq010821@outgoing.mit.edu \
--to=jfc@mit.edu \
--cc=berenger@riken.jp \
--cc=caml-list@inria.fr \
--cc=goswin-v-b@web.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox