POV-Ray : Newsgroups : povray.off-topic : Tape-sort : Re: Tape-sort Server Time
3 Sep 2024 17:15:25 EDT (-0400)
  Re: Tape-sort  
From: Invisible
Date: 13 Oct 2010 04:14:51
Message: <4cb56a7b$1@news.povray.org>
On 12/10/2010 05:06 PM, Warp wrote:

>    Merge sort requires a lot of seeking when comparing partitions. However,
> you can use the RAM to reduce the needed amount of seeking by reading as
> many elements of each partition being compared as possible to RAM, and
> then doing the comparisons in RAM and writing the result to the other
> tape. There will still be a fair amount of seeking (in the tape being
> read), but this RAM buffering will reduce it quite significantly.

And if you put half of the data onto one tape and half of the data onto 
another tape, you can avoid *all* of the tape seeks. Each 
partially-sorted "chunk" is the same as all the others; you don't need 
to keep them arranged with respect to each other. So on each pass, just 
write half of the chunks onto one output tape and half onto the other. 
Then rewind the tapes and merge from both input tapes (again onto two 
output tapes). In this manner, with 4 tapes, you need no tape seeks at 
all. (The number of passes is of course still log N.)


Post a reply to this message

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