View Single Post
Old 07-31-2010, 01:55 PM   #6
shall1028
Nameless Being
 
moffatm and J. Strnad's solutions benefit words closest to the centre but make for many clicks to access the first and last sentences of the page.

My solution is to use a "dichotomic divide and conquer search algorithm" sometimes known as a "binary search" (although technically that is for a sorted array of items) to balance out the number of clicks needed to get to any line.

For the following, assume there are 25 sentences on the screen labelled A to Y and 11 words on a line numbered 1 to 11. Also assume we want a word at sentence E number 4.

As with J's idea home+center activates the search. Sentence M (half way) is underlined. If there were 26 sentences (A to Z) then the search would randomly choose M or N.

Since D is less than M we press the up button. The G line is now selected. Again the up button is pressed but now, with an even number of lines left (A to F), the search needs to randomly decide between C and D and say C is chosen.

C is less than E so the down button is pressed. Since C wasn't selected the only options left are D, E and F and since E is the middle line it is underlined.

Now, we are at the line we wanted so we press the middle button to acknowledge the correct line and search for word.

Word number 6 is underlined. 4 is less than 6 so the left button is pressed. Since 6 is not wanted 1 to 5 are the choices and 3 is smack in the middle; it is underlined.

The right button pushed and now the search randomly chooses between 4 and 5. If 4 is the winner we can press the centre button to acknowledge otherwise we need to press the left (to get back to 4 from 5) button then the centre button (technically since there is no other choice the search function could auto-select the 4 word for us).

A similar version of this could be used for go to page number. For that, though, I would divide the page range in 3 blocks so that left, centre and right buttons would select the appropriate zone. Eg. we have 99 pages in our book or chapter (depending on how the go to is to work). The initial ranges would be 1-33, 34-66, 67-99.

If the page range is not divisible by three you need to allocated the remainder. If the remainder is 1 add it to the centre. If the remainder is 2 add 1 to the left and right ranges.

Last edited by shall1028; 07-31-2010 at 01:58 PM.
  Reply With Quote