POV-Ray : Newsgroups : povray.off-topic : BST : Re: BST Server Time
29 Jul 2024 08:12:34 EDT (-0400)
  Re: BST  
From: Kevin Wampler
Date: 31 Jan 2012 10:49:30
Message: <4f280d8a@news.povray.org>
On 1/31/2012 1:23 AM, Invisible wrote:
> Question: If you have a bunch of data in sorted order, how do you build
> a BST from that faster than O(n log n) times?
>
> (I can kind of see how that would work if the data is in an array;
> arrays support random access, so you could just binary chop the array
> and keep the results as a BST. I'm trying to figure out if you can do
> anything with a linked list, which does /not/ support random access...)

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.


Post a reply to this message

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