Make table of logs reach up to n and return floor(log_2(n)).
(n)
| 221 | |
| 222 | _logtable = [None,0] |
| 223 | def _log2(n): |
| 224 | """Make table of logs reach up to n and return floor(log_2(n)).""" |
| 225 | while len(_logtable) <= n: |
| 226 | _logtable.extend([1+_logtable[-1]]*len(_logtable)) |
| 227 | return _logtable[n] |
| 228 | |
| 229 | # if run as "python lca.py", run tests on random data |
| 230 | # and check that RangeMin's results are correct. |