Did someone say binary search?

> A more efficient solution is to start with the last known revision of
> the document, if this is your first access then you start with 1. 
> Test to see whether this document exists, if not, try the next one
> until you find a document which does exist.  Take this to be your
> starting point, call it S.  Next you try requesting S*2, then S*4,
> then S*8, doubling each time, until your request fails, say at point
> P.  You now know that the latest version of the document is between P
> and S.  You try requesting the document at (P+S)/2, if this exists
> then your new P becomes (P+S)/2, if not, your new S becomes (P+S)/2. 
> Through this mechanism you can rapidly "home in" on the correct
> document.  So, for example, for a document with 20 revisions, the
> following documents would be requested in this order:

> 1,2,4,8,16,32,24,20,22,21

> Ok, 10 requests sounds like alot, however recall that future requests
> for this document will know that there are at least 20 revisions, and
> this will speed things up dramatically.  This algorithm also scales
> excellently ( O(ln n) time).

_______________________________________________
Freenet-dev mailing list
Freenet-dev at lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/freenet-dev

Reply via email to