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 2.7 and Python 3.x.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fenwick-0.1.0.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

fenwick-0.1.0-py2.py3-none-any.whl (4.4 kB view hashes)

Uploaded Python 2 Python 3

Supported by

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