Skip to content

Suggestions? #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions segment_tree/operations.py
Original file line number Diff line number Diff line change
@@ -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'))
2 changes: 1 addition & 1 deletion segment_tree/segment_tree.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from segment_tree.operations import *
from .operations import *


class SegmentTree:
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -16,4 +16,4 @@
license='MIT',
packages=find_packages(exclude=['tests*']),
keywords='segment, tree, range, rmq, multidimensional',
python_requires='>=3')
python_requires='>=2.7')