S S ,

A Form of Binary search? Nice algorithm. In this case the lookup will be 
rare, and typically only when changing the Postcodes on a particular 
region. So I suspect in this case it would be overkill.

Also being postcodes the data is not simply a list of numbers from 1000 to 
9000 as the first number represents an Australian state, and some have much 
less post codse, with some codes representing millions of Square 
kilometers. 

I suppose my main objective is to make the application of changes easy, and 
in someway's that is simply to allow the user to set numbers and ranges. It 
is then interpreting them on the fly that is my greater concern in this 
application. But I will keep this in mind.

I have no doubt your algoritium could be essential in other data cases.

How do you think it would be implemented in TiddlyWiki?

Regards
Tony


On Wednesday, 20 February 2019 12:42:48 UTC+11, S. S. wrote:
>
>
> Tony,
>
> The method of going through a table by halves is very effective and fast 
> where a number (*N*) lies inside a given range.
> Now how you could do this using TiddlyWiki is the challenge!
>
> The below simple method can look up a table of a million range entries in 
> milliseconds.
>
> 1. Count the number of entries in your table. Say you have 10,000 post 
> codes.
>    Likely the table will be less than 1,000 entries as they are ranges - 
> let us say it is 1,000 ranges (X)
>    First Line is 0 (FL) : FL = 0
>    Note the post code entry that is in the middle position of this table - 
> the X/2 = 500th entry in the table (Integer value) 
>    This is the Search Line(SL) : SL = INT(X/2)
> 2. Check if your number (*N*) is 
>    greater than the start value of this middle entry's post code range
>    AND less than the end value of this range.
>    If it is, you have found the correct range. - Stop here.
>    If not ...
>  3a. Check if the post code *N* is NOT in any range in your table (needed 
> as you narrow down your search)
>      If FL=SL then the Code is Missing - Stop here.
>  3b. If *N* is greater than the start value of the range
>      Make FL = SL
>      check against the higher next half point table entry position: (FL + 
> X)/2  = 750 (Rounded value)
>      Repeat step #2
>  3b. ELSE (meaning *N* is less than the start value of the range)
>      Make X = SL
>      check against the lower next half point table entry position: (FL + 
> X)/2 = 250 (Integer value)
>      and Repeat step #2
>  4. Continue until you reach the end point - I believe 2^10 calculations 
> (1,024) for this size of table.
>
> I doubt you will end up doing it this way, as TiddlyWiki out of the box 
> doesn't seem to be geared for this kind of manipulation.
> Still, it was fun laying you the logic for you!
>
> Cheers
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/0f65b0e9-eae8-41cd-b60b-c71296bbb451%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to