From: Remi VANICAT <vanicat@labri.u-bordeaux.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Simple question
Date: 13 Apr 2002 13:10:26 +0200 [thread overview]
Message-ID: <87sn5zg8gt.dlv@wanadoo.fr> (raw)
In-Reply-To: <20020412191529.79299.qmail@web13007.mail.yahoo.com>
Eric Merritt <cyberlync@yahoo.com> writes:
> > erg, apply_fun_list become tail recursive, but it's
> > in O(n^2) (when
> > the first version is in O(n)), and as @ is not tail
> > recursive, this
> > doesn't resolve the problem of Usage of the
> > stack....
> >
> > better stick to the non tail recursive version that
> > to do this.
>
> by this I assume that the '@' function is not as
> strait forward as I thought it would be? In what
> manner does it append to the list to make the time
> 0(n^2)? -just curious.
so let's look at :
let rec apply_fun_list x f_list accum =
match f_list with
h::t ->
apply_fun_list x t (accum@(h x))
| [] ->
accum;;
so the line "apply_fun_list x t (accum@(h x))" is done O(n) time (one
time for each element in f_list), and "(accum@(h x))" take time O(n),
so the time taken by this algorithm is O(n)*O(n)=O(n^2).
--
Rémi Vanicat
vanicat@labri.u-bordeaux.fr
http://dept-info.labri.u-bordeaux.fr/~vanicat
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2002-04-13 11:10 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-04-12 15:51 [Caml-list] Applications written in O'Caml Vincent Foley
2002-04-12 16:15 ` Benjamin C. Pierce
2002-04-12 16:44 ` [Caml-list] Simple question Eric Merritt
2002-04-12 16:59 ` Remi VANICAT
2002-04-12 17:04 ` Maxence Guesdon
2002-04-12 17:57 ` Remi VANICAT
2002-04-12 19:15 ` Eric Merritt
2002-04-12 19:55 ` John Prevost
2002-04-15 20:08 ` Eric Merritt
2002-04-12 20:20 ` james woodyatt
2002-04-13 11:10 ` Remi VANICAT [this message]
2002-04-13 12:45 ` [Caml-list] Applications written in O'Caml Oliver Bandel
2002-04-13 19:07 ` Benjamin C. Pierce
2002-04-12 16:40 ` Maxence Guesdon
2002-04-12 17:04 ` Warp
2002-04-13 2:27 ` eijiro_sumii
2002-04-13 3:28 ` Michael Vanier
2002-04-15 8:16 ` Nicolas barnier
2002-04-16 10:12 ` Jacek Chrzaszcz
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=87sn5zg8gt.dlv@wanadoo.fr \
--to=vanicat@labri.u-bordeaux.fr \
--cc=caml-list@inria.fr \
/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