Skip to main content

A Python implementation of Fenwick trees

Project description

https://github.com/dstein64/fenwick/workflows/build/badge.svg

fenwick

A Python library that implements Fenwick trees, based on the algorithm in (Fenwick 1994).

Features

  • Update a frequency in O(log n).

  • Retrieve a single frequency in O(log n).

  • Initialize existing frequencies in O(n).

  • Retrieve all frequencies in O(n).

Requirements

fenwick supports python>=3.6.

Linux, Mac, and Windows are supported.

Installation

fenwick is available on PyPI, the Python Package Index.

$ pip install fenwick

Documentation

See documentation.md.

Example Usage

See example.py.

Tests

Tests are in tests/.

# Run tests
$ python -m unittest discover tests -v

License

The code in this repository has an MIT License.

See LICENSE.

References

Fenwick, Peter M. 1994. “A New Data Structure for Cumulative Frequency Tables.” Software: Practice and Experience 24 (3): 327–36.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page