in reply to Re: Can I speed this up? (Algorithm error)
in thread Can I speed this up? (repetitively scanning ranges in a large array)

I think you misunderstood the question, probably due my poor explanation. You have to look both sides at the same time in a single range. You can't pick one range that has a far right side and another that has a far left side. In other words: for each position i we are looking for the (half) size of the minimal (odd-sized) window which is centered around i, and is not contained by any (single) range. You can't 'split' the containment between two ranges.

Going back to the example of position 1:

half size 0: there exists a range that covers 1,1
half size 1: there exists a range that covers 35,2
half size 2: there exists a range that covers 34,3
...
half size 8: there exists a range that covers 28,9 (e.g. 28,10)
half size 9: there is NO range that covers 27,10. DONE!

I hope it's more clear now.

(p.s. in your ASCII art it seems as if MAX=36, not 35, doesn't it?)

  • Comment on Re^2: Can I speed this up? (Algorithm error)

Replies are listed 'Best First'.
Re^3: Can I speed this up? (Algorithm error)
by BrowserUk (Patriarch) on Nov 03, 2010 at 20:37 UTC

    Thanks for the clarification. Back to my drawing board :)

    (p.s. in your ASCII art it seems as if MAX=36, not 35, doesn't it?)

    No. The last vertical line of '|'s is just a border. Notice that there are no stars in in it.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.