Browse thread
The Implicit Accumulator: a design pattern using optional arguments
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Pal-Kristian Engstad <pal_engstad@n...> |
| Subject: | Re: [Caml-list] Book about functional design patterns |
Quôc Peyrot wrote:
> I don't understand that part. Each time you add a node, log2(n) node
> needs to be re-allocated. Hence the total number of reallocations is:
> Sum(ceil(log2(i)), i = 1..N) with N = 1000000, which is significant.
So you are saying that inserting N elements into a tree takes O(n*log2(n)).
> Where is my mistake in these maths?
No mistake. After all, after insertion you essentially have a sorted
tree, since iterating the tree takes O(n). Sorting take O(n*log n)...
Thanks,
PKE.
--
Pål-Kristian Engstad (engstad@naughtydog.com), Lead Graphics & Engine Programmer,
"Uncharted"-team, Naughty Dog, Inc., 1601 Cloverfield Blvd, 6000 North,
Santa Monica, CA 90404, USA. Ph.: (310) 633-9112.
"Most of us would do well to remember that there is a reason Carmack
is Carmack, and we are not Carmack.",
Jonathan Blow, 2/1/2006, GD Algo Mailing List