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.

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.2.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

fenwick-0.2.0-py2.py3-none-any.whl (4.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file fenwick-0.2.0.tar.gz.

File metadata

  • Download URL: fenwick-0.2.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for fenwick-0.2.0.tar.gz
Algorithm Hash digest
SHA256 151cb712886b4c4f767a9bd4d1a328e22ff61ec8a4d792de762b1d0ec3da43ac
MD5 4c4242f1e34d2961781ae3eb05e9ff89
BLAKE2b-256 cec0c1718b78bf8ce0c9f3e109018fd1c7e3e6b9ed192e91f77779671b5e9852

See more details on using hashes here.

File details

Details for the file fenwick-0.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: fenwick-0.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for fenwick-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 cdbf23efd877bcde8b777af4332dd0b371772ddd072474a0f313ad1394496fa1
MD5 56bf70de4c42df9bf4121b9c46304825
BLAKE2b-256 143dd82aee46ed001ea8fc61fd9a0524235bedba81fb712f40b9ebf7d2dda52b

See more details on using hashes here.

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