POV-Ray : Newsgroups : povray.off-topic : BST : Re: BST Server Time
29 Jul 2024 14:26:56 EDT (-0400)
  Re: BST  
From: Kevin Wampler
Date: 31 Jan 2012 11:37:10
Message: <4f2818b6$1@news.povray.org>
On 1/31/2012 7:49 AM, Kevin Wampler wrote:
>
> Although I haven't done it myself, I believe if you actually do the
> complexity analysis you'll find that the lack of random access doesn't
> change the complexity of the obvious recursive algorithm except by a
> constant factor.

Ok, I actually looked at it and the obvious algorithm does take O(n 
log(n)) on a linked list.  But you I think you can modify it prettily 
easily to run in O(n) by treating the linked list as a list of trees of 
size 1, and iteratively running through the list and forming larger 
trees from the smaller ones.  There's probably some fiddily details to 
get balancing just right while ensuring combining the sub-trees takes 
O(1) though, but I think it'll all work out.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.