diff --git a/README.md b/README.md index 072d1e6..9a6d4c6 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Segment Tree (one-dimensional) from segment_tree import * array = [3, 1, 5, 3, 13, 7, 2, 7, 2] - tree = SegmentTree(array) + t = SegmentTree(array) t.query(1, 3, "sum") # 9 t.update(0, 10) # [10, 1, 5, 3, 13, 7, 2, 7, 2] @@ -56,11 +56,11 @@ Multidimensional Segment Tree (alpha version, might have bugs) ```python from segment_tree import * a = [[[1, 2], [1, 3]], [[-1, -2], [-1, -3]]] - tree = MultidimensionalSegmentTree(a) + t = MultidimensionalSegmentTree(a) - tree.query([(0, 1), (0, 0), (0, 0)], max) # 1 - tree.query([(1, 1), (0, 1), (0, 1)], sum) # -7 - tree.query([(0, 1), (1, 1), (0, 1)], min) # -3 + t.query([(0, 1), (0, 0), (0, 0)], max) # 1 + t.query([(1, 1), (0, 1), (0, 1)], sum) # -7 + t.query([(0, 1), (1, 1), (0, 1)], min) # -3 ``` ## Operations and their complexity diff --git a/segment_tree/operations.py b/segment_tree/operations.py index c176406..0882829 100644 --- a/segment_tree/operations.py +++ b/segment_tree/operations.py @@ -18,5 +18,5 @@ def max_multiple(x, count): sum_operation = Operation("sum", sum, add_multiple, 0) -min_operation = Operation("min", min, min_multiple, 1e9) -max_operation = Operation("max", max, max_multiple, -1e9) +min_operation = Operation("min", min, min_multiple, +float('inf')) +max_operation = Operation("max", max, max_multiple, -float('inf')) diff --git a/segment_tree/segment_tree.py b/segment_tree/segment_tree.py index 8b6c3a1..598192f 100644 --- a/segment_tree/segment_tree.py +++ b/segment_tree/segment_tree.py @@ -1,4 +1,4 @@ -from segment_tree.operations import * +from .operations import * class SegmentTree: diff --git a/setup.py b/setup.py index c63e029..aa584cd 100644 --- a/setup.py +++ b/setup.py @@ -16,4 +16,4 @@ license='MIT', packages=find_packages(exclude=['tests*']), keywords='segment, tree, range, rmq, multidimensional', - python_requires='>=3') + python_requires='>=2.7')