POV-Ray : Newsgroups : povray.off-topic : BST Server Time
29 Jul 2024 12:27:22 EDT (-0400)
  BST (Message 11 to 14 of 14)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Kevin Wampler
Subject: Re: BST
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

From: Kevin Wampler
Subject: Re: BST
Date: 31 Jan 2012 11:43:47
Message: <4f281a43$1@news.povray.org>
On 1/31/2012 8:29 AM, Warp wrote:
>
>    Since elements in a BST usually have pointers to each other anyways,
> and since merging two linked lists can be done without requiring any
> additional memory, this whole operation might be possible using O(1)
> memory.

I have the same intuition, although I don't care enough to code it up 
work out the details.


Post a reply to this message

From: Darren New
Subject: Re: BST
Date: 1 Feb 2012 22:07:27
Message: <4f29fdef$1@news.povray.org>
On 1/31/2012 8:43, Kevin Wampler wrote:
> I have the same intuition, although I don't care enough to code it up work
> out the details.

I tried that on math tests a couple times. It didn't fly. :-)

-- 
Darren New, San Diego CA, USA (PST)
   People tell me I am the counter-example.


Post a reply to this message

From: Invisible
Subject: Re: BST
Date: 2 Feb 2012 04:37:54
Message: <4f2a5972@news.povray.org>
On 02/02/2012 03:07 AM, Darren New wrote:
> On 1/31/2012 8:43, Kevin Wampler wrote:
>> I have the same intuition, although I don't care enough to code it up
>> work out the details.
>
> I tried that on math tests a couple times. It didn't fly. :-)

Huh. It worked for Pierre de Fermat. :-P

But I have to say I'm relieved. Sometimes I worry that education has 
sunk to the level where that kind of thing might be OK. Like when I paid 
for university tuition only to have some professor of computer science 
tell me that "float supports numbers up to about 2^38 which is, oh, far 
more than the number of atoms in the entire universe".

(Pro tip: Number of atoms in 12g of carbon = 2^77 or so. The number of 
atoms in the /entire universe/ is clearly much, much larger.)


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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