diff --git a/fenwick/__init__.py b/fenwick/__init__.py index bffb0fc..f385d56 100644 --- a/fenwick/__init__.py +++ b/fenwick/__init__.py @@ -1 +1,3 @@ from .fenwick import FenwickTree, __version__ + +__all__ = ["FenwickTree", "__version__"] diff --git a/fenwick/fenwick.py b/fenwick/fenwick.py index 215353d..6d2e62e 100644 --- a/fenwick/fenwick.py +++ b/fenwick/fenwick.py @@ -17,6 +17,7 @@ # * Core # ************************************************************ + class FenwickTree(object): """ A data structure for maintaining cumulative (prefix) sums. @@ -88,7 +89,7 @@ def init(self, frequencies): raise ValueError("Length of frequencies must match length of FenwickTree.") self._v = list(frequencies) for idx in range(1, self._n + 1): - parent_idx = idx + (idx & -idx) # parent in update tree + parent_idx = idx + (idx & -idx) # parent in update tree if parent_idx <= self._n: self._v[parent_idx - 1] += self._v[idx - 1]